on 239fdcc help sign in
unity8/qml/Panel/Panel.qml
249 lines 8.3 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.4
18import Ubuntu.Components 1.3
19import Unity.Application 0.1
20import "../Components"
21import "../Components/PanelState"
22import "../Components/TouchControlsState"
23import ".."
25Item {
26 id: root
27 readonly property real panelHeight: indicatorArea.y + d.indicatorHeight
28 property alias indicators: __indicators
29 property alias callHint: __callHint
30 property bool fullscreenMode: false
31 property real indicatorAreaShowProgress: 1.0
32 property bool locked: false
34 Rectangle {
35 id: darkenedArea
36 property real darkenedOpacity: 0.6
37 anchors {
38 fill: parent
39 topMargin: panelHeight
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 hoverEnabled: true // should also eat hover events, otherwise they will pass through
49 }
50 }
52 Binding {
53 target: PanelState
54 property: "panelHeight"
55 value: indicators.minimizedPanelHeight
56 }
58 Item {
59 id: indicatorArea
60 objectName: "indicatorArea"
62 anchors.fill: parent
64 transform: Translate {
65 y: indicators.state === "initial"
66 ? (1.0 - indicatorAreaShowProgress) * -d.indicatorHeight
67 : 0
68 }
70 BorderImage {
71 id: indicatorsDropShadow
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 BorderImage {
82 id: panelDropShadow
83 anchors {
84 fill: indicatorAreaBackground
85 bottomMargin: -units.gu(1)
86 }
87 visible: PanelState.dropShadow && !callHint.visible
88 source: "graphics/rectangular_dropshadow.sci"
89 }
91 Rectangle {
92 id: indicatorAreaBackground
93 color: callHint.visible ? UbuntuColors.green : theme.palette.normal.background
94 anchors {
95 top: parent.top
96 left: parent.left
97 right: parent.right
98 }
99 height: indicators.minimizedPanelHeight
101 Behavior on color { ColorAnimation { duration: UbuntuAnimation.FastDuration } }
102 }
104 MouseArea {
105 anchors {
106 top: parent.top
107 left: parent.left
108 right: indicators.left
109 }
110 height: indicators.minimizedPanelHeight
111 hoverEnabled: true
112 onClicked: callHint.visible ? callHint.showLiveCall() : PanelState.focusMaximizedApp()
113 onDoubleClicked: PanelState.restoreClicked()
115 // WindowControlButtons inside the mouse area, otherwise QML doesn't grok nested hover events :/
116 // cf. https://bugreports.qt.io/browse/QTBUG-32909
117 WindowControlButtons {
118 id: windowControlButtons
119 objectName: "panelWindowControlButtons"
120 anchors {
121 left: parent.left
122 top: parent.top
123 leftMargin: units.gu(1)
124 topMargin: units.gu(0.5)
125 bottomMargin: units.gu(0.5)
126 }
127 height: indicators.minimizedPanelHeight - anchors.topMargin - anchors.bottomMargin
129 visible: ((PanelState.buttonsVisible && parent.containsMouse) || TouchControlsState.buttonsShownInPanel)
130 && !root.locked && !callHint.visible
131 active: PanelState.buttonsVisible || TouchControlsState.buttonsShownInPanel
132 windowIsMaximized: true
133 onCloseClicked: PanelState.closeClicked()
134 onMinimizeClicked: PanelState.minimizeClicked()
135 onMaximizeClicked: PanelState.restoreClicked()
136 closeButtonShown: PanelState.closeButtonShown
137 }
138 }
140 IndicatorsMenu {
141 id: __indicators
142 objectName: "indicators"
144 anchors {
145 top: parent.top
146 right: parent.right
147 }
149 shown: false
150 width: root.width - (windowControlButtons.visible ? windowControlButtons.width + titleLabel.width : 0)
151 minimizedPanelHeight: units.gu(3)
152 expandedPanelHeight: units.gu(7)
153 openedHeight: root.height
155 overFlowWidth: {
156 if (callHint.visible) {
157 return Math.max(root.width - (callHint.width + units.gu(2)), 0)
158 }
159 return root.width
160 }
161 enableHint: !callHint.active && !fullscreenMode
162 showOnClick: !callHint.visible
163 panelColor: indicatorAreaBackground.color
165 onShowTapped: {
166 if (callHint.active) {
167 callHint.showLiveCall();
168 }
169 }
170 }
172 Label {
173 id: titleLabel
174 objectName: "windowDecorationTitle"
175 anchors {
176 left: parent.left
177 right: __indicators.left
178 top: parent.top
179 leftMargin: units.gu(1)
180 rightMargin: units.gu(1)
181 topMargin: units.gu(0.5)
182 bottomMargin: units.gu(0.5)
183 }
184 color: "white"
185 height: indicators.minimizedPanelHeight - anchors.topMargin - anchors.bottomMargin
186 visible: !windowControlButtons.visible && !root.locked && !callHint.visible
187 verticalAlignment: Text.AlignVCenter
188 fontSize: "medium"
189 font.weight: PanelState.buttonsVisible ? Font.Light : Font.Medium
190 text: PanelState.title
191 elide: Text.ElideRight
192 maximumLineCount: 1
193 }
195 // TODO here would the Locally integrated menus come
197 ActiveCallHint {
198 id: __callHint
199 anchors {
200 top: parent.top
201 left: parent.left
202 }
203 height: indicators.minimizedPanelHeight
204 visible: active && indicators.state == "initial"
205 }
206 }
208 QtObject {
209 id: d
210 objectName: "panelPriv"
211 readonly property real indicatorHeight: indicators.minimizedPanelHeight
212 }
214 states: [
215 State {
216 name: "onscreen" //fully opaque and visible at top edge of screen
217 when: !fullscreenMode
218 PropertyChanges {
219 target: indicatorArea;
220 anchors.topMargin: 0
221 opacity: 1;
222 }
223 },
224 State {
225 name: "offscreen" //pushed off screen
226 when: fullscreenMode
227 PropertyChanges {
228 target: indicatorArea;
229 anchors.topMargin: indicators.state === "initial" ? -d.indicatorHeight : 0
230 opacity: indicators.fullyClosed ? 0.0 : 1.0
231 }
232 PropertyChanges {
233 target: indicators.showDragHandle;
234 anchors.bottomMargin: -units.gu(1)
235 }
236 }
237 ]
239 transitions: [
240 Transition {
241 to: "onscreen"
242 UbuntuNumberAnimation { target: indicatorArea; properties: "anchors.topMargin,opacity" }
243 },
244 Transition {
245 to: "offscreen"
246 UbuntuNumberAnimation { target: indicatorArea; properties: "anchors.topMargin,opacity" }
247 }
248 ]