on 02fa86a help sign in
unity8/qml/Panel/Panel.qml
216 lines 6.6 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
31 Rectangle {
32 id: darkenedArea
33 property real darkenedOpacity: 0.6
34 anchors {
35 top: parent.top
36 topMargin: panelHeight
37 left: parent.left
38 right: parent.right
39 bottom: parent.bottom
40 }
41 color: "black"
42 opacity: indicators.unitProgress * darkenedOpacity
43 visible: !indicators.fullyClosed
45 MouseArea {
46 anchors.fill: parent
47 onClicked: if (indicators.fullyOpened) indicators.hide();
48 }
49 }
51 Item {
52 id: indicatorArea
53 objectName: "indicatorArea"
55 anchors.fill: parent
57 Behavior on anchors.topMargin {
58 NumberAnimation { duration: UbuntuAnimation.FastDuration; easing: UbuntuAnimation.StandardEasing }
59 }
61 BorderImage {
62 id: dropShadow
63 anchors {
64 fill: indicators
65 leftMargin: -units.gu(1)
66 bottomMargin: -units.gu(1)
67 }
68 visible: !indicators.fullyClosed
69 source: "graphics/rectangular_dropshadow.sci"
70 }
72 Rectangle {
73 id: indicatorAreaBackground
74 color: callHint.visible ? "green" : "black"
75 anchors {
76 top: parent.top
77 left: parent.left
78 right: parent.right
79 }
80 height: indicators.minimizedPanelHeight
82 Behavior on color { ColorAnimation { duration: UbuntuAnimation.FastDuration } }
83 }
85 PanelSeparatorLine {
86 id: orangeLine
87 anchors {
88 top: indicatorAreaBackground.bottom
89 left: parent.left
90 right: indicators.left
91 }
92 saturation: 1 - indicators.unitProgress
94 // Don't let input event pass trough
95 MouseArea { anchors.fill: parent }
96 }
98 Image {
99 anchors {
100 top: indicators.top
101 bottom: indicators.bottom
102 right: indicators.left
103 topMargin: indicatorArea.anchors.topMargin + indicators.minimizedPanelHeight
104 }
105 width: units.dp(2)
106 source: "graphics/VerticalDivider.png"
107 }
109 MouseArea {
110 anchors {
111 top: parent.top
112 left: parent.left
113 right: indicators.left
114 }
115 height: indicators.minimizedPanelHeight
116 onClicked: { if (callHint.visible) { callHint.showLiveCall(); } }
117 }
119 IndicatorsMenu {
120 id: __indicators
121 objectName: "indicators"
123 anchors {
124 top: parent.top
125 right: parent.right
126 }
128 shown: false
129 width: root.width - (PanelState.buttonsVisible ? windowControlButtons.width : 0)
130 minimizedPanelHeight: units.gu(3)
131 expandedPanelHeight: units.gu(7)
132 openedHeight: root.height - indicatorOrangeLine.height
134 overFlowWidth: {
135 if (callHint.visible) {
136 return Math.max(root.width - (callHint.width + units.gu(2)), 0)
137 }
138 return root.width
139 }
140 enableHint: !callHint.active && !fullscreenMode
141 panelColor: indicatorAreaBackground.color
143 onShowTapped: {
144 if (callHint.active) {
145 callHint.showLiveCall();
146 }
147 }
149 hideDragHandle {
150 anchors.bottomMargin: -indicatorOrangeLine.height
151 }
152 }
154 WindowControlButtons {
155 id: windowControlButtons
156 anchors {
157 left: parent.left
158 top: parent.top
159 margins: units.gu(0.7)
160 }
161 height: indicators.minimizedPanelHeight - anchors.margins * 2
162 visible: PanelState.buttonsVisible
163 onClose: PanelState.close()
164 onMinimize: PanelState.minimize()
165 onMaximize: PanelState.maximize()
166 }
168 PanelSeparatorLine {
169 id: indicatorOrangeLine
170 anchors {
171 top: indicators.bottom
172 left: indicators.left
173 right: indicators.right
174 }
175 }
177 ActiveCallHint {
178 id: __callHint
179 anchors {
180 top: parent.top
181 left: PanelState.buttonsVisible ? windowControlButtons.right : parent.left
182 }
183 height: indicators.minimizedPanelHeight
184 visible: active && indicators.state == "initial"
185 }
186 }
188 QtObject {
189 id: d
190 objectName: "panelPriv"
191 readonly property real indicatorHeight: indicators.minimizedPanelHeight + indicatorOrangeLine.height
192 }
194 states: [
195 State {
196 name: "onscreen" //fully opaque and visible at top edge of screen
197 when: !fullscreenMode
198 PropertyChanges {
199 target: indicatorArea;
200 anchors.topMargin: 0
201 }
202 },
203 State {
204 name: "offscreen" //pushed off screen
205 when: fullscreenMode
206 PropertyChanges {
207 target: indicatorArea;
208 anchors.topMargin: indicators.state === "initial" ? -d.indicatorHeight : 0
209 }
210 PropertyChanges {
211 target: indicators.showDragHandle;
212 anchors.bottomMargin: -units.gu(1)
213 }
214 }
215 ]