on a6d77df help sign in
unity8/qml/Panel/Panel.qml
213 lines 6.4 kB history raw
1/*
2 * Copyright (C) 2013-2014 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
44 MouseArea {
45 anchors.fill: parent
46 enabled: indicators.shown
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
93 }
95 Image {
96 anchors {
97 top: indicators.top
98 bottom: indicators.bottom
99 right: indicators.left
100 topMargin: indicatorArea.anchors.topMargin + indicators.minimizedPanelHeight
101 }
102 width: units.dp(2)
103 source: "graphics/VerticalDivider.png"
104 }
106 MouseArea {
107 anchors {
108 top: parent.top
109 left: parent.left
110 right: indicators.left
111 }
112 height: indicators.minimizedPanelHeight
113 enabled: callHint.visible
114 onClicked: callHint.showLiveCall()
115 }
117 IndicatorsMenu {
118 id: __indicators
119 objectName: "indicators"
121 anchors {
122 top: parent.top
123 right: parent.right
124 }
126 shown: false
127 width: root.width - (PanelState.buttonsVisible ? windowControlButtons.width : 0)
128 minimizedPanelHeight: units.gu(3)
129 expandedPanelHeight: units.gu(7)
130 openedHeight: root.height - indicatorOrangeLine.height
132 overFlowWidth: {
133 if (callHint.visible) {
134 return Math.max(root.width - (callHint.width + units.gu(2)), 0)
135 }
136 return root.width
137 }
138 enableHint: !callHint.active && !fullscreenMode
139 panelColor: indicatorAreaBackground.color
141 onShowTapped: {
142 if (callHint.active) {
143 callHint.showLiveCall();
144 }
145 }
147 hideDragHandle {
148 anchors.bottomMargin: -indicatorOrangeLine.height
149 }
150 }
152 WindowControlButtons {
153 id: windowControlButtons
154 anchors {
155 left: parent.left
156 top: parent.top
157 margins: units.gu(0.7)
158 }
159 height: indicators.minimizedPanelHeight - anchors.margins * 2
160 visible: PanelState.buttonsVisible
161 onClose: PanelState.close()
162 onMinimize: PanelState.minimize()
163 onMaximize: PanelState.maximize()
164 }
166 PanelSeparatorLine {
167 id: indicatorOrangeLine
168 anchors {
169 top: indicators.bottom
170 left: indicators.left
171 right: indicators.right
172 }
173 }
175 ActiveCallHint {
176 id: __callHint
177 anchors {
178 top: parent.top
179 left: PanelState.buttonsVisible ? windowControlButtons.right : parent.left
180 }
181 height: indicators.minimizedPanelHeight
182 visible: active && indicators.state == "initial"
183 }
184 }
186 QtObject {
187 id: d
188 readonly property real indicatorHeight: indicators.minimizedPanelHeight + indicatorOrangeLine.height
189 }
191 states: [
192 State {
193 name: "onscreen" //fully opaque and visible at top edge of screen
194 when: !fullscreenMode
195 PropertyChanges {
196 target: indicatorArea;
197 anchors.topMargin: 0
198 }
199 },
200 State {
201 name: "offscreen" //pushed off screen
202 when: fullscreenMode
203 PropertyChanges {
204 target: indicatorArea;
205 anchors.topMargin: indicators.state === "initial" ? -d.indicatorHeight : 0
206 }
207 PropertyChanges {
208 target: indicators.showDragHandle;
209 anchors.bottomMargin: -units.gu(1)
210 }
211 }
212 ]