on xenial help sign in
Support solids and gradients in navigation button highlights
commit78860661df6b712bdbc378a812f88065e0c2effe authorMichał Sawicz <michal.sawicz@canonical.com> dateTue 26 Aug 2014, 13:46 (12 years ago) parent55473f9
5 files changed+24−7
qml/Components/Background.qml+4 qml/Dash/DashNavigation.qml+6−3 qml/Dash/PageHeader.qml+8−4 tests/mocks/Unity/fake_scope.cpp+6 tests/qmltests/Dash/artwork/background.png
qml/Components/Background.qml+4
@@ -15,6 +15,7 @@
1515 */
1616
1717import QtQuick 2.0
18+import Ubuntu.Components 1.1
1819import Utils 0.1 as Utils
1920
2021Loader {
@@ -30,6 +31,9 @@ Loader {
3031 else if (parsedStyle[1] === "gradient") return Utils.Style.luminance(parsedStyle[2], parsedStyle[3]);
3132 }
3233
34+ // FIXME this is only here for highlight purposes (see DashNavigation.qml, too)
35+ readonly property color topColor: parsedStyle ? parsedStyle[2] : UbuntuColors.lightGrey
36+
3337 sourceComponent: {
3438 if (style == "") return null;
3539 if (!parsedStyle) return image;
qml/Dash/DashNavigation.qml+6−3
@@ -34,13 +34,16 @@ Item {
3434 return null;
3535 }
3636
37+ // FIXME this is only here for highlight purposes (see Background.qml, too)
38+ readonly property var background: backgroundItem
39+
3740 visible: navigationButton.currentNavigation || altNavigationButton.currentNavigation
3841
3942 height: visible ? units.gu(5) : 0
4043
4144 QtObject {
4245 id: d
43− readonly property color foregroundColor: scopeStyle.getTextColor(background.luminance)
46+ readonly property color foregroundColor: scopeStyle.getTextColor(backgroundItem.luminance)
4447 readonly property bool bothVisible: altNavigationButton.visible && navigationButton.visible
4548 readonly property real navigationWidth: root.width >= units.gu(60) ? units.gu(40) : root.width
4649 readonly property real buttonWidth: navigationWidth / (bothVisible ? 2 : 1)
@@ -56,7 +59,7 @@ Item {
5659 }
5760
5861 Background {
59− id: background
62+ id: backgroundItem
6063 anchors.fill: parent
6164 style: scopeStyle ? scopeStyle.navigationBackground : "color:///f5f5f5"
6265 }
@@ -98,7 +101,7 @@ Item {
98101
99102 Image {
100103 fillMode: Image.Stretch
101− source: background.luminance > 0.7 ? "graphics/navigation_shadow.png" : "graphics/navigation_shadow_light.png"
104+ source: backgroundItem.luminance > 0.7 ? "graphics/navigation_shadow.png" : "graphics/navigation_shadow_light.png"
102105 x: navigationButton.listView.height > 0 ? altNavigationButton.x : navigationButton.x
103106 width: d.buttonWidth
104107 rotation: 180
qml/Dash/PageHeader.qml+8−4
@@ -379,13 +379,17 @@ Item {
379379 height: units.dp(1)
380380 opacity: 0.6
381381
382− // FIXME this should be a shader when bottomContainer.height != 0
382+ // FIXME this should be a shader when bottomItem exists
383383 // to support image backgrounds
384384 Rectangle {
385385 anchors.fill: parent
386− color: scopeStyle && bottomContainer.height === 0 ?
387− Qt.lighter(Qt.rgba(scopeStyle.background.r, scopeStyle.background.g, scopeStyle.background.b, 1.0), 1.2) :
388− "#CCFFFFFF"
386+ color: if (bottomItem && bottomItem.background) {
387+ Qt.lighter(Qt.rgba(bottomItem.background.topColor.r,
388+ bottomItem.background.topColor.g,
389+ bottomItem.background.topColor.b, 1.0), 1.2);
390+ } else if (!bottomItem && scopeStyle) {
391+ Qt.lighter(Qt.rgba(scopeStyle.background.r, scopeStyle.background.g, scopeStyle.background.b, 1.0), 1.2);
392+ } else "#CCFFFFFF"
389393 }
390394 }
391395
tests/mocks/Unity/fake_scope.cpp+6
@@ -224,12 +224,18 @@ QVariantMap Scope::customizations() const
224224 m["background-color"] = "red";
225225 m["foreground-color"] = "blue";
226226 m["page-header"] = h;
227+ } else if (m_id == "MockScope4") {
228+ h["navigation-background"] = QUrl("../../../tests/qmltests/Dash/artwork/background.png");
229+ m["page-header"] = h;
227230 } else if (m_id == "MockScope5") {
228231 h["background"] = "gradient:///lightgrey/grey";
229232 h["logo"] = QUrl("../../../tests/qmltests/Dash/tst_PageHeader/logo-ubuntu-orange.svg");
230233 h["divider-color"] = "red";
231234 h["navigation-background"] = "color:///black";
232235 m["page-header"] = h;
236+ } else if (m_id == "MockScope6") {
237+ h["navigation-background"] = "gradient:///blue/red";
238+ m["page-header"] = h;
233239 }
234240 return m;
235241}
tests/qmltests/Dash/artwork/background.pngnew file

Binary file not shown.