on bbbdccd help sign in
unity8/qml/Dash/DashNavigation.qml
117 lines 4.5 kB history raw
1/*
2 * Copyright (C) 2014,2015 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
17import QtQuick 2.4
18import Ubuntu.Components 1.3
19import Dash 0.1
20import "../Components"
22Item {
23 id: root
24 objectName: "dashNavigation"
26 property var scope: null
27 property var scopeStyle: null
29 property alias windowWidth: blackRect.width
30 property alias windowHeight: blackRect.height
31 readonly property var openList: {
32 if (navigationButton.showList) return navigationButton.listView;
33 if (altNavigationButton.showList) return altNavigationButton.listView;
34 return null;
35 }
36 readonly property bool disableParentInteractive: {
37 return navigationButton.showList || altNavigationButton.showList ||
38 navigationButton.inverseMousePressed || altNavigationButton.inverseMousePressed;
39 }
41 // FIXME this is only here for highlight purposes (see Background.qml, too)
42 readonly property var background: backgroundItem
44 visible: height != 0
45 height: navigationButton.currentNavigation || altNavigationButton.currentNavigation ? units.gu(5) : 0
47 QtObject {
48 id: d
49 readonly property color foregroundColor: root.scopeStyle
50 ? root.scopeStyle.getTextColor(backgroundItem.luminance)
51 : theme.palette.normal.baseText
52 readonly property bool bothVisible: altNavigationButton.visible && navigationButton.visible
53 readonly property real navigationWidth: root.width >= units.gu(60) ? units.gu(40) : root.width
54 readonly property real buttonWidth: navigationWidth / (bothVisible ? 2 : 1)
55 }
57 Rectangle {
58 id: blackRect
59 objectName: "blackRect"
60 color: "black"
61 opacity: openList && openList.currentItem && openList.currentItem.visible ? 0.5 : 0
62 Behavior on opacity { UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration } }
63 anchors { left: parent.left; right: parent.right }
64 visible: opacity > 0
65 }
67 Background {
68 id: backgroundItem
69 anchors.fill: parent
70 style: scopeStyle ? scopeStyle.navigationBackground : "color:///#f5f5f5"
71 }
73 Image {
74 fillMode: Image.Stretch
75 source: scopeStyle.backgroundLuminance > 0.2 ? "graphics/navigation_shadow.png" : "graphics/navigation_shadow_light.png"
76 anchors { top: parent.bottom; left: parent.left; right: parent.right }
77 }
79 DashNavigationButton {
80 id: altNavigationButton
81 objectName: "altNavigationButton"
82 height: root.height
83 width: d.buttonWidth
84 scope: root.scope
85 scopeStyle: root.scopeStyle
86 foregroundColor: d.foregroundColor
87 listView.width: d.navigationWidth
88 isAltNavigation: true
89 showDivider: navigationButton.visible || root.width > d.navigationWidth
90 // needed so that InverseMouseArea is above navigationButton
91 z: listView.height > 0 ? 1 : 0
92 }
94 DashNavigationButton {
95 id: navigationButton
96 objectName: "navigationButton"
97 height: root.height
98 width: altNavigationButton.visible ? d.buttonWidth : d.navigationWidth
99 x: altNavigationButton.visible ? d.buttonWidth : 0
100 scope: root.scope
101 scopeStyle: root.scopeStyle
102 foregroundColor: d.foregroundColor
103 listView.width: d.navigationWidth
104 listView.x: -x
105 showDivider: root.width > d.navigationWidth
106 }
108 Image {
109 fillMode: Image.Stretch
110 source: backgroundItem.luminance > 0.7 ? "graphics/navigation_shadow.png" : "graphics/navigation_shadow_light.png"
111 x: navigationButton.listView.height > 0 ? altNavigationButton.x : navigationButton.x
112 width: d.buttonWidth
113 rotation: 180
114 anchors.bottom: parent.bottom
115 visible: d.bothVisible && (navigationButton.listView.height > 0 || altNavigationButton.listView.height > 0)
116 }