on 41fd789 help sign in
unity8/qml/Panel/Panel.qml
252 lines 7.8 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.1
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
31 property bool locked: false
33 opacity: fullscreenMode && indicators.fullyClosed ? 0.0 : 1.0
35 Binding {
36 target: PanelState
37 property: "panelHeight"
38 value: root.panelHeight
39 }
41 Rectangle {
42 id: darkenedArea
43 property real darkenedOpacity: 0.6
44 anchors {
45 top: parent.top
46 topMargin: panelHeight
47 left: parent.left
48 right: parent.right
49 bottom: parent.bottom
50 }
51 color: "black"
52 opacity: indicators.unitProgress * darkenedOpacity
53 visible: !indicators.fullyClosed
55 MouseArea {
56 anchors.fill: parent
57 onClicked: if (indicators.fullyOpened) indicators.hide();
58 hoverEnabled: true // should also eat hover events, otherwise they will pass through
59 }
60 }
62 Item {
63 id: indicatorArea
64 objectName: "indicatorArea"
66 anchors.fill: parent
68 Behavior on anchors.topMargin {
69 NumberAnimation { duration: UbuntuAnimation.FastDuration; easing: UbuntuAnimation.StandardEasing }
70 }
72 transform: Translate {
73 y: indicators.state === "initial"
74 ? (1.0 - indicatorAreaShowProgress) * -d.indicatorHeight
75 : 0
76 }
78 BorderImage {
79 id: dropShadow
80 anchors {
81 fill: indicators
82 leftMargin: -units.gu(1)
83 bottomMargin: -units.gu(1)
84 }
85 visible: !indicators.fullyClosed
86 source: "graphics/rectangular_dropshadow.sci"
87 }
89 Rectangle {
90 id: indicatorAreaBackground
91 color: callHint.visible ? "green" : "black"
92 anchors {
93 top: parent.top
94 left: parent.left
95 right: parent.right
96 }
97 height: indicators.minimizedPanelHeight
99 Behavior on color { ColorAnimation { duration: UbuntuAnimation.FastDuration } }
100 }
102 PanelSeparatorLine {
103 id: orangeLine
104 anchors {
105 top: indicatorAreaBackground.bottom
106 left: parent.left
107 right: indicators.left
108 }
109 saturation: 1 - indicators.unitProgress
111 // Don't let input event pass trough
112 MouseArea { anchors.fill: parent }
113 }
115 Image {
116 anchors {
117 top: indicators.top
118 bottom: indicators.bottom
119 right: indicators.left
120 topMargin: indicatorArea.anchors.topMargin + indicators.minimizedPanelHeight
121 }
122 width: units.dp(2)
123 source: "graphics/VerticalDivider.png"
124 }
126 MouseArea {
127 anchors {
128 top: parent.top
129 left: parent.left
130 right: indicators.left
131 }
132 height: indicators.minimizedPanelHeight
133 onClicked: { if (callHint.visible) { callHint.showLiveCall(); } }
134 }
136 IndicatorsMenu {
137 id: __indicators
138 objectName: "indicators"
140 anchors {
141 top: parent.top
142 right: parent.right
143 }
145 shown: false
146 width: root.width - (windowControlButtons.visible ? windowControlButtons.width + titleLabel.width : 0)
147 minimizedPanelHeight: units.gu(3)
148 expandedPanelHeight: units.gu(7)
149 openedHeight: root.height - indicatorOrangeLine.height
151 overFlowWidth: {
152 if (callHint.visible) {
153 return Math.max(root.width - (callHint.width + units.gu(2)), 0)
154 }
155 return root.width
156 }
157 enableHint: !callHint.active && !fullscreenMode
158 showOnClick: !callHint.visible
159 panelColor: indicatorAreaBackground.color
161 onShowTapped: {
162 if (callHint.active) {
163 callHint.showLiveCall();
164 }
165 }
167 hideDragHandle {
168 anchors.bottomMargin: -indicatorOrangeLine.height
169 }
170 }
172 WindowControlButtons {
173 id: windowControlButtons
174 objectName: "panelWindowControlButtons"
175 anchors {
176 left: parent.left
177 top: parent.top
178 margins: units.gu(0.7)
179 }
180 height: indicators.minimizedPanelHeight - anchors.margins * 2
181 visible: PanelState.buttonsVisible && !root.locked
182 onClose: PanelState.close()
183 onMinimize: PanelState.minimize()
184 onMaximize: PanelState.maximize()
185 }
187 Label {
188 id: titleLabel
189 objectName: "windowDecorationTitle"
190 anchors {
191 left: windowControlButtons.right
192 top: parent.top
193 margins: units.gu(0.7)
194 }
195 color: "#DFDBD2"
196 height: windowControlButtons.height
197 visible: windowControlButtons.visible
198 verticalAlignment: Text.AlignVCenter
199 fontSize: "small"
200 font.bold: true
201 text: PanelState.title
202 }
204 PanelSeparatorLine {
205 id: indicatorOrangeLine
206 anchors {
207 top: indicators.bottom
208 left: indicators.left
209 right: indicators.right
210 }
211 }
213 ActiveCallHint {
214 id: __callHint
215 anchors {
216 top: parent.top
217 left: windowControlButtons.visible ? windowControlButtons.right : parent.left
218 }
219 height: indicators.minimizedPanelHeight
220 visible: active && indicators.state == "initial"
221 }
222 }
224 QtObject {
225 id: d
226 objectName: "panelPriv"
227 readonly property real indicatorHeight: indicators.minimizedPanelHeight + indicatorOrangeLine.height
228 }
230 states: [
231 State {
232 name: "onscreen" //fully opaque and visible at top edge of screen
233 when: !fullscreenMode
234 PropertyChanges {
235 target: indicatorArea;
236 anchors.topMargin: 0
237 }
238 },
239 State {
240 name: "offscreen" //pushed off screen
241 when: fullscreenMode
242 PropertyChanges {
243 target: indicatorArea;
244 anchors.topMargin: indicators.state === "initial" ? -d.indicatorHeight : 0
245 }
246 PropertyChanges {
247 target: indicators.showDragHandle;
248 anchors.bottomMargin: -units.gu(1)
249 }
250 }
251 ]