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