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
40 visible: navigationButton.currentNavigation || altNavigationButton.currentNavigation
42 height: visible ? units.gu(5) : 0
46 readonly property color foregroundColor: root.scopeStyle
47 ? root.scopeStyle.getTextColor(backgroundItem.luminance)
48 : Theme.palette.normal.baseText
49 readonly property bool bothVisible: altNavigationButton.visible && navigationButton.visible
50 readonly property real navigationWidth: root.width >= units.gu(60) ? units.gu(40) : root.width
51 readonly property real buttonWidth: navigationWidth / (bothVisible ? 2 : 1)
57 opacity: openList && openList.currentItem && openList.currentItem.visible ? 0.5 : 0
58 Behavior on opacity { UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration } }
59 anchors { left: parent.left; right: parent.right }
66 style: scopeStyle ? scopeStyle.navigationBackground : "color:///#f5f5f5"
70 fillMode: Image.Stretch
71 source: scopeStyle.backgroundLuminance > 0.2 ? "graphics/navigation_shadow.png" : "graphics/navigation_shadow_light.png"
72 anchors { top: parent.bottom; left: parent.left; right: parent.right }
75 DashNavigationButton {
76 id: altNavigationButton
77 objectName: "altNavigationButton"
81 scopeStyle: root.scopeStyle
82 foregroundColor: d.foregroundColor
83 listView.width: d.navigationWidth
85 showDivider: navigationButton.visible || root.width > d.navigationWidth
86 // needed so that InverseMouseArea is above navigationButton
87 z: listView.height > 0 ? 1 : 0
90 DashNavigationButton {
92 objectName: "navigationButton"
94 width: altNavigationButton.visible ? d.buttonWidth : d.navigationWidth
95 x: altNavigationButton.visible ? d.buttonWidth : 0
97 scopeStyle: root.scopeStyle
98 foregroundColor: d.foregroundColor
99 listView.width: d.navigationWidth
101 showDivider: root.width > d.navigationWidth
105 fillMode: Image.Stretch
106 source: backgroundItem.luminance > 0.7 ? "graphics/navigation_shadow.png" : "graphics/navigation_shadow_light.png"
107 x: navigationButton.listView.height > 0 ? altNavigationButton.x : navigationButton.x
110 anchors.bottom: parent.bottom
111 visible: d.bothVisible && (navigationButton.listView.height > 0 || altNavigationButton.listView.height > 0)