Merge branch 'CURA-6874_path_slider_layout' of github.com:Ultimaker/Cura

This commit is contained in:
Jaime van Kessel 2019-10-31 13:15:01 +01:00
commit 9dccbcdd8e
No known key found for this signature in database
GPG Key ID: 3710727397403C91
4 changed files with 53 additions and 14 deletions

View File

@ -12,14 +12,18 @@ 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 { Item
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
} }
Loader Loader
@ -29,9 +33,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

@ -56,6 +56,11 @@ Item
return Math.min(Math.max(value, sliderRoot.minimumValue), sliderRoot.maximumValue) 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 // slider track
Rectangle Rectangle
{ {

View File

@ -18,7 +18,10 @@ Item
property bool isSimulationPlaying: false property bool isSimulationPlaying: false
readonly property var layerSliderSafeYMax: safeArea.y + safeArea.height 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 visible: UM.SimulationView.layerActivity && CuraApplication.platformActivity
@ -26,13 +29,21 @@ Item
PathSlider PathSlider
{ {
id: pathSlider id: pathSlider
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 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,15 @@ UM.MainWindow
} }
} }
// A hint for the loaded content view. Overlay items / controls can safely be placed in this area
Item {
id: mainSafeArea
anchors.left: viewOrientationControls.right
anchors.right: main.right
anchors.top: main.top
anchors.bottom: main.bottom
}
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 +325,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