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: height != 0
41  height: navigationButton.currentNavigation || altNavigationButton.currentNavigation ? units.gu(5) : 0
42 
43  QtObject {
44  id: d
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)
51  }
52 
53  Rectangle {
54  id: blackRect
55  color: "black"
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 }
59  visible: opacity > 0
60  }
61 
62  Background {
63  id: backgroundItem
64  anchors.fill: parent
65  style: scopeStyle ? scopeStyle.navigationBackground : "color:///#f5f5f5"
66  }
67 
68  Image {
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 }
72  }
73 
74  DashNavigationButton {
75  id: altNavigationButton
76  objectName: "altNavigationButton"
77  height: root.height
78  width: d.buttonWidth
79  scope: root.scope
80  scopeStyle: root.scopeStyle
81  foregroundColor: d.foregroundColor
82  listView.width: d.navigationWidth
83  isAltNavigation: true
84  showDivider: navigationButton.visible || root.width > d.navigationWidth
85  // needed so that InverseMouseArea is above navigationButton
86  z: listView.height > 0 ? 1 : 0
87  }
88 
89  DashNavigationButton {
90  id: navigationButton
91  objectName: "navigationButton"
92  height: root.height
93  width: altNavigationButton.visible ? d.buttonWidth : d.navigationWidth
94  x: altNavigationButton.visible ? d.buttonWidth : 0
95  scope: root.scope
96  scopeStyle: root.scopeStyle
97  foregroundColor: d.foregroundColor
98  listView.width: d.navigationWidth
99  listView.x: -x
100  showDivider: root.width > d.navigationWidth
101  }
102 
103  Image {
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
107  width: d.buttonWidth
108  rotation: 180
109  anchors.bottom: parent.bottom
110  visible: d.bothVisible && (navigationButton.listView.height > 0 || altNavigationButton.listView.height > 0)
111  }
112 }