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