on 0193f12 help sign in
unity8/qml/Panel/Panel.qml
142 lines 4.1 kB history raw
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 */
17import QtQuick 2.0
18import Ubuntu.Components 0.1
19import "../Components"
21Item {
22 id: root
23 readonly property real panelHeight: units.gu(3) + units.dp(2)
24 property real indicatorsMenuWidth: (shell.width > units.gu(60)) ? units.gu(40) : shell.width
25 property alias indicators: indicatorsMenu
26 property bool fullscreenMode: false
28 readonly property real separatorLineHeight: leftSeparatorLine.height
29 readonly property real __panelMinusSeparatorLineHeight: panelHeight - separatorLineHeight
31 function hideIndicatorMenu(delay) {
32 if (delay !== undefined) {
33 hideTimer.interval = delay;
34 hideTimer.start();
35 } else {
36 indicatorsMenu.hide();
37 }
38 }
40 Timer {
41 id: hideTimer
42 running: false
43 onTriggered: {
44 indicatorsMenu.hide();
45 }
46 }
48 Connections {
49 target: indicatorsMenu
50 onShownChanged: hideTimer.stop()
51 }
53 PanelBackground {
54 id: panelBackground
55 anchors {
56 left: parent.left
57 right: parent.right
58 }
59 height: __panelMinusSeparatorLineHeight
60 y: 0
62 Behavior on y { StandardAnimation { duration: 500 } }
63 }
65 PanelSeparatorLine {
66 id: leftSeparatorLine
67 anchors {
68 top: panelBackground.bottom
69 left: parent.left
70 right: indicatorsMenu.left
71 }
72 saturation: 1 - indicatorsMenu.unitProgress
73 }
75 Rectangle {
76 id: darkenedArea
77 property real darkenedOpacity: 0.6
78 anchors {
79 left: parent.left
80 right: parent.right
81 top: panelBackground.bottom
82 bottom: parent.bottom
83 }
84 color: "black"
85 opacity: indicatorsMenu.unitProgress * darkenedOpacity
86 MouseArea {
87 anchors.fill: parent
88 enabled: indicatorsMenu.shown
89 onClicked: if (indicatorsMenu.fullyOpened) indicatorsMenu.hide();
90 }
91 }
93 Indicators {
94 id: indicatorsMenu
95 objectName: "indicators"
97 anchors.right: parent.right
98 y: panelBackground.y
99 width: root.indicatorsMenuWidth
100 shown: false
101 panelHeight: __panelMinusSeparatorLineHeight
102 openedHeight: parent.height + (pinnedMode ? 0 : root.panelHeight)
103 pinnedMode: !fullscreenMode
104 overFlowWidth: parent.width
105 }
107 PanelSeparatorLine {
108 id: indicatorsSeparatorLine
109 visible: true
110 anchors {
111 left: indicatorsMenu.left
112 right: indicatorsMenu.right
113 }
114 y: indicatorsMenu.visualBottom
115 }
117 BorderImage {
118 id: dropShadow
119 anchors {
120 top: indicators.top
121 bottom: indicatorsSeparatorLine.bottom
122 left: indicators.left
123 right: indicators.right
124 margins: -units.gu(1)
125 }
126 visible: indicatorsMenu.height > indicatorsMenu.panelHeight
127 source: "graphics/rectangular_dropshadow.sci"
128 }
130 states: [
131 State {
132 name: "in" //fully opaque and visible at top edge of screen
133 when: !fullscreenMode
134 PropertyChanges { target: panelBackground; y: 0 }
135 },
136 State {
137 name: "out" //pushed off screen
138 when: fullscreenMode
139 PropertyChanges { target: panelBackground; y: -panelHeight }
140 }
141 ]