on 4a3183d help sign in
unity8/Panel/Panel.qml
152 lines 4.4 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
27 property bool searchVisible: true
29 readonly property real separatorLineHeight: leftSeparatorLine.height
30 readonly property real __panelMinusSeparatorLineHeight: panelHeight - separatorLineHeight
32 signal searchClicked
34 PanelBackground {
35 id: panelBackground
36 anchors {
37 left: parent.left
38 right: parent.right
39 }
40 height: __panelMinusSeparatorLineHeight
41 y: 0
43 Behavior on y { StandardAnimation {} }
44 }
46 PanelSeparatorLine {
47 id: leftSeparatorLine
48 anchors {
49 top: panelBackground.bottom
50 left: parent.left
51 right: indicatorsMenu.left
52 }
53 saturation: 1 - indicatorsMenu.unitProgress
54 }
56 Rectangle {
57 id: darkenedArea
58 property real darkenedOpacity: 0.6
59 anchors {
60 left: parent.left
61 right: parent.right
62 top: panelBackground.bottom
63 bottom: parent.bottom
64 }
65 color: "black"
66 opacity: indicatorsMenu.unitProgress * darkenedOpacity
67 MouseArea {
68 anchors.fill: parent
69 enabled: indicatorsMenu.shown
70 onClicked: if (indicatorsMenu.fullyOpened) indicatorsMenu.hide();
71 }
72 }
74 Indicators {
75 id: indicatorsMenu
77 anchors.right: parent.right
78 y: panelBackground.y
79 width: root.indicatorsMenuWidth
80 shown: false
81 hintValue: __panelMinusSeparatorLineHeight * 3
82 panelHeight: __panelMinusSeparatorLineHeight
83 openedHeight: parent.height + (pinnedMode ? 0 : root.panelHeight)
84 pinnedMode: !fullscreenMode
86 property real unitProgress: (height - panelHeight) / (openedHeight - panelHeight)
87 }
89 PanelSeparatorLine {
90 id: indicatorsSeparatorLine
91 visible: true
92 anchors {
93 left: indicatorsMenu.left
94 right: indicatorsMenu.right
95 }
96 y: indicatorsMenu.visualBottom
97 }
99 BorderImage {
100 id: dropShadow
101 anchors {
102 top: indicators.top
103 bottom: indicatorsSeparatorLine.bottom
104 left: indicators.left
105 right: indicators.right
106 margins: -units.gu(1)
107 }
108 visible: indicatorsMenu.height > indicatorsMenu.panelHeight
109 source: "graphics/rectangular_dropshadow.sci"
110 }
112 SearchIndicator {
113 id: search
114 objectName: "search"
115 enabled: root.searchVisible
117 state: {
118 if (parent.width < indicatorsMenu.width + width) {
119 if (indicatorsMenu.state != "initial") {
120 return "hidden";
121 }
122 }
123 if (root.searchVisible) {
124 return "visible";
125 }
127 return "hidden";
128 }
130 width: units.gu(13)
131 height: __panelMinusSeparatorLineHeight
132 anchors {
133 top: panelBackground.top
134 left: panelBackground.left
135 }
137 onClicked: root.searchClicked()
138 }
140 states: [
141 State {
142 name: "in" //fully opaque and visible at top edge of screen
143 when: !fullscreenMode
144 PropertyChanges { target: panelBackground; y: 0 }
145 },
146 State {
147 name: "out" //pushed off screen
148 when: fullscreenMode
149 PropertyChanges { target: panelBackground; y: -panelHeight }
150 }
151 ]