on e63da72 help sign in
unity8/qml/Panel/Panel.qml
226 lines 6.9 kB history raw
1/*
2 * Copyright (C) 2013-2015 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.2
18import Ubuntu.Components 1.3
19import Unity.Application 0.1
20import "../Components"
21import "../Components/PanelState"
22import ".."
24Item {
25 id: root
26 readonly property real panelHeight: indicatorArea.y + d.indicatorHeight
27 property alias indicators: __indicators
28 property alias callHint: __callHint
29 property bool fullscreenMode: false
30 property real indicatorAreaShowProgress: 1.0
32 opacity: fullscreenMode && indicators.fullyClosed ? 0.0 : 1.0
34 Rectangle {
35 id: darkenedArea
36 property real darkenedOpacity: 0.6
37 anchors {
38 top: parent.top
39 topMargin: panelHeight
40 left: parent.left
41 right: parent.right
42 bottom: parent.bottom
43 }
44 color: "black"
45 opacity: indicators.unitProgress * darkenedOpacity
46 visible: !indicators.fullyClosed
48 MouseArea {
49 anchors.fill: parent
50 onClicked: if (indicators.fullyOpened) indicators.hide();
51 }
52 }
54 Item {
55 id: indicatorArea
56 objectName: "indicatorArea"
58 anchors.fill: parent
60 Behavior on anchors.topMargin {
61 NumberAnimation { duration: UbuntuAnimation.FastDuration; easing: UbuntuAnimation.StandardEasing }
62 }
64 transform: Translate {
65 y: indicators.state === "initial"
66 ? (1.0 - indicatorAreaShowProgress) * -d.indicatorHeight
67 : 0
68 }
70 BorderImage {
71 id: dropShadow
72 anchors {
73 fill: indicators
74 leftMargin: -units.gu(1)
75 bottomMargin: -units.gu(1)
76 }
77 visible: !indicators.fullyClosed
78 source: "graphics/rectangular_dropshadow.sci"
79 }
81 Rectangle {
82 id: indicatorAreaBackground
83 color: callHint.visible ? "green" : "black"
84 anchors {
85 top: parent.top
86 left: parent.left
87 right: parent.right
88 }
89 height: indicators.minimizedPanelHeight
91 Behavior on color { ColorAnimation { duration: UbuntuAnimation.FastDuration } }
92 }
94 PanelSeparatorLine {
95 id: orangeLine
96 anchors {
97 top: indicatorAreaBackground.bottom
98 left: parent.left
99 right: indicators.left
100 }
101 saturation: 1 - indicators.unitProgress
103 // Don't let input event pass trough
104 MouseArea { anchors.fill: parent }
105 }
107 Image {
108 anchors {
109 top: indicators.top
110 bottom: indicators.bottom
111 right: indicators.left
112 topMargin: indicatorArea.anchors.topMargin + indicators.minimizedPanelHeight
113 }
114 width: units.dp(2)
115 source: "graphics/VerticalDivider.png"
116 }
118 MouseArea {
119 anchors {
120 top: parent.top
121 left: parent.left
122 right: indicators.left
123 }
124 height: indicators.minimizedPanelHeight
125 onClicked: { if (callHint.visible) { callHint.showLiveCall(); } }
126 }
128 IndicatorsMenu {
129 id: __indicators
130 objectName: "indicators"
132 anchors {
133 top: parent.top
134 right: parent.right
135 }
137 shown: false
138 width: root.width - (PanelState.buttonsVisible ? windowControlButtons.width : 0)
139 minimizedPanelHeight: units.gu(3)
140 expandedPanelHeight: units.gu(7)
141 openedHeight: root.height - indicatorOrangeLine.height
143 overFlowWidth: {
144 if (callHint.visible) {
145 return Math.max(root.width - (callHint.width + units.gu(2)), 0)
146 }
147 return root.width
148 }
149 enableHint: !callHint.active && !fullscreenMode
150 showOnClick: !callHint.visible
151 panelColor: indicatorAreaBackground.color
153 onShowTapped: {
154 if (callHint.active) {
155 callHint.showLiveCall();
156 }
157 }
159 hideDragHandle {
160 anchors.bottomMargin: -indicatorOrangeLine.height
161 }
162 }
164 WindowControlButtons {
165 id: windowControlButtons
166 anchors {
167 left: parent.left
168 top: parent.top
169 margins: units.gu(0.7)
170 }
171 height: indicators.minimizedPanelHeight - anchors.margins * 2
172 visible: PanelState.buttonsVisible
173 onClose: PanelState.close()
174 onMinimize: PanelState.minimize()
175 onMaximize: PanelState.maximize()
176 }
178 PanelSeparatorLine {
179 id: indicatorOrangeLine
180 anchors {
181 top: indicators.bottom
182 left: indicators.left
183 right: indicators.right
184 }
185 }
187 ActiveCallHint {
188 id: __callHint
189 anchors {
190 top: parent.top
191 left: PanelState.buttonsVisible ? windowControlButtons.right : parent.left
192 }
193 height: indicators.minimizedPanelHeight
194 visible: active && indicators.state == "initial"
195 }
196 }
198 QtObject {
199 id: d
200 objectName: "panelPriv"
201 readonly property real indicatorHeight: indicators.minimizedPanelHeight + indicatorOrangeLine.height
202 }
204 states: [
205 State {
206 name: "onscreen" //fully opaque and visible at top edge of screen
207 when: !fullscreenMode
208 PropertyChanges {
209 target: indicatorArea;
210 anchors.topMargin: 0
211 }
212 },
213 State {
214 name: "offscreen" //pushed off screen
215 when: fullscreenMode
216 PropertyChanges {
217 target: indicatorArea;
218 anchors.topMargin: indicators.state === "initial" ? -d.indicatorHeight : 0
219 }
220 PropertyChanges {
221 target: indicators.showDragHandle;
222 anchors.bottomMargin: -units.gu(1)
223 }
224 }
225 ]