on 555cc15 help sign in
unity8/qml/Panel/Panel.qml
227 lines 7.0 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
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 hoverEnabled: true // should also eat hover events, otherwise they will pass through
52 }
53 }
55 Item {
56 id: indicatorArea
57 objectName: "indicatorArea"
59 anchors.fill: parent
61 Behavior on anchors.topMargin {
62 NumberAnimation { duration: UbuntuAnimation.FastDuration; easing: UbuntuAnimation.StandardEasing }
63 }
65 transform: Translate {
66 y: indicators.state === "initial"
67 ? (1.0 - indicatorAreaShowProgress) * -d.indicatorHeight
68 : 0
69 }
71 BorderImage {
72 id: dropShadow
73 anchors {
74 fill: indicators
75 leftMargin: -units.gu(1)
76 bottomMargin: -units.gu(1)
77 }
78 visible: !indicators.fullyClosed
79 source: "graphics/rectangular_dropshadow.sci"
80 }
82 Rectangle {
83 id: indicatorAreaBackground
84 color: callHint.visible ? "green" : "black"
85 anchors {
86 top: parent.top
87 left: parent.left
88 right: parent.right
89 }
90 height: indicators.minimizedPanelHeight
92 Behavior on color { ColorAnimation { duration: UbuntuAnimation.FastDuration } }
93 }
95 PanelSeparatorLine {
96 id: orangeLine
97 anchors {
98 top: indicatorAreaBackground.bottom
99 left: parent.left
100 right: indicators.left
101 }
102 saturation: 1 - indicators.unitProgress
104 // Don't let input event pass trough
105 MouseArea { anchors.fill: parent }
106 }
108 Image {
109 anchors {
110 top: indicators.top
111 bottom: indicators.bottom
112 right: indicators.left
113 topMargin: indicatorArea.anchors.topMargin + indicators.minimizedPanelHeight
114 }
115 width: units.dp(2)
116 source: "graphics/VerticalDivider.png"
117 }
119 MouseArea {
120 anchors {
121 top: parent.top
122 left: parent.left
123 right: indicators.left
124 }
125 height: indicators.minimizedPanelHeight
126 onClicked: { if (callHint.visible) { callHint.showLiveCall(); } }
127 }
129 IndicatorsMenu {
130 id: __indicators
131 objectName: "indicators"
133 anchors {
134 top: parent.top
135 right: parent.right
136 }
138 shown: false
139 width: root.width - (PanelState.buttonsVisible ? windowControlButtons.width : 0)
140 minimizedPanelHeight: units.gu(3)
141 expandedPanelHeight: units.gu(7)
142 openedHeight: root.height - indicatorOrangeLine.height
144 overFlowWidth: {
145 if (callHint.visible) {
146 return Math.max(root.width - (callHint.width + units.gu(2)), 0)
147 }
148 return root.width
149 }
150 enableHint: !callHint.active && !fullscreenMode
151 showOnClick: !callHint.visible
152 panelColor: indicatorAreaBackground.color
154 onShowTapped: {
155 if (callHint.active) {
156 callHint.showLiveCall();
157 }
158 }
160 hideDragHandle {
161 anchors.bottomMargin: -indicatorOrangeLine.height
162 }
163 }
165 WindowControlButtons {
166 id: windowControlButtons
167 anchors {
168 left: parent.left
169 top: parent.top
170 margins: units.gu(0.7)
171 }
172 height: indicators.minimizedPanelHeight - anchors.margins * 2
173 visible: PanelState.buttonsVisible
174 onClose: PanelState.close()
175 onMinimize: PanelState.minimize()
176 onMaximize: PanelState.maximize()
177 }
179 PanelSeparatorLine {
180 id: indicatorOrangeLine
181 anchors {
182 top: indicators.bottom
183 left: indicators.left
184 right: indicators.right
185 }
186 }
188 ActiveCallHint {
189 id: __callHint
190 anchors {
191 top: parent.top
192 left: PanelState.buttonsVisible ? windowControlButtons.right : parent.left
193 }
194 height: indicators.minimizedPanelHeight
195 visible: active && indicators.state == "initial"
196 }
197 }
199 QtObject {
200 id: d
201 objectName: "panelPriv"
202 readonly property real indicatorHeight: indicators.minimizedPanelHeight + indicatorOrangeLine.height
203 }
205 states: [
206 State {
207 name: "onscreen" //fully opaque and visible at top edge of screen
208 when: !fullscreenMode
209 PropertyChanges {
210 target: indicatorArea;
211 anchors.topMargin: 0
212 }
213 },
214 State {
215 name: "offscreen" //pushed off screen
216 when: fullscreenMode
217 PropertyChanges {
218 target: indicatorArea;
219 anchors.topMargin: indicators.state === "initial" ? -d.indicatorHeight : 0
220 }
221 PropertyChanges {
222 target: indicators.showDragHandle;
223 anchors.bottomMargin: -units.gu(1)
224 }
225 }
226 ]