ExtruderIcon.qml 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. // Copyright (c) 2018 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.7
  4. import QtQuick.Controls 1.1
  5. import UM 1.2 as UM
  6. Item
  7. {
  8. id: extruderIconItem
  9. implicitWidth: UM.Theme.getSize("extruder_icon").width
  10. implicitHeight: UM.Theme.getSize("extruder_icon").height
  11. property bool checked: true
  12. property color materialColor
  13. property alias textColor: extruderNumberText.color
  14. property bool extruderEnabled: true
  15. UM.RecolorImage
  16. {
  17. id: mainIcon
  18. anchors.fill: parent
  19. source: UM.Theme.getIcon("extruder_button")
  20. color: extruderEnabled ? materialColor: UM.Theme.getColor("disabled")
  21. }
  22. Rectangle
  23. {
  24. id: extruderNumberCircle
  25. width: height
  26. height: Math.round(parent.height / 2)
  27. radius: Math.round(width / 2)
  28. color: UM.Theme.getColor("toolbar_background")
  29. anchors
  30. {
  31. horizontalCenter: parent.horizontalCenter
  32. top: parent.top
  33. // The circle needs to be slightly off center (so it sits in the middle of the square bit of the icon)
  34. topMargin: (parent.height - height) / 2 - 0.1 * parent.height
  35. }
  36. Label
  37. {
  38. id: extruderNumberText
  39. anchors.centerIn: parent
  40. text: index + 1
  41. font: UM.Theme.getFont("small")
  42. color: UM.Theme.getColor("text")
  43. width: contentWidth
  44. height: contentHeight
  45. visible: extruderEnabled
  46. renderType: Text.NativeRendering
  47. horizontalAlignment: Text.AlignHCenter
  48. verticalAlignment: Text.AlignVCenter
  49. }
  50. UM.RecolorImage
  51. {
  52. id: disabledIcon
  53. anchors.fill: parent
  54. anchors.margins: UM.Theme.getSize("thick_lining").width
  55. sourceSize.height: width
  56. source: UM.Theme.getIcon("cross1")
  57. visible: !extruderEnabled
  58. color: UM.Theme.getColor("text")
  59. }
  60. }
  61. }