2 * Copyright (C) 2014 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.1
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;
37 // FIXME this is only here for highlight purposes (see Background.qml, too)
38 readonly property var background: backgroundItem
41 height: navigationButton.currentNavigation || altNavigationButton.currentNavigation ? units.gu(5) : 0
45 readonly property color foregroundColor: root.scopeStyle
46 ? root.scopeStyle.getTextColor(backgroundItem.luminance)
47 : Theme.palette.normal.baseText
48 readonly property bool bothVisible: altNavigationButton.visible && navigationButton.visible
49 readonly property real navigationWidth: root.width >= units.gu(60) ? units.gu(40) : root.width
50 readonly property real buttonWidth: navigationWidth / (bothVisible ? 2 : 1)
56 opacity: openList && openList.currentItem && openList.currentItem.visible ? 0.5 : 0
57 Behavior on opacity { UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration } }
58 anchors { left: parent.left; right: parent.right }
65 style: scopeStyle ? scopeStyle.navigationBackground : "color:///#f5f5f5"
69 fillMode: Image.Stretch
70 source: scopeStyle.backgroundLuminance > 0.2 ? "graphics/navigation_shadow.png" : "graphics/navigation_shadow_light.png"
71 anchors { top: parent.bottom; left: parent.left; right: parent.right }
74 DashNavigationButton {
75 id: altNavigationButton
76 objectName: "altNavigationButton"
80 scopeStyle: root.scopeStyle
81 foregroundColor: d.foregroundColor
82 listView.width: d.navigationWidth
84 showDivider: navigationButton.visible || root.width > d.navigationWidth
85 // needed so that InverseMouseArea is above navigationButton
86 z: listView.height > 0 ? 1 : 0
89 DashNavigationButton {
91 objectName: "navigationButton"
93 width: altNavigationButton.visible ? d.buttonWidth : d.navigationWidth
94 x: altNavigationButton.visible ? d.buttonWidth : 0
96 scopeStyle: root.scopeStyle
97 foregroundColor: d.foregroundColor
98 listView.width: d.navigationWidth
100 showDivider: root.width > d.navigationWidth
104 fillMode: Image.Stretch
105 source: backgroundItem.luminance > 0.7 ? "graphics/navigation_shadow.png" : "graphics/navigation_shadow_light.png"
106 x: navigationButton.listView.height > 0 ? altNavigationButton.x : navigationButton.x
109 anchors.bottom: parent.bottom
110 visible: d.bothVisible && (navigationButton.listView.height > 0 || altNavigationButton.listView.height > 0)