Toolbar.qml 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. // Copyright (c) 2015 Ultimaker B.V.
  2. // Cura is released under the terms of the AGPLv3 or higher.
  3. import QtQuick 2.2
  4. import QtQuick.Controls 1.1
  5. import QtQuick.Controls.Styles 1.1
  6. import QtQuick.Layouts 1.1
  7. import UM 1.0 as UM
  8. Item {
  9. id: base;
  10. width: buttons.width;
  11. height: buttons.height
  12. RowLayout {
  13. id: buttons;
  14. anchors.bottom: parent.bottom;
  15. anchors.left: parent.left;
  16. spacing: 1
  17. Repeater {
  18. id: repeat
  19. model: UM.Models.toolModel
  20. Button {
  21. text: model.name;
  22. iconSource: UM.Theme.icons[model.icon];
  23. checkable: true;
  24. checked: model.active;
  25. style: UM.Theme.styles.tool_button;
  26. //Workaround since using ToolButton"s onClicked would break the binding of the checked property, instead
  27. //just catch the click so we do not trigger that behaviour.
  28. MouseArea {
  29. anchors.fill: parent;
  30. onClicked: parent.checked ? UM.Controller.setActiveTool(null) : UM.Controller.setActiveTool(model.id);
  31. }
  32. }
  33. }
  34. }
  35. Rectangle {
  36. width: base.width - 10
  37. height: base.height
  38. z: parent.z - 1
  39. anchors.verticalCenter: parent.verticalCenter
  40. anchors.horizontalCenter: parent.horizontalCenter
  41. color: UM.Theme.colors.button_lining
  42. }
  43. Rectangle {
  44. id: panelBackground;
  45. anchors.left: parent.left;
  46. anchors.top: buttons.bottom;
  47. width: panel.item ? Math.max(panel.width + 2 * UM.Theme.sizes.default_margin.width) : 0;
  48. height: panel.item ? panel.height + 2 * UM.Theme.sizes.default_margin.height : 0;
  49. opacity: panel.item ? 1 : 0
  50. Behavior on opacity { NumberAnimation { duration: 100 } }
  51. color: UM.Theme.colors.tool_panel_background;
  52. Loader {
  53. id: panel
  54. x: UM.Theme.sizes.default_margin.width;
  55. y: UM.Theme.sizes.default_margin.height;
  56. source: UM.ActiveTool.valid ? UM.ActiveTool.activeToolPanel : "";
  57. }
  58. }
  59. }