2 * Copyright (C) 2014,2015 Canonical, Ltd.
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.
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.
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/>.
18 import Ubuntu.Components 1.3
20 import "../Components"
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;
36 readonly property bool disableParentInteractive: {
37 return navigationButton.showList || altNavigationButton.showList ||
38 navigationButton.inverseMousePressed || altNavigationButton.inverseMousePressed;
41 // FIXME this is only here for highlight purposes (see Background.qml, too)
42 readonly property var background: backgroundItem
45 height: navigationButton.currentNavigation || altNavigationButton.currentNavigation ? units.gu(5) : 0
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)
59 objectName: "blackRect"
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 }
70 style: scopeStyle ? scopeStyle.navigationBackground : "color:///#f5f5f5"
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 }
79 DashNavigationButton {
80 id: altNavigationButton
81 objectName: "altNavigationButton"
85 scopeStyle: root.scopeStyle
86 foregroundColor: d.foregroundColor
87 listView.width: d.navigationWidth
89 showDivider: navigationButton.visible || root.width > d.navigationWidth
90 // needed so that InverseMouseArea is above navigationButton
91 z: listView.height > 0 ? 1 : 0
94 DashNavigationButton {
96 objectName: "navigationButton"
98 width: altNavigationButton.visible ? d.buttonWidth : d.navigationWidth
99 x: altNavigationButton.visible ? d.buttonWidth : 0
101 scopeStyle: root.scopeStyle
102 foregroundColor: d.foregroundColor
103 listView.width: d.navigationWidth
105 showDivider: root.width > d.navigationWidth
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
114 anchors.bottom: parent.bottom
115 visible: d.bothVisible && (navigationButton.listView.height > 0 || altNavigationButton.listView.height > 0)