on 3f5d08f help sign in
unity8/Panel/Panel.qml
133 lines 3.8 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
42 onYChanged: indicatorsMenu.y = y;
44 Behavior on y {
45 NumberAnimation { duration: 200 }
46 }
47 }
49 PanelSeparatorLine {
50 id: leftSeparatorLine
51 anchors {
52 top: panelBackground.bottom
53 left: parent.left
54 right: indicatorsMenu.left
55 }
56 saturation: 1 - indicatorsMenu.unitProgress
57 }
59 Rectangle {
60 id: darkenedArea
61 property real darkenedOpacity: 0.6
62 anchors {
63 left: parent.left
64 right: parent.right
65 top: panelBackground.bottom
66 bottom: parent.bottom
67 }
68 color: "black"
69 opacity: indicatorsMenu.unitProgress * darkenedOpacity
70 MouseArea {
71 anchors.fill: parent
72 enabled: indicatorsMenu.shown
73 onClicked: if (indicatorsMenu.fullyOpened) indicatorsMenu.hide();
74 }
75 }
77 Indicators {
78 id: indicatorsMenu
80 anchors.right: parent.right
81 y: 0
82 width: root.indicatorsMenuWidth
83 shown: false
84 hintValue: __panelMinusSeparatorLineHeight * 3
85 panelHeight: __panelMinusSeparatorLineHeight
86 referenceOpenedHeight: parent.height
88 pinnedMode: !fullscreenMode
90 property real unitProgress: (height - panelHeight) / (openedHeight - panelHeight)
91 }
93 SearchIndicator {
94 id: search
95 objectName: "search"
96 enabled: root.searchVisible
98 state: {
99 if (parent.width < indicatorsMenu.width + width) {
100 if (indicatorsMenu.state != "initial") {
101 return "hiddenUp";
102 }
103 }
104 if (root.searchVisible) {
105 return "visible";
106 }
108 return "hiddenUp";
109 }
111 width: units.gu(13)
112 height: __panelMinusSeparatorLineHeight
113 anchors {
114 top: panelBackground.top
115 left: panelBackground.left
116 }
118 onClicked: root.searchClicked()
119 }
121 states: [
122 State {
123 name: "in" //fully opaque and visible at top edge of screen
124 when: !fullscreenMode
125 PropertyChanges { target: panelBackground; y: 0 }
126 },
127 State {
128 name: "out" //pushed off screen
129 when: fullscreenMode
130 PropertyChanges { target: panelBackground; y: -panelHeight }
131 }
132 ]