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