on xenial help sign in
Fix wide layout and adapt to coloured background
commit5c1bae9db8e97301aa6ea3788b06c3ced264954b authorMichał Sawicz <michal.sawicz@canonical.com> dateThu 14 Aug 2014, 14:02 (12 years ago) parent339ae52
4 files changed+52−56
qml/Dash/DashNavigation.qml+32−51 qml/Dash/DashNavigationButton.qml+18−2 qml/Dash/DashNavigationList.qml+1−1 qml/Dash/GenericScopeView.qml+1−2
qml/Dash/DashNavigation.qml+32−51
@@ -38,14 +38,23 @@ Item {
3838
3939 height: visible ? units.gu(5) : 0
4040
41+ QtObject {
42+ id: d
43+ readonly property color foregroundColor: {
44+ if (scopeStyle) return background.luminance > scopeStyle.threshold ? scopeStyle.dark : ScopeStyle.light;
45+ else return background.luminance > 0.7 ? Theme.palette.normal.baseText : "white"
46+ }
47+ readonly property bool bothVisible: altNavigationButton.visible && navigationButton.visible
48+ readonly property real navigationWidth: root.width >= units.gu(60) ? units.gu(40) : root.width
49+ readonly property real buttonWidth: navigationWidth / (bothVisible ? 2 : 1)
50+ }
51+
4152 Rectangle {
4253 id: blackRect
4354 color: "black"
4455 opacity: openList && openList.currentItem && openList.currentItem.visible ? 0.3 : 0
4556 Behavior on opacity { UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration } }
46− // Doesn't matter if navigationButton or altNavigationButton list, they are both at the same y
47− y: navigationButton.listView.y
48− anchors.right: parent.right
57+ anchors { left: parent.left; right: parent.right }
4958 visible: opacity != 0
5059 }
5160
@@ -59,71 +68,43 @@ Item {
5968 id: altNavigationButton
6069 objectName: "altNavigationButton"
6170 height: root.height
62− width: navigationButton.visible ? root.width / 2 : root.width
71+ width: d.buttonWidth
6372 scope: root.scope
6473 scopeStyle: root.scopeStyle
65− listView.width: root.width
74+ foregroundColor: d.foregroundColor
75+ listView.width: d.navigationWidth
6676 isAltNavigation: true
67− }
68−
69− Rectangle {
70− visible: navigationButton.visible && altNavigationButton.visible
71− anchors {
72− top: parent.top
73− bottom: parent.bottom
74− right: navigationButton.left
75− rightMargin: -units.dp(1)
76− }
77− width: units.dp(2)
78− color: scopeStyle ? (background.luminance > scopeStyle.threshold ? scopeStyle.dark : scopeStyle.light) : Theme.palette.normal.baseText
79− opacity: 0.3
77+ showDivider: navigationButton.visible || root.width > d.navigationWidth
8078 }
8179
8280 DashNavigationButton {
8381 id: navigationButton
8482 objectName: "navigationButton"
8583 height: root.height
86− width: altNavigationButton.visible ? root.width / 2 : root.width
87− x: altNavigationButton.visible ? root.width / 2 : 0
84+ width: altNavigationButton.visible ? d.buttonWidth : d.navigationWidth
85+ x: altNavigationButton.visible ? d.buttonWidth : 0
8886 scope: root.scope
8987 scopeStyle: root.scopeStyle
90− listView.width: root.width
88+ foregroundColor: d.foregroundColor
89+ listView.width: d.navigationWidth
9190 listView.x: -x
91+ showDivider: root.width > d.navigationWidth
9292 }
9393
9494 Image {
95− id: dropShadow
9695 fillMode: Image.Stretch
9796 source: "graphics/navigation_shadow.png"
97+ anchors { top: parent.bottom; left: parent.left; right: parent.right }
98+ z: d.bothVisible ? -1 : 0
99+ }
98100
99− readonly property bool bothVisible: navigationButton.visible & altNavigationButton.visible
100−
101− state: "default"
102−
103− states: [
104− State {
105− name: "default"
106− when: !dropShadow.bothVisible || (!altNavigationButton.showList && !navigationButton.showList)
107− PropertyChanges { target: dropShadow; width: root.width; x: 0; rotation: 0 }
108− AnchorChanges { target: dropShadow; anchors.top: parent.bottom; anchors.bottom: undefined }
109− },
110− State {
111− name: "open"
112− PropertyChanges { target: dropShadow; width: navigationButton.width; rotation: 180 }
113− AnchorChanges { target: dropShadow; anchors.bottom: parent.bottom; anchors.top: undefined }
114− },
115− State {
116− name: "mainOpen"
117− extend: "open"
118− when: dropShadow.bothVisible && navigationButton.showList
119− PropertyChanges { target: dropShadow; x: altNavigationButton.x }
120− },
121− State {
122− name: "altOpen"
123− extend: "open"
124− when: dropShadow.bothVisible && altNavigationButton.showList
125− PropertyChanges { target: dropShadow; x: navigationButton.x }
126− }
127− ]
101+ Image {
102+ fillMode: Image.Stretch
103+ source: "graphics/navigation_shadow.png"
104+ x: navigationButton.listView.height > 0 ? altNavigationButton.x : navigationButton.x
105+ width: d.buttonWidth
106+ rotation: 180
107+ anchors.bottom: parent.bottom
108+ visible: d.bothVisible && (navigationButton.listView.height > 0 || altNavigationButton.listView.height > 0)
128109 }
129110}
qml/Dash/DashNavigationButton.qml+18−2
@@ -24,7 +24,9 @@ AbstractButton {
2424 // Set by parent
2525 property var scope: null
2626 property var scopeStyle: null
27+ property color foregroundColor: Theme.palette.normal.baseText
2728 property bool isAltNavigation: false
29+ property bool showDivider: false
2830
2931 // Used by parent
3032 readonly property var currentNavigation: scope && scope[hasNavigation] ? getNavigation(scope[currentNavigationId]) : null
@@ -56,7 +58,7 @@ AbstractButton {
5658 anchors.margins: units.gu(2)
5759 verticalAlignment: Text.AlignVCenter
5860 text: root.currentNavigation ? root.currentNavigation.label : ""
59− color: root.scopeStyle ? root.scopeStyle.foreground : Theme.palette.normal.baseText
61+ color: root.foregroundColor
6062 }
6163
6264 Icon {
@@ -66,7 +68,7 @@ AbstractButton {
6668 name: showList ? "up" : "down"
6769 height: units.gu(2)
6870 width: height
69− color: root.scopeStyle ? root.scopeStyle.foreground : Theme.palette.normal.baseText
71+ color: root.foregroundColor
7072 }
7173
7274 // navigationListView is outside root
@@ -103,6 +105,7 @@ AbstractButton {
103105 visible: height != 0
104106 width: navigationListView.width
105107 scopeStyle: root.scopeStyle
108+ foregroundColor: root.foregroundColor
106109 property real desiredHeight: {
107110 if (root.showList) {
108111 if (navigation && navigation.loaded && x == navigationListView.contentX)
@@ -202,4 +205,17 @@ AbstractButton {
202205 enabled: root.showList
203206 onClicked: root.showList = false
204207 }
208+
209+ Rectangle {
210+ visible: root.showDivider
211+ anchors {
212+ top: parent.top
213+ bottom: parent.bottom
214+ left: parent.right
215+ leftMargin: -units.dp(1)
216+ }
217+ width: units.dp(2)
218+ color: root.foregroundColor
219+ opacity: 0.3
220+ }
205221}
qml/Dash/DashNavigationList.qml+1−1
@@ -23,12 +23,12 @@ Item {
2323 property var navigation: null
2424 property var currentNavigation: null
2525 property var scopeStyle: null
26+ property color foregroundColor: Theme.palette.normal.baseText
2627 signal enterNavigation(var newNavigationId, bool hasChildren)
2728 signal goBackToParentClicked()
2829 signal allNavigationClicked()
2930
3031 readonly property int itemHeight: units.gu(5)
31− readonly property color foregroundColor: root.scopeStyle ? root.scopeStyle.foreground : Theme.palette.normal.baseText
3232 implicitHeight: flickable.contentHeight
3333
3434 Background {
qml/Dash/GenericScopeView.qml+1−2
@@ -438,8 +438,7 @@ FocusScope {
438438
439439 bottomItem: DashNavigation {
440440 scope: scopeView.scope
441− width: parent.width <= units.gu(60) ? parent.width : units.gu(40)
442− anchors.right: parent.right
441+ anchors { left: parent.left; right: parent.right }
443442 windowHeight: scopeView.height
444443 windowWidth: scopeView.width
445444 scopeStyle: scopeView.scopeStyle