WIP: center path slider between view controls and action panel

CURA-6874
This commit is contained in:
Nino van Hooff 2019-10-25 15:06:33 +02:00
parent 8198762755
commit 9430d05cac
3 changed files with 57 additions and 13 deletions

View file

@ -12,14 +12,26 @@ import Cura 1.0 as Cura
Item 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 // Subtract the actionPanel from the safe area. This way the view won't draw interface elements under/over it
Item { Rectangle
id: safeArea {
visible: false id: childSafeArea
anchors.left: parent.left x: safeArea.x - parent.x
anchors.right: actionPanelWidget.left y: safeArea.y - parent.y
anchors.top: parent.top width: actionPanelWidget.x - x
anchors.bottom: actionPanelWidget.top 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 Loader
@ -29,9 +41,10 @@ Item
source: UM.Controller.activeView != null && UM.Controller.activeView.mainComponent != null ? UM.Controller.activeView.mainComponent : "" source: UM.Controller.activeView != null && UM.Controller.activeView.mainComponent != null ? UM.Controller.activeView.mainComponent : ""
onLoaded: { onLoaded:
{
if (previewMain.item.safeArea !== undefined){ if (previewMain.item.safeArea !== undefined){
previewMain.item.safeArea = Qt.binding(function() { return safeArea }); previewMain.item.safeArea = Qt.binding(function() { return childSafeArea });
} }
} }
} }

View file

@ -18,7 +18,10 @@ Item
property bool isSimulationPlaying: false property bool isSimulationPlaying: false
readonly property var layerSliderSafeYMin: safeArea.y
readonly property var layerSliderSafeYMax: safeArea.y + safeArea.height 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 visible: UM.SimulationView.layerActivity && CuraApplication.platformActivity
@ -26,13 +29,21 @@ Item
PathSlider PathSlider
{ {
id: 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 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.bottom: parent.bottom
anchors.bottomMargin: UM.Theme.getSize("default_margin").height anchors.bottomMargin: margin
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
anchors.horizontalCenterOffset: -(parent.width - pathSliderSafeXMax - pathSliderSafeXMin) / 2 // center between parent top and layerSliderSafeYMax
visible: !UM.SimulationView.compatibilityMode visible: !UM.SimulationView.compatibilityMode
@ -184,16 +195,19 @@ Item
{ {
property var preferredHeight: UM.Theme.getSize("slider_layerview_size").height property var preferredHeight: UM.Theme.getSize("slider_layerview_size").height
property double heightMargin: UM.Theme.getSize("default_margin").height property double heightMargin: UM.Theme.getSize("default_margin").height
property double layerSliderSafeHeight: layerSliderSafeYMax - layerSliderSafeYMin
//todo incorporate margins in safeHeight?
id: layerSlider id: layerSlider
width: UM.Theme.getSize("slider_handle").width 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 anchors
{ {
right: parent.right right: parent.right
verticalCenter: parent.verticalCenter 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 rightMargin: UM.Theme.getSize("default_margin").width
bottomMargin: heightMargin bottomMargin: heightMargin
topMargin: heightMargin topMargin: heightMargin

View file

@ -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 Loader
{ {
// A stage can control this area. If nothing is set, it will therefore show the 3D view. // 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 : "" source: UM.Controller.activeStage != null ? UM.Controller.activeStage.mainComponent : ""
onLoaded: {
if (main.item.safeArea !== undefined){
main.item.safeArea = Qt.binding(function() { return mainSafeArea });
}
}
} }
Loader Loader