diff --git a/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml b/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml index cb65da635b..c3c7249155 100644 --- a/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml +++ b/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml @@ -26,129 +26,6 @@ Item { spacing: UM.Theme.getSize("default_margin").height - Row - { - spacing: UM.Theme.getSize("default_margin").width - Label - { - text: catalog.i18nc("@label Followed by extruder selection drop-down.", "Print model with") - anchors.verticalCenter: extruderSelector.verticalCenter - - color: UM.Theme.getColor("setting_control_text") - font: UM.Theme.getFont("default") - visible: extruderSelector.visible - } - ComboBox - { - id: extruderSelector - - model: Cura.ExtrudersModel - { - id: extrudersModel - onModelChanged: extruderSelector.color = extrudersModel.getItem(extruderSelector.currentIndex).color - } - property string color: extrudersModel.getItem(extruderSelector.currentIndex).color - visible: machineExtruderCount.properties.value > 1 - textRole: "name" - width: UM.Theme.getSize("setting_control").width - height: UM.Theme.getSize("section").height - MouseArea - { - anchors.fill: parent - acceptedButtons: Qt.NoButton - onWheel: wheel.accepted = true; - } - - style: ComboBoxStyle - { - background: Rectangle - { - color: - { - if(extruderSelector.hovered || base.activeFocus) - { - return UM.Theme.getColor("setting_control_highlight"); - } - else - { - return UM.Theme.getColor("setting_control"); - } - } - border.width: UM.Theme.getSize("default_lining").width - border.color: UM.Theme.getColor("setting_control_border") - } - label: Item - { - Rectangle - { - id: swatch - height: UM.Theme.getSize("setting_control").height / 2 - width: height - anchors.left: parent.left - anchors.leftMargin: UM.Theme.getSize("default_lining").width - anchors.verticalCenter: parent.verticalCenter - - color: extruderSelector.color - border.width: UM.Theme.getSize("default_lining").width - border.color: !enabled ? UM.Theme.getColor("setting_control_disabled_border") : UM.Theme.getColor("setting_control_border") - } - Label - { - anchors.left: swatch.right - anchors.leftMargin: UM.Theme.getSize("default_lining").width - anchors.right: downArrow.left - anchors.rightMargin: UM.Theme.getSize("default_lining").width - anchors.verticalCenter: parent.verticalCenter - - text: extruderSelector.currentText - font: UM.Theme.getFont("default") - color: !enabled ? UM.Theme.getColor("setting_control_disabled_text") : UM.Theme.getColor("setting_control_text") - - elide: Text.ElideRight - verticalAlignment: Text.AlignVCenter - } - - UM.RecolorImage - { - id: downArrow - anchors.right: parent.right - anchors.rightMargin: UM.Theme.getSize("default_lining").width * 2 - anchors.verticalCenter: parent.verticalCenter - - source: UM.Theme.getIcon("arrow_bottom") - width: UM.Theme.getSize("standard_arrow").width - height: UM.Theme.getSize("standard_arrow").height - sourceSize.width: width + 5 - sourceSize.height: width + 5 - - color: UM.Theme.getColor("setting_control_text") - } - } - } - - onActivated: - { - UM.ActiveTool.setProperty("SelectedActiveExtruder", extrudersModel.getItem(index).id); - extruderSelector.color = extrudersModel.getItem(index).color; - } - onModelChanged: updateCurrentIndex(); - - function updateCurrentIndex() - { - for(var i = 0; i < extrudersModel.rowCount(); ++i) - { - if(extrudersModel.getItem(i).id == UM.ActiveTool.properties.getValue("SelectedActiveExtruder")) - { - extruderSelector.currentIndex = i; - extruderSelector.color = extrudersModel.getItem(i).color; - return; - } - } - extruderSelector.currentIndex = -1; - } - } - } - Column { // This is to ensure that the panel is first increasing in size up to 200 and then shows a scrollbar. diff --git a/plugins/PerObjectSettingsTool/PerObjectSettingsTool.py b/plugins/PerObjectSettingsTool/PerObjectSettingsTool.py index 865401804c..b2d14942ba 100644 --- a/plugins/PerObjectSettingsTool/PerObjectSettingsTool.py +++ b/plugins/PerObjectSettingsTool/PerObjectSettingsTool.py @@ -112,4 +112,4 @@ class PerObjectSettingsTool(Tool): self._single_model_selected = False # Group is selected, so tool needs to be disabled else: self._single_model_selected = True - Application.getInstance().getController().toolEnabledChanged.emit(self._plugin_id, (self._advanced_mode or self._multi_extrusion) and self._single_model_selected) \ No newline at end of file + Application.getInstance().getController().toolEnabledChanged.emit(self._plugin_id, self._advanced_mode and self._single_model_selected) diff --git a/resources/qml/ExtruderButton.qml b/resources/qml/ExtruderButton.qml new file mode 100644 index 0000000000..ba503dba2b --- /dev/null +++ b/resources/qml/ExtruderButton.qml @@ -0,0 +1,80 @@ +// Copyright (c) 2017 Ultimaker B.V. +// Cura is released under the terms of the AGPLv3 or higher. + +import QtQuick 2.2 +import QtQuick.Controls 1.1 + +import UM 1.2 as UM +import Cura 1.0 as Cura + +Button +{ + id: base + + property var extruder; + + text: catalog.i18ncp("@label", "Print Selected Model with %1", "Print Selected Models With %1", UM.Selection.selectionCount).arg(extruder.name) + + style: UM.Theme.styles.tool_button; + iconSource: checked ? UM.Theme.getIcon("material_selected") : UM.Theme.getIcon("material_not_selected"); + + checked: ExtruderManager.selectedObjectExtruders.indexOf(extruder.id) != -1 + enabled: UM.Selection.hasSelection + + property color customColor: base.hovered ? UM.Theme.getColor("button_hover") : UM.Theme.getColor("button"); + + Rectangle + { + anchors.fill: parent + anchors.margins: UM.Theme.getSize("default_lining").width; + + color: "transparent" + + border.width: base.checked ? UM.Theme.getSize("default_lining").width : 0; + border.color: UM.Theme.getColor("button_text") + } + + Item + { + anchors + { + right: parent.right; + top: parent.top; + margins: UM.Theme.getSize("default_lining").width * 3 + } + width: UM.Theme.getSize("default_margin").width + height: UM.Theme.getSize("default_margin").height + + Text + { + anchors.centerIn: parent; + text: index + 1; + color: parent.enabled ? UM.Theme.getColor("button_text") : UM.Theme.getColor("button_disabled_text") + font: UM.Theme.getFont("default_bold"); + } + } + + Rectangle + { + anchors + { + left: parent.left; + top: parent.top; + margins: UM.Theme.getSize("default_lining").width * 3 + } + + color: model.color + + width: UM.Theme.getSize("default_margin").width + height: UM.Theme.getSize("default_margin").height + + border.width: UM.Theme.getSize("default_lining").width + border.color: UM.Theme.getColor("lining"); + } + + onClicked: + { + forceActiveFocus() //First grab focus, so all the text fields are updated + CuraActions.setExtruderForSelection(extruder.id); + } +} diff --git a/resources/qml/Toolbar.qml b/resources/qml/Toolbar.qml index 60fc6fd723..5100a0dacb 100644 --- a/resources/qml/Toolbar.qml +++ b/resources/qml/Toolbar.qml @@ -6,28 +6,33 @@ import QtQuick.Controls 1.1 import QtQuick.Controls.Styles 1.1 import QtQuick.Layouts 1.1 -import UM 1.0 as UM +import UM 1.2 as UM +import Cura 1.0 as Cura -Item { +Item +{ id: base; width: buttons.width; height: buttons.height property int activeY - ColumnLayout { + Column + { id: buttons; anchors.bottom: parent.bottom; anchors.left: parent.left; spacing: UM.Theme.getSize("button_lining").width - Repeater { + Repeater + { id: repeat model: UM.ToolModel { } - Button { + Button + { text: model.name iconSource: UM.Theme.getIcon(model.icon); @@ -45,9 +50,11 @@ Item { } //Workaround since using ToolButton"s onClicked would break the binding of the checked property, instead //just catch the click so we do not trigger that behaviour. - MouseArea { + MouseArea + { anchors.fill: parent; - onClicked: { + onClicked: + { forceActiveFocus() //First grab focus, so all the text fields are updated if(parent.checked) { @@ -61,9 +68,19 @@ Item { } } } + + Item { height: UM.Theme.getSize("default_margin").height; width: 1; visible: extruders.count > 0 } + + Repeater + { + id: extruders + model: Cura.ExtrudersModel { id: extrudersModel } + ExtruderButton { extruder: model } + } } - UM.PointingRectangle { + UM.PointingRectangle + { id: panelBorder; anchors.left: parent.right; @@ -75,7 +92,8 @@ Item { target: Qt.point(parent.right, base.activeY + UM.Theme.getSize("button").height/2) arrowSize: UM.Theme.getSize("default_arrow").width - width: { + width: + { if (panel.item && panel.width > 0){ return Math.max(panel.width + 2 * UM.Theme.getSize("default_margin").width) } @@ -90,7 +108,8 @@ Item { color: UM.Theme.getColor("lining"); - UM.PointingRectangle { + UM.PointingRectangle + { id: panelBackground; color: UM.Theme.getColor("tool_panel_background"); @@ -105,7 +124,8 @@ Item { } } - Loader { + Loader + { id: panel x: UM.Theme.getSize("default_margin").width; @@ -116,6 +136,8 @@ Item { } } + // This rectangle displays the information about the current angle etc. when + // dragging a tool handle. Rectangle { x: -base.x + base.mouseX + UM.Theme.getSize("default_margin").width diff --git a/resources/themes/cura/icons/material_not_selected.svg b/resources/themes/cura/icons/material_not_selected.svg new file mode 100644 index 0000000000..9b3cad88bd --- /dev/null +++ b/resources/themes/cura/icons/material_not_selected.svg @@ -0,0 +1,77 @@ + + + + + + image/svg+xml + + Artboard 3 + + + + + + Artboard 3 + Created with Sketch. + + + + + + + + + + diff --git a/resources/themes/cura/icons/material_selected.svg b/resources/themes/cura/icons/material_selected.svg new file mode 100644 index 0000000000..6589eac416 --- /dev/null +++ b/resources/themes/cura/icons/material_selected.svg @@ -0,0 +1,78 @@ + + + + + + image/svg+xml + + Artboard 3 Copy + + + + + + Artboard 3 Copy + Created with Sketch. + + + + + + + + + + diff --git a/resources/themes/cura/styles.qml b/resources/themes/cura/styles.qml index a7c7dcb6cd..899ea3cf79 100755 --- a/resources/themes/cura/styles.qml +++ b/resources/themes/cura/styles.qml @@ -206,7 +206,9 @@ QtObject { property bool down: control.pressed || (control.checkable && control.checked); color: { - if(control.checkable && control.checked && control.hovered) { + if(control.customColor !== undefined && control.customColor !== null) { + return control.customColor + } else if(control.checkable && control.checked && control.hovered) { return Theme.getColor("button_active_hover"); } else if(control.pressed || (control.checkable && control.checked)) { return Theme.getColor("button_active");