ExtruderIcon.qml 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. width: contentWidth
  43. height: contentHeight
  44. visible: extruderEnabled
  45. renderType: Text.NativeRendering
  46. horizontalAlignment: Text.AlignHCenter
  47. verticalAlignment: Text.AlignVCenter
  48. }
  49. UM.RecolorImage
  50. {
  51. id: disabledIcon
  52. anchors.fill: parent
  53. anchors.margins: UM.Theme.getSize("thick_lining").width
  54. sourceSize.height: width
  55. source: UM.Theme.getIcon("cross1")
  56. visible: !extruderEnabled
  57. color: "black"
  58. }
  59. }
  60. }