on 7235b09 help sign in
unity8/qml/Panel/Panel.qml
202 lines 5.9 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/ListItems"
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 VerticalThinDivider {
96 id: indicatorDividor
97 anchors {
98 top: indicators.top
99 bottom: indicators.bottom
100 right: indicators.left
102 topMargin: indicatorArea.anchors.topMargin + indicators.minimizedPanelHeight
103 }
105 width: units.dp(2)
106 source: "graphics/VerticalDivider.png"
107 }
109 MouseArea {
110 anchors {
111 top: parent.top
112 left: parent.left
113 right: indicators.left
114 }
115 height: indicators.minimizedPanelHeight
116 enabled: callHint.visible
117 onClicked: callHint.showLiveCall()
118 }
120 IndicatorsMenu {
121 id: __indicators
122 objectName: "indicators"
124 anchors {
125 top: parent.top
126 right: parent.right
127 }
129 shown: false
130 width: root.width
131 minimizedPanelHeight: units.gu(3)
132 expandedPanelHeight: units.gu(7)
133 openedHeight: root.height - indicatorOrangeLine.height
135 overFlowWidth: {
136 if (callHint.visible) {
137 return Math.max(root.width - (callHint.width + units.gu(2)), 0)
138 }
139 return root.width
140 }
141 enableHint: !callHint.active && !fullscreenMode
142 panelColor: indicatorAreaBackground.color
144 onShowTapped: {
145 if (callHint.active) {
146 callHint.showLiveCall();
147 }
148 }
150 hideDragHandle {
151 anchors.bottomMargin: -indicatorOrangeLine.height
152 }
153 }
155 PanelSeparatorLine {
156 id: indicatorOrangeLine
157 anchors {
158 top: indicators.bottom
159 left: indicators.left
160 right: indicators.right
161 }
162 }
164 ActiveCallHint {
165 id: __callHint
166 anchors {
167 top: parent.top
168 left: parent.left
169 }
170 height: indicators.minimizedPanelHeight
171 visible: active && indicators.state == "initial"
172 }
173 }
175 QtObject {
176 id: d
177 readonly property real indicatorHeight: indicators.minimizedPanelHeight + indicatorOrangeLine.height
178 }
180 states: [
181 State {
182 name: "onscreen" //fully opaque and visible at top edge of screen
183 when: !fullscreenMode
184 PropertyChanges {
185 target: indicatorArea;
186 anchors.topMargin: 0
187 }
188 },
189 State {
190 name: "offscreen" //pushed off screen
191 when: fullscreenMode
192 PropertyChanges {
193 target: indicatorArea;
194 anchors.topMargin: indicators.state === "initial" ? -d.indicatorHeight : 0
195 }
196 PropertyChanges {
197 target: indicators.showDragHandle;
198 anchors.bottomMargin: -units.gu(1)
199 }
200 }
201 ]