From 9430d05cac522fb1953cb134cf603bcd4db6ad6c Mon Sep 17 00:00:00 2001 From: Nino van Hooff Date: Fri, 25 Oct 2019 15:06:33 +0200 Subject: [PATCH 1/5] WIP: center path slider between view controls and action panel CURA-6874 --- plugins/PreviewStage/PreviewMain.qml | 31 +++++++++++++------ .../SimulationViewMainComponent.qml | 22 ++++++++++--- resources/qml/Cura.qml | 17 ++++++++++ 3 files changed, 57 insertions(+), 13 deletions(-) diff --git a/plugins/PreviewStage/PreviewMain.qml b/plugins/PreviewStage/PreviewMain.qml index 4ef10e5dbb..0b93dea0af 100644 --- a/plugins/PreviewStage/PreviewMain.qml +++ b/plugins/PreviewStage/PreviewMain.qml @@ -12,14 +12,26 @@ import Cura 1.0 as Cura Item { + // An Item whose bounds are guaranteed to be safe for overlays to be placed. + // Defaults to parent, ie. the entire available area + property var safeArea: parent + // Subtract the actionPanel from the safe area. This way the view won't draw interface elements under/over it - Item { - id: safeArea - visible: false - anchors.left: parent.left - anchors.right: actionPanelWidget.left - anchors.top: parent.top - anchors.bottom: actionPanelWidget.top + Rectangle + { + id: childSafeArea + x: safeArea.x - parent.x + y: safeArea.y - parent.y + width: actionPanelWidget.x - x + height: actionPanelWidget.y - y + visible: true // true for debug only + color:"#800000FF" + + Component.onCompleted: { + print("parent", parent.x, parent.y) + print("parent safe", safeArea.x, safeArea.y) + print("previewmain safe", childSafeArea.x, childSafeArea.y, childSafeArea.width, childSafeArea.height) + } } Loader @@ -29,9 +41,10 @@ Item source: UM.Controller.activeView != null && UM.Controller.activeView.mainComponent != null ? UM.Controller.activeView.mainComponent : "" - onLoaded: { + onLoaded: + { if (previewMain.item.safeArea !== undefined){ - previewMain.item.safeArea = Qt.binding(function() { return safeArea }); + previewMain.item.safeArea = Qt.binding(function() { return childSafeArea }); } } } diff --git a/plugins/SimulationView/SimulationViewMainComponent.qml b/plugins/SimulationView/SimulationViewMainComponent.qml index cd7d108370..0cd2027dfa 100644 --- a/plugins/SimulationView/SimulationViewMainComponent.qml +++ b/plugins/SimulationView/SimulationViewMainComponent.qml @@ -18,7 +18,10 @@ Item property bool isSimulationPlaying: false + readonly property var layerSliderSafeYMin: safeArea.y readonly property var layerSliderSafeYMax: safeArea.y + safeArea.height + readonly property var pathSliderSafeXMin: safeArea.x + playButton.width //todo playbutton margin or group button + slider in an item? + readonly property var pathSliderSafeXMax: safeArea.x + safeArea.width visible: UM.SimulationView.layerActivity && CuraApplication.platformActivity @@ -26,13 +29,21 @@ Item PathSlider { id: pathSlider + + readonly property var preferredWidth: UM.Theme.getSize("slider_layerview_size").height // not a typo, should be as long as layerview slider + readonly property var margin: UM.Theme.getSize("default_margin").width + readonly property var pathSliderSafeWidth: pathSliderSafeXMax - pathSliderSafeXMin + height: UM.Theme.getSize("slider_handle").width - width: UM.Theme.getSize("slider_layerview_size").height + width: preferredWidth + margin * 2 < pathSliderSafeWidth ? preferredWidth : pathSliderSafeWidth - margin * 2 + anchors.bottom: parent.bottom - anchors.bottomMargin: UM.Theme.getSize("default_margin").height + anchors.bottomMargin: margin anchors.horizontalCenter: parent.horizontalCenter + anchors.horizontalCenterOffset: -(parent.width - pathSliderSafeXMax - pathSliderSafeXMin) / 2 // center between parent top and layerSliderSafeYMax + visible: !UM.SimulationView.compatibilityMode @@ -184,16 +195,19 @@ Item { property var preferredHeight: UM.Theme.getSize("slider_layerview_size").height property double heightMargin: UM.Theme.getSize("default_margin").height + property double layerSliderSafeHeight: layerSliderSafeYMax - layerSliderSafeYMin + //todo incorporate margins in safeHeight? + id: layerSlider width: UM.Theme.getSize("slider_handle").width - height: preferredHeight + heightMargin * 2 < layerSliderSafeYMax ? preferredHeight : layerSliderSafeYMax - heightMargin * 2 + height: preferredHeight + heightMargin * 2 < layerSliderSafeHeight ? preferredHeight : layerSliderSafeHeight - heightMargin * 2 anchors { right: parent.right verticalCenter: parent.verticalCenter - verticalCenterOffset: -(parent.height - layerSliderSafeYMax) / 2 // center between parent top and layerSliderSafeYMax + verticalCenterOffset: -(parent.height - layerSliderSafeYMax - layerSliderSafeYMin) / 2 // center between parent top and layerSliderSafeYMax rightMargin: UM.Theme.getSize("default_margin").width bottomMargin: heightMargin topMargin: heightMargin diff --git a/resources/qml/Cura.qml b/resources/qml/Cura.qml index 828d8854dd..023072ddd3 100644 --- a/resources/qml/Cura.qml +++ b/resources/qml/Cura.qml @@ -301,6 +301,17 @@ UM.MainWindow } } + // A hint for the loaded content view. Overlay items / controls can safely be placed in this area + Rectangle { + id: mainSafeArea + anchors.left: viewOrientationControls.right + anchors.right: main.right + anchors.top: main.top + anchors.bottom: main.bottom + visible: true // set to true for debugging only + color:"#8000FF00" + } + Loader { // A stage can control this area. If nothing is set, it will therefore show the 3D view. @@ -316,6 +327,12 @@ UM.MainWindow } source: UM.Controller.activeStage != null ? UM.Controller.activeStage.mainComponent : "" + + onLoaded: { + if (main.item.safeArea !== undefined){ + main.item.safeArea = Qt.binding(function() { return mainSafeArea }); + } + } } Loader From d59a343b3f4020e2ff9742376378d143b4f59ad3 Mon Sep 17 00:00:00 2001 From: Nino van Hooff Date: Mon, 28 Oct 2019 09:59:30 +0100 Subject: [PATCH 2/5] Update simulation slider handle position after width change CURA-6874 --- plugins/SimulationView/PathSlider.qml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugins/SimulationView/PathSlider.qml b/plugins/SimulationView/PathSlider.qml index c7a43c6407..facdbb6a53 100644 --- a/plugins/SimulationView/PathSlider.qml +++ b/plugins/SimulationView/PathSlider.qml @@ -56,6 +56,11 @@ Item return Math.min(Math.max(value, sliderRoot.minimumValue), sliderRoot.maximumValue) } + onWidthChanged : { + // After a width change, the pixel-position of the handle is out of sync with the property value + setHandleValue(handleValue) + } + // slider track Rectangle { From 6bef16bbecd5044b19847d6d4f4b92deba2fe60a Mon Sep 17 00:00:00 2001 From: Nino van Hooff Date: Mon, 28 Oct 2019 10:28:19 +0100 Subject: [PATCH 3/5] Cleanup: make safe areas invisible CURA-6874 --- plugins/PreviewStage/PreviewMain.qml | 2 +- resources/qml/Cura.qml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/PreviewStage/PreviewMain.qml b/plugins/PreviewStage/PreviewMain.qml index 0b93dea0af..719b5c0c0b 100644 --- a/plugins/PreviewStage/PreviewMain.qml +++ b/plugins/PreviewStage/PreviewMain.qml @@ -24,7 +24,7 @@ Item y: safeArea.y - parent.y width: actionPanelWidget.x - x height: actionPanelWidget.y - y - visible: true // true for debug only + visible: false // true for debug only color:"#800000FF" Component.onCompleted: { diff --git a/resources/qml/Cura.qml b/resources/qml/Cura.qml index 023072ddd3..1f7ccf39a5 100644 --- a/resources/qml/Cura.qml +++ b/resources/qml/Cura.qml @@ -308,7 +308,7 @@ UM.MainWindow anchors.right: main.right anchors.top: main.top anchors.bottom: main.bottom - visible: true // set to true for debugging only + visible: false // set to true for debugging only color:"#8000FF00" } From 958a92280845ba9833ca3dae5b86cecd8b0aaf24 Mon Sep 17 00:00:00 2001 From: Nino van Hooff Date: Wed, 30 Oct 2019 10:54:22 +0100 Subject: [PATCH 4/5] Cleanup debugging things for cura-6874 CURA-6874 --- plugins/PreviewStage/PreviewMain.qml | 11 ++--------- .../SimulationView/SimulationViewMainComponent.qml | 14 +++++++------- resources/qml/Cura.qml | 5 ++--- 3 files changed, 11 insertions(+), 19 deletions(-) diff --git a/plugins/PreviewStage/PreviewMain.qml b/plugins/PreviewStage/PreviewMain.qml index 719b5c0c0b..9eac1b9d40 100644 --- a/plugins/PreviewStage/PreviewMain.qml +++ b/plugins/PreviewStage/PreviewMain.qml @@ -17,21 +17,14 @@ Item property var safeArea: parent // Subtract the actionPanel from the safe area. This way the view won't draw interface elements under/over it - Rectangle + Item { id: childSafeArea x: safeArea.x - parent.x y: safeArea.y - parent.y width: actionPanelWidget.x - x height: actionPanelWidget.y - y - visible: false // true for debug only - color:"#800000FF" - - Component.onCompleted: { - print("parent", parent.x, parent.y) - print("parent safe", safeArea.x, safeArea.y) - print("previewmain safe", childSafeArea.x, childSafeArea.y, childSafeArea.width, childSafeArea.height) - } + visible: false } Loader diff --git a/plugins/SimulationView/SimulationViewMainComponent.qml b/plugins/SimulationView/SimulationViewMainComponent.qml index 0cd2027dfa..3b70c69e82 100644 --- a/plugins/SimulationView/SimulationViewMainComponent.qml +++ b/plugins/SimulationView/SimulationViewMainComponent.qml @@ -18,10 +18,10 @@ Item property bool isSimulationPlaying: false - readonly property var layerSliderSafeYMin: safeArea.y - readonly property var layerSliderSafeYMax: safeArea.y + safeArea.height - readonly property var pathSliderSafeXMin: safeArea.x + playButton.width //todo playbutton margin or group button + slider in an item? - readonly property var pathSliderSafeXMax: safeArea.x + safeArea.width + readonly property real layerSliderSafeYMin: safeArea.y + readonly property real layerSliderSafeYMax: safeArea.y + safeArea.height + readonly property real pathSliderSafeXMin: safeArea.x + playButton.width + readonly property real pathSliderSafeXMax: safeArea.x + safeArea.width visible: UM.SimulationView.layerActivity && CuraApplication.platformActivity @@ -30,9 +30,9 @@ Item { id: pathSlider - readonly property var preferredWidth: UM.Theme.getSize("slider_layerview_size").height // not a typo, should be as long as layerview slider - readonly property var margin: UM.Theme.getSize("default_margin").width - readonly property var pathSliderSafeWidth: pathSliderSafeXMax - pathSliderSafeXMin + readonly property real preferredWidth: UM.Theme.getSize("slider_layerview_size").height // not a typo, should be as long as layerview slider + readonly property real margin: UM.Theme.getSize("default_margin").width + readonly property real pathSliderSafeWidth: pathSliderSafeXMax - pathSliderSafeXMin height: UM.Theme.getSize("slider_handle").width width: preferredWidth + margin * 2 < pathSliderSafeWidth ? preferredWidth : pathSliderSafeWidth - margin * 2 diff --git a/resources/qml/Cura.qml b/resources/qml/Cura.qml index 1f7ccf39a5..abae84e7f0 100644 --- a/resources/qml/Cura.qml +++ b/resources/qml/Cura.qml @@ -302,14 +302,13 @@ UM.MainWindow } // A hint for the loaded content view. Overlay items / controls can safely be placed in this area - Rectangle { + Item { id: mainSafeArea anchors.left: viewOrientationControls.right anchors.right: main.right anchors.top: main.top anchors.bottom: main.bottom - visible: false // set to true for debugging only - color:"#8000FF00" + visible: false } Loader From d63499fb245b62385de54532f90545791eeb7f46 Mon Sep 17 00:00:00 2001 From: Nino van Hooff Date: Wed, 30 Oct 2019 10:57:03 +0100 Subject: [PATCH 5/5] Remove redundant visibility properties from Items CURA-6874 --- plugins/PreviewStage/PreviewMain.qml | 1 - resources/qml/Cura.qml | 1 - 2 files changed, 2 deletions(-) diff --git a/plugins/PreviewStage/PreviewMain.qml b/plugins/PreviewStage/PreviewMain.qml index 9eac1b9d40..2926f0d012 100644 --- a/plugins/PreviewStage/PreviewMain.qml +++ b/plugins/PreviewStage/PreviewMain.qml @@ -24,7 +24,6 @@ Item y: safeArea.y - parent.y width: actionPanelWidget.x - x height: actionPanelWidget.y - y - visible: false } Loader diff --git a/resources/qml/Cura.qml b/resources/qml/Cura.qml index abae84e7f0..f13f9e0ce9 100644 --- a/resources/qml/Cura.qml +++ b/resources/qml/Cura.qml @@ -308,7 +308,6 @@ UM.MainWindow anchors.right: main.right anchors.top: main.top anchors.bottom: main.bottom - visible: false } Loader