on c43037e help sign in
unity8/Panel/Panel.qml
175 lines 5.0 kB history raw
1/*
2 * Copyright (C) 2013 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 */
17import QtQuick 2.0
18import Ubuntu.Components 0.1
19import "../Components"
21Item {
22 id: root
23 readonly property real panelHeight: units.gu(3) + units.dp(2)
24 property real indicatorsMenuWidth: (shell.width > units.gu(60)) ? units.gu(40) : shell.width
25 property alias indicators: indicatorsMenu
26 property bool fullscreenMode: false
27 property bool searchVisible: true
29 readonly property real separatorLineHeight: leftSeparatorLine.height
30 readonly property real __panelMinusSeparatorLineHeight: panelHeight - separatorLineHeight
32 signal searchClicked
34 function hideIndicatorMenu(delay) {
35 if (delay !== undefined) {
36 hideTimer.interval = delay;
37 hideTimer.start();
38 } else {
39 indicatorsMenu.hide();
40 }
41 }
43 Timer {
44 id: hideTimer
45 running: false
46 onTriggered: {
47 indicatorsMenu.hide();
48 }
49 }
51 Connections {
52 target: indicatorsMenu
53 onShown: hideTimer.stop()
54 }
56 PanelBackground {
57 id: panelBackground
58 anchors {
59 left: parent.left
60 right: parent.right
61 }
62 height: __panelMinusSeparatorLineHeight
63 y: 0
65 Behavior on y { StandardAnimation {} }
66 }
68 PanelSeparatorLine {
69 id: leftSeparatorLine
70 anchors {
71 top: panelBackground.bottom
72 left: parent.left
73 right: indicatorsMenu.left
74 }
75 saturation: 1 - indicatorsMenu.unitProgress
76 }
78 Rectangle {
79 id: darkenedArea
80 property real darkenedOpacity: 0.6
81 anchors {
82 left: parent.left
83 right: parent.right
84 top: panelBackground.bottom
85 bottom: parent.bottom
86 }
87 color: "black"
88 opacity: indicatorsMenu.unitProgress * darkenedOpacity
89 MouseArea {
90 anchors.fill: parent
91 enabled: indicatorsMenu.shown
92 onClicked: if (indicatorsMenu.fullyOpened) indicatorsMenu.hide();
93 }
94 }
96 Indicators {
97 id: indicatorsMenu
98 objectName: "indicators"
100 anchors.right: parent.right
101 y: panelBackground.y
102 width: root.indicatorsMenuWidth
103 shown: false
104 hintValue: __panelMinusSeparatorLineHeight * 3
105 panelHeight: __panelMinusSeparatorLineHeight
106 openedHeight: parent.height + (pinnedMode ? 0 : root.panelHeight)
107 pinnedMode: !fullscreenMode
108 overFlowWidth: search.state=="hidden" ? parent.width : parent.width - search.width
110 property real unitProgress: (height - panelHeight) / (openedHeight - panelHeight)
111 }
113 PanelSeparatorLine {
114 id: indicatorsSeparatorLine
115 visible: true
116 anchors {
117 left: indicatorsMenu.left
118 right: indicatorsMenu.right
119 }
120 y: indicatorsMenu.visualBottom
121 }
123 BorderImage {
124 id: dropShadow
125 anchors {
126 top: indicators.top
127 bottom: indicatorsSeparatorLine.bottom
128 left: indicators.left
129 right: indicators.right
130 margins: -units.gu(1)
131 }
132 visible: indicatorsMenu.height > indicatorsMenu.panelHeight
133 source: "graphics/rectangular_dropshadow.sci"
134 }
136 SearchIndicator {
137 id: search
138 objectName: "search"
139 enabled: root.searchVisible
141 state: {
142 if (parent.width < indicatorsMenu.width + width) {
143 if (indicatorsMenu.state != "initial") {
144 return "hidden";
145 }
146 }
147 if (root.searchVisible && !indicatorsMenu.showAll) {
148 return "visible";
149 }
151 return "hidden";
152 }
154 height: __panelMinusSeparatorLineHeight
155 anchors {
156 top: panelBackground.top
157 left: panelBackground.left
158 }
160 onClicked: root.searchClicked()
161 }
163 states: [
164 State {
165 name: "in" //fully opaque and visible at top edge of screen
166 when: !fullscreenMode
167 PropertyChanges { target: panelBackground; y: 0 }
168 },
169 State {
170 name: "out" //pushed off screen
171 when: fullscreenMode
172 PropertyChanges { target: panelBackground; y: -panelHeight }
173 }
174 ]