Set up window pane's content width so that can right-align

This commit is contained in:
David Rowe 2016-02-17 15:35:35 +13:00
parent 30498760b0
commit 1164e3e303
3 changed files with 15 additions and 12 deletions

View file

@ -80,6 +80,7 @@ Window {
} }
Column { Column {
width: pane.contentWidth
HifiControls.StaticSection { HifiControls.StaticSection {
name: "Currently Running" name: "Currently Running"

View file

@ -59,7 +59,7 @@ Item {
height: width height: width
x: -width / 4 x: -width / 4
y: -width / 4 y: -width / 4
visible: window && window.focus && windowContent.visible visible: window && window.focus && pane.visible
gradient: Gradient { gradient: Gradient {
// GradientStop position 0.5 is at full circumference of circle that fits inside the square. // GradientStop position 0.5 is at full circumference of circle that fits inside the square.
GradientStop { position: 0.0; color: "#ff000000" } // black, 100% opacity GradientStop { position: 0.0; color: "#ff000000" } // black, 100% opacity
@ -79,7 +79,7 @@ Item {
border.width: 3 border.width: 3
border.color: hifi.colors.white50 border.color: hifi.colors.white50
radius: hifi.dimensions.borderRadius radius: hifi.dimensions.borderRadius
visible: window ? !windowContent.visible : false visible: window ? !pane.visible : false
} }
MouseArea { MouseArea {
@ -102,15 +102,15 @@ Item {
} }
onReleased: { onReleased: {
if (hid) { if (hid) {
windowContent.visible = true pane.visible = true
frameContent.visible = true frameContent.visible = true
hid = false; hid = false;
} }
} }
onPositionChanged: { onPositionChanged: {
if (pressed) { if (pressed) {
if (windowContent.visible) { if (pane.visible) {
windowContent.visible = false; pane.visible = false;
frameContent.visible = false frameContent.visible = false
hid = true; hid = true;
} }

View file

@ -120,15 +120,17 @@ Fadable {
property var frame: DefaultFrame { } property var frame: DefaultFrame { }
// Scrollable window content. // Scrollable window content.
property var scroller: Item { property var pane: Item {
id: windowContent property bool isScrolling: scrollView.height < scrollView.contentItem.height
property int contentWidth: scrollView.width - (isScrolling ? 11 : 0)
anchors.fill: parent anchors.fill: parent
anchors.rightMargin: theScrollView.height < theScrollView.contentItem.height ? 11 : 0 anchors.rightMargin: isScrolling ? 11 : 0
Rectangle { Rectangle {
id: contentBackground id: contentBackground
anchors.fill: parent anchors.fill: parent
anchors.rightMargin: theScrollView.height < theScrollView.contentItem.height ? 11 : 0 anchors.rightMargin: parent.isScrolling ? 11 : 0
color: hifi.colors.baseGray color: hifi.colors.baseGray
} }
@ -146,12 +148,12 @@ Fadable {
} }
ScrollView { ScrollView {
id: theScrollView id: scrollView
contentItem: content contentItem: content
horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff
verticalScrollBarPolicy: Qt.ScrollBarAsNeeded verticalScrollBarPolicy: Qt.ScrollBarAsNeeded
anchors.fill: parent anchors.fill: parent
anchors.rightMargin: height < contentItem.height ? 1 : 0 anchors.rightMargin: parent.isScrolling ? 1 : 0
style: ScrollViewStyle { style: ScrollViewStyle {
@ -195,7 +197,7 @@ Fadable {
} }
} }
children: [ swallower, frame, scroller, activator ] children: [ swallower, frame, pane, activator ]
Component.onCompleted: raise(); Component.onCompleted: raise();
Component.onDestruction: windowDestroyed(); Component.onDestruction: windowDestroyed();