~unity-team/unity8/ota9.5

« back to all changes in this revision

Viewing changes to Panel/Panel.qml

  • Committer: Michał Sawicz
  • Date: 2013-06-05 22:03:08 UTC
  • Revision ID: michal.sawicz@canonical.com-20130605220308-yny8fv3futtr04fg
Inital unity8 commit.

Previous history can be found at https://code.launchpad.net/~unity-team/unity/phablet

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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 "../Components"
 
20
import "../Components/ListItems"
 
21
 
 
22
Item {
 
23
    id: root
 
24
    readonly property real panelHeight: units.gu(3) + units.dp(2)
 
25
    property real indicatorsMenuWidth: (shell.width > units.gu(60)) ? units.gu(40) : shell.width
 
26
    property alias indicators: indicatorsMenu
 
27
    property bool fullscreenMode: false
 
28
    property bool searchVisible: true
 
29
 
 
30
    readonly property real separatorLineHeight: leftSeparatorLine.height
 
31
    readonly property real __panelMinusSeparatorLineHeight: panelHeight - separatorLineHeight
 
32
 
 
33
    signal searchClicked
 
34
 
 
35
    PanelBackground {
 
36
        id: panelBackground
 
37
        anchors {
 
38
            left: parent.left
 
39
            right: parent.right
 
40
        }
 
41
        height: __panelMinusSeparatorLineHeight
 
42
        y: 0
 
43
        onYChanged: indicatorsMenu.y = y;
 
44
 
 
45
        Behavior on y {
 
46
                NumberAnimation { duration: 200 }
 
47
        }
 
48
    }
 
49
 
 
50
    PanelSeparatorLine {
 
51
        id: leftSeparatorLine
 
52
        anchors {
 
53
            top: panelBackground.bottom
 
54
            left: parent.left
 
55
            right: indicatorsMenu.left
 
56
        }
 
57
        saturation: 1 - indicatorsMenu.unitProgress
 
58
    }
 
59
 
 
60
    Rectangle {
 
61
        id: darkenedArea
 
62
        property real darkenedOpacity: 0.6
 
63
        anchors {
 
64
            left: parent.left
 
65
            right: parent.right
 
66
            top: panelBackground.bottom
 
67
            bottom: parent.bottom
 
68
        }
 
69
        color: "black"
 
70
        opacity: indicatorsMenu.unitProgress * darkenedOpacity
 
71
        MouseArea {
 
72
            anchors.fill: parent
 
73
            enabled: indicatorsMenu.shown
 
74
            onClicked: if (indicatorsMenu.fullyOpened) indicatorsMenu.hide();
 
75
        }
 
76
    }
 
77
 
 
78
    BorderImage {
 
79
        id: dropShadow
 
80
        anchors {
 
81
            top: indicatorsMenu.top
 
82
            bottom: indicatorsSeparatorLine.bottom
 
83
            left: indicatorsMenu.left
 
84
            right: indicatorsMenu.right
 
85
            margins: -units.gu(1)
 
86
        }
 
87
        visible: indicatorsMenu.progress != indicatorRevealer.closedValue
 
88
        source: "graphics/rectangular_dropshadow.sci"
 
89
    }
 
90
 
 
91
    VerticalThinDivider {
 
92
        anchors {
 
93
            top: leftSeparatorLine.top
 
94
            bottom: indicatorsSeparatorLine.top
 
95
            right: indicatorsMenu.left
 
96
        }
 
97
        width: units.dp(2)
 
98
        source: "graphics/VerticalDivider.png"
 
99
    }
 
100
 
 
101
    Indicators {
 
102
        id: indicatorsMenu
 
103
 
 
104
        anchors.right: parent.right
 
105
        y: 0
 
106
        width: root.indicatorsMenuWidth
 
107
        shown: false
 
108
        revealer: indicatorRevealer
 
109
        hintValue: indicatorRevealer.hintDisplacement
 
110
        panelHeight: __panelMinusSeparatorLineHeight
 
111
        showAnimation: StandardAnimation { property: "progress"; duration: 350; to: indicatorRevealer.openedValue; easing.type: Easing.OutCubic }
 
112
        hideAnimation: StandardAnimation { property: "progress"; duration: 350; to: indicatorRevealer.closedValue; easing.type: Easing.OutCubic }
 
113
        openedHeight: parent.height
 
114
 
 
115
        pinnedMode: !fullscreenMode
 
116
 
 
117
        property real unitProgress: (indicatorRevealer.closedValue - progress) / (indicatorRevealer.closedValue - indicatorRevealer.openedValue)
 
118
    }
 
119
 
 
120
    PanelSeparatorLine {
 
121
        id: indicatorsSeparatorLine
 
122
        anchors {
 
123
            top: indicatorsMenu.bottom
 
124
            left: indicatorsMenu.left
 
125
            right: parent.right
 
126
        }
 
127
    }
 
128
 
 
129
    Revealer {
 
130
        id: indicatorRevealer
 
131
        objectName: "indicatorRevealer"
 
132
 
 
133
        width: root.indicatorsMenuWidth
 
134
        anchors {
 
135
            top: parent.top
 
136
            bottom: parent.bottom
 
137
            right: parent.right
 
138
        }
 
139
        target: indicatorsMenu
 
140
        handleSize: __panelMinusSeparatorLineHeight
 
141
        closedValue: __panelMinusSeparatorLineHeight
 
142
        dragVelocityThreshold: units.dp(1)
 
143
        boundProperty: "progress"
 
144
        hintDisplacement: __panelMinusSeparatorLineHeight * 3
 
145
        openOnPress: !fullscreenMode
 
146
        orientation: Qt.Vertical
 
147
 
 
148
        onOpenClicked: {
 
149
            indicatorsMenu.openOverview();
 
150
            indicatorsMenu.show();
 
151
        }
 
152
        onCloseClicked: indicatorsMenu.hide();
 
153
 
 
154
        onOpenPressed: indicatorsMenu.handlePress()
 
155
 
 
156
        function dragToValue(dragPosition) {
 
157
            var offset = target.shown ? 0 : -hintDisplacement + handleSize;
 
158
            return dragPosition + offset;
 
159
        }
 
160
    }
 
161
 
 
162
    SearchIndicator {
 
163
        id: search
 
164
        objectName: "search"
 
165
        enabled: root.searchVisible
 
166
 
 
167
        state: {
 
168
            if (parent.width < indicatorsMenu.width + width) {
 
169
                if (indicatorsMenu.state != "initial") {
 
170
                    return "hiddenUp";
 
171
                }
 
172
            }
 
173
            if (root.searchVisible) {
 
174
                return "visible";
 
175
            }
 
176
 
 
177
            return "hiddenUp";
 
178
        }
 
179
 
 
180
        width: units.gu(13)
 
181
        height: __panelMinusSeparatorLineHeight
 
182
        anchors {
 
183
            top: panelBackground.top
 
184
            left: panelBackground.left
 
185
        }
 
186
 
 
187
        onClicked: root.searchClicked()
 
188
    }
 
189
 
 
190
    states: [
 
191
        State {
 
192
            name: "in" //fully opaque and visible at top edge of screen
 
193
            when: !fullscreenMode
 
194
            PropertyChanges { target: panelBackground; y: 0 }
 
195
            PropertyChanges { target: indicatorRevealer; openedValue: indicatorsMenu.openedHeight - panelHeight }
 
196
        },
 
197
        State {
 
198
            name: "out" //pushed off screen
 
199
            when: fullscreenMode
 
200
            PropertyChanges { target: panelBackground; y: -panelHeight }
 
201
            PropertyChanges { target: indicatorRevealer; openedValue: indicatorsMenu.openedHeight }
 
202
        }
 
203
    ]
 
204
}