Unity 8
 All Classes Functions
DashNavigation.qml
1 /*
2  * Copyright (C) 2014 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  */
16 
17 import QtQuick 2.2
18 import Ubuntu.Components 1.1
19 import Dash 0.1
20 import "../Components"
21 
22 Item {
23  id: root
24  objectName: "dashNavigation"
25 
26  property var scope: null
27  property var scopeStyle: null
28 
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 
37  // FIXME this is only here for highlight purposes (see Background.qml, too)
38  readonly property var background: backgroundItem
39 
40  visible: navigationButton.currentNavigation || altNavigationButton.currentNavigation
41 
42  height: visible ? units.gu(5) : 0
43 
44  QtObject {
45  id: d
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)
52  }
53 
54  Rectangle {
55  id: blackRect
56  color: "black"
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 }
60  visible: opacity > 0
61  }
62 
63  Background {
64  id: backgroundItem
65  anchors.fill: parent
66  style: scopeStyle ? scopeStyle.navigationBackground : "color:///#f5f5f5"
67  }
68 
69  Image {
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 }
73  }
74 
75  DashNavigationButton {
76  id: altNavigationButton
77  objectName: "altNavigationButton"
78  height: root.height
79  width: d.buttonWidth
80  scope: root.scope
81  scopeStyle: root.scopeStyle
82  foregroundColor: d.foregroundColor
83  listView.width: d.navigationWidth
84  isAltNavigation: true
85  showDivider: navigationButton.visible || root.width > d.navigationWidth
86  // needed so that InverseMouseArea is above navigationButton
87  z: listView.height > 0 ? 1 : 0
88  }
89 
90  DashNavigationButton {
91  id: navigationButton
92  objectName: "navigationButton"
93  height: root.height
94  width: altNavigationButton.visible ? d.buttonWidth : d.navigationWidth
95  x: altNavigationButton.visible ? d.buttonWidth : 0
96  scope: root.scope
97  scopeStyle: root.scopeStyle
98  foregroundColor: d.foregroundColor
99  listView.width: d.navigationWidth
100  listView.x: -x
101  showDivider: root.width > d.navigationWidth
102  }
103 
104  Image {
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
108  width: d.buttonWidth
109  rotation: 180
110  anchors.bottom: parent.bottom
111  visible: d.bothVisible && (navigationButton.listView.height > 0 || altNavigationButton.listView.height > 0)
112  }
113 }