ExtruderIcon.qml 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. sourceSize.width: parent.width
  20. sourceSize.height: parent.height
  21. source: UM.Theme.getIcon("extruder_button")
  22. color: extruderEnabled ? materialColor: "gray"
  23. }
  24. Rectangle
  25. {
  26. id: extruderNumberCircle
  27. width: height
  28. height: Math.round(parent.height / 2)
  29. radius: Math.round(width / 2)
  30. color: UM.Theme.getColor("toolbar_background")
  31. anchors
  32. {
  33. horizontalCenter: parent.horizontalCenter
  34. top: parent.top
  35. // The circle needs to be slightly off center (so it sits in the middle of the square bit of the icon)
  36. topMargin: (parent.height - height) / 2 - 0.1 * parent.height
  37. }
  38. Label
  39. {
  40. id: extruderNumberText
  41. anchors.centerIn: parent
  42. text: index + 1
  43. font: UM.Theme.getFont("very_small")
  44. width: contentWidth
  45. height: contentHeight
  46. visible: extruderEnabled
  47. renderType: Text.NativeRendering
  48. horizontalAlignment: Text.AlignHCenter
  49. verticalAlignment: Text.AlignVCenter
  50. }
  51. UM.RecolorImage
  52. {
  53. id: disabledIcon
  54. anchors.fill: parent
  55. anchors.margins: UM.Theme.getSize("thick_lining").width
  56. sourceSize.width: width
  57. sourceSize.height: width
  58. source: UM.Theme.getIcon("cross1")
  59. visible: !extruderEnabled
  60. color: "black"
  61. }
  62. }
  63. }