MonitorExtruderConfiguration.qml 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. // Copyright (c) 2018 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.2
  4. import QtQuick.Controls 2.0
  5. import UM 1.3 as UM
  6. /**
  7. * This component comprises a colored extruder icon, the material name, and the
  8. * print core name. It is used by the MonitorPrinterConfiguration component with
  9. * a sibling instance as well as a MonitorBuildplateConfiguration instance.
  10. *
  11. * NOTE: For most labels, a fixed height with vertical alignment is used to make
  12. * layouts more deterministic (like the fixed-size textboxes used in original
  13. * mock-ups). This is also a stand-in for CSS's 'line-height' property. Denoted
  14. * with '// FIXED-LINE-HEIGHT:'.
  15. */
  16. Item
  17. {
  18. // The material color
  19. property alias color: extruderIcon.color
  20. // The extruder position; NOTE: Decent human beings count from 0
  21. property alias position: extruderIcon.position
  22. // The material name
  23. property alias material: materialLabel.text
  24. // The print core name (referred to as hotendID in Python)
  25. property alias printCore: printCoreLabel.text
  26. // Height is 2 x 18px labels, plus 4px spacing between them
  27. height: 40 * screenScaleFactor // TODO: Theme!
  28. width: childrenRect.width
  29. MonitorIconExtruder
  30. {
  31. id: extruderIcon
  32. color: UM.Theme.getColor("monitor_skeleton_loading")
  33. position: 0
  34. }
  35. Rectangle
  36. {
  37. id: materialLabelWrapper
  38. anchors
  39. {
  40. left: extruderIcon.right
  41. leftMargin: 12 * screenScaleFactor // TODO: Theme!
  42. }
  43. color: materialLabel.visible > 0 ? "transparent" : UM.Theme.getColor("monitor_skeleton_loading")
  44. height: 18 * screenScaleFactor // TODO: Theme!
  45. width: Math.max(materialLabel.contentWidth, 60 * screenScaleFactor) // TODO: Theme!
  46. radius: 2 * screenScaleFactor // TODO: Theme!
  47. Label
  48. {
  49. id: materialLabel
  50. color: UM.Theme.getColor("monitor_text_primary")
  51. elide: Text.ElideRight
  52. font: UM.Theme.getFont("default") // 12pt, regular
  53. text: ""
  54. visible: text !== ""
  55. // FIXED-LINE-HEIGHT:
  56. height: parent.height
  57. verticalAlignment: Text.AlignVCenter
  58. }
  59. }
  60. Rectangle
  61. {
  62. id: printCoreLabelWrapper
  63. anchors
  64. {
  65. left: materialLabelWrapper.left
  66. bottom: parent.bottom
  67. }
  68. color: printCoreLabel.visible > 0 ? "transparent" : UM.Theme.getColor("monitor_skeleton_loading")
  69. height: 18 * screenScaleFactor // TODO: Theme!
  70. width: Math.max(printCoreLabel.contentWidth, 36 * screenScaleFactor) // TODO: Theme!
  71. radius: 2 * screenScaleFactor // TODO: Theme!
  72. Label
  73. {
  74. id: printCoreLabel
  75. color: UM.Theme.getColor("monitor_text_primary")
  76. elide: Text.ElideRight
  77. font: UM.Theme.getFont("default_bold") // 12pt, bold
  78. text: ""
  79. visible: text !== ""
  80. // FIXED-LINE-HEIGHT:
  81. height: parent.height
  82. verticalAlignment: Text.AlignVCenter
  83. }
  84. }
  85. }