Unity 8
 All Classes Functions Properties
Panel.qml
1 /*
2  * Copyright (C) 2013 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.0
18 import Ubuntu.Components 0.1
19 import Unity.Application 0.1
20 import "../Components"
21 import "../Components/ListItems"
22 
23 Item {
24  id: root
25  readonly property real panelHeight: indicatorArea.y + d.indicatorHeight
26  property alias indicators: __indicators
27  property alias callHint: __callHint
28  property bool fullscreenMode: false
29 
30  Rectangle {
31  id: darkenedArea
32  property real darkenedOpacity: 0.6
33  anchors {
34  top: parent.top
35  topMargin: panelHeight
36  left: parent.left
37  right: parent.right
38  bottom: parent.bottom
39  }
40  color: "black"
41  opacity: indicators.unitProgress * darkenedOpacity
42 
43  MouseArea {
44  anchors.fill: parent
45  enabled: indicators.shown
46  onClicked: if (indicators.fullyOpened) indicators.hide();
47  }
48  }
49 
50  Item {
51  id: indicatorArea
52  objectName: "indicatorArea"
53 
54  anchors.fill: parent
55 
56  Behavior on anchors.topMargin { StandardAnimation {} }
57 
58  BorderImage {
59  id: dropShadow
60  anchors {
61  fill: indicators
62  leftMargin: -units.gu(1)
63  bottomMargin: -units.gu(1)
64  }
65  visible: indicators.height > indicators.panelHeight
66  source: "graphics/rectangular_dropshadow.sci"
67  }
68 
69  VerticalThinDivider {
70  id: indicatorDividor
71  anchors {
72  top: indicators.top
73  bottom: indicators.bottom
74  right: indicators.left
75 
76  topMargin: indicatorArea.anchors.topMargin + indicators.panelHeight
77  }
78 
79  width: units.dp(2)
80  source: "graphics/VerticalDivider.png"
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.panelHeight
92 
93  Behavior on color { ColorAnimation { duration: UbuntuAnimation.FastDuration } }
94  }
95 
96  PanelSeparatorLine {
97  id: nonIndicatorAreaSeparatorLine
98  anchors {
99  top: indicatorAreaBackground.bottom
100  left: parent.left
101  right: indicators.left
102  }
103  saturation: 1 - indicators.unitProgress
104  }
105 
106  MouseArea {
107  anchors {
108  top: parent.top
109  left: parent.left
110  right: indicators.left
111  }
112  height: indicators.panelHeight
113  enabled: callHint.visible
114  onClicked: callHint.showLiveCall()
115  }
116 
117  Indicators {
118  id: __indicators
119  objectName: "indicators"
120 
121  anchors {
122  top: parent.top
123  right: parent.right
124  }
125 
126  width: root.width
127  shown: false
128  panelHeight: units.gu(3)
129  openedHeight: root.height
130  overFlowWidth: {
131  if (callHint.visible) {
132  return Math.max(root.width - (callHint.width + units.gu(2)), 0)
133  }
134  return root.width
135  }
136 
137  enableHint: !callHint.active && !fullscreenMode
138  showHintBottomMargin: fullscreenMode ? -panelHeight : 0
139 
140  onShowTapped: {
141  if (callHint.active) {
142  callHint.showLiveCall();
143  }
144  }
145  }
146 
147  ActiveCallHint {
148  id: __callHint
149  anchors {
150  top: parent.top
151  left: parent.left
152  }
153  height: indicators.panelHeight
154  visible: active && indicators.state == "initial"
155  }
156 
157  PanelSeparatorLine {
158  id: indicatorsSeparatorLine
159  visible: true
160  anchors {
161  top: indicators.bottom
162  left: indicatorDividor.left
163  right: indicators.right
164  }
165  }
166  }
167 
168  QtObject {
169  id: d
170  readonly property real indicatorHeight: indicators.panelHeight + indicatorsSeparatorLine.height
171  }
172 
173  states: [
174  State {
175  name: "onscreen" //fully opaque and visible at top edge of screen
176  when: !fullscreenMode
177  PropertyChanges {
178  target: indicatorArea;
179  anchors.topMargin: 0
180  }
181  },
182  State {
183  name: "offscreen" //pushed off screen
184  when: fullscreenMode
185  PropertyChanges {
186  target: indicatorArea;
187  anchors.topMargin: indicators.state === "initial" ? -d.indicatorHeight : 0
188  }
189  }
190  ]
191 }