2
* Copyright (C) 2015 Canonical, Ltd.
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.
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.
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/>.
21
objectName: "mainView"
23
applicationName: "com.ubuntu.developer.qtros.tabsbottomedge"
27
useDeprecatedToolbar: false
31
Component.onCompleted: push(tabs)
37
bottomEdgePage: secondPage
38
bottomEdgeTitle: "Violet page"
44
anchors.centerIn: parent
45
text: "Content of first tab"
54
anchors.centerIn: parent
55
text: "Centered label"
76
import Ubuntu.Components 1.2
81
property Page bottomEdgePage: null
82
property alias bottomEdgeTitle: tipLabel.text
83
property color bottomEdgeBackgroundColor
84
property color bottomEdgeTipColor
85
property bool bottomEdgeEnabled: true
86
property bool bottomEdgeHeaderHidden: true
87
property bool bottomEdgeUseHeaderInCalculations: true
88
property real bottomEdgeExpandThreshold: 0.2
90
readonly property bool isReady: bottomEdgePageLoaded && bottomEdgePage.active && bottomEdge.y === __pageStartY
91
readonly property bool isCollapsed: (bottomEdge.y === page.height)
92
readonly property bool bottomEdgePageLoaded: bottomEdgePage != null
94
readonly property int __pageStartY: bottomEdgeUseHeaderInCalculations ? fakeHeader.height : 0
96
signal bottomEdgeReleased()
97
signal bottomEdgeDismissed()
99
function __pushPage() {
100
if (bottomEdgePageLoaded) {
101
bottomEdgePage.active = true
102
if (bottomEdgePage.hasOwnProperty("isDirty")) // TODO
103
bottomEdgePage.isDirty = true
104
page.pageStack.push(bottomEdgePage)
105
if (bottomEdgePage.flickable) {
106
bottomEdgePage.flickable.contentY = -page.header.height
107
bottomEdgePage.flickable.returnToBounds()
109
if (bottomEdgePage.ready)
110
bottomEdgePage.ready()
116
bottomEdge.state = "collapsed"
120
onBottomEdgePageChanged: {
121
tip.forceActiveFocus()
122
if (page.isReady && bottomEdgePageLoaded && !bottomEdgePage.active) {
133
topMargin: __pageStartY
135
opacity: 0.7 * ((page.height - bottomEdge.y) / page.height)
141
objectName: "bottomEdgeTip"
143
property bool hidden: !activeFocus || (bottomEdge.y - units.gu(1) < tip.y)
145
enabled: bottomEdgePageLoaded
146
visible: bottomEdgeEnabled
148
bottom: parent.bottom
149
horizontalCenter: bottomEdge.horizontalCenter
150
bottomMargin: hidden ? - height + units.gu(1) : -units.gu(1)
151
Behavior on bottomMargin {
152
SequentialAnimation {
153
// wait some msecs in case of the focus change again, to avoid flickering
157
UbuntuNumberAnimation {
158
duration: UbuntuAnimation.SnapDuration
165
width: tipLabel.paintedWidth + units.gu(6)
166
height: bottomEdge.tipHeight + units.gu(1)
167
color: bottomEdgeTipColor //color: "#C9C9C9"
177
height: bottomEdge.tipHeight
178
verticalAlignment: Text.AlignVCenter
179
horizontalAlignment: Text.AlignHCenter
180
opacity: tip.hidden ? 0.0 : 1.0
181
Behavior on opacity {
182
UbuntuNumberAnimation {
183
duration: UbuntuAnimation.SnapDuration
195
bottom: bottomEdge.top
201
GradientStop { position: 0.0; color: "transparent" }
202
GradientStop { position: 1.0; color: Qt.rgba(0, 0, 0, 0.2) }
209
property real previousY: -1
210
property string dragDirection: "None"
212
preventStealing: true
216
minimumY: __pageStartY
217
maximumY: page.height
219
enabled: bottomEdgePageLoaded
220
visible: page.bottomEdgeEnabled
225
bottom: parent.bottom
227
height: bottomEdge.tipHeight
231
page.bottomEdgeReleased()
232
if ((dragDirection === "BottomToTop") &&
233
bottomEdge.y < (page.height - page.height * bottomEdgeExpandThreshold - bottomEdge.tipHeight)) {
234
bottomEdge.state = "expanded"
236
bottomEdge.state = "collapsed"
239
dragDirection = "None"
244
tip.forceActiveFocus()
248
var yOffset = previousY - mouseY
249
// skip if was a small move
250
if (Math.abs(yOffset) <= units.gu(2))
254
dragDirection = yOffset > 0 ? "BottomToTop" : "TopToBottom"
260
visible: bottomEdgeEnabled && !bottomEdgeHeaderHidden
266
y: -fakeHeader.height + (fakeHeader.height * (page.height - bottomEdge.y)) / (page.height - fakeHeader.height)
270
UbuntuNumberAnimation {
271
duration: UbuntuAnimation.SnapDuration
278
objectName: "bottomEdge"
280
readonly property int tipHeight: units.gu(3)
284
color: bottomEdgeBackgroundColor
293
visible: !page.isCollapsed
304
y: -fakeHeader.height
320
when: mouseArea.drag.active
331
SequentialAnimation {
337
duration: UbuntuAnimation.FastDuration
338
easing.type: Easing.Linear
343
duration: UbuntuAnimation.FastDuration
344
easing.type: Easing.Linear
349
property: "anchors.topMargin"
351
duration: UbuntuAnimation.FastDuration
352
easing.type: Easing.Linear
356
property: "anchors.topMargin"
358
duration: UbuntuAnimation.FastDuration
359
easing: UbuntuAnimation.StandardEasing
362
script: page.__pushPage()
369
SequentialAnimation {
374
Qt.inputMethod.hide()
375
bottomEdgePage.active = false
382
duration: UbuntuAnimation.SlowDuration
387
duration: UbuntuAnimation.SlowDuration
393
page.bottomEdgeDismissed()
394
bottomEdgePage.active = true
402
UbuntuNumberAnimation {
411
sourceItem: bottomEdgePage
417
height: page.height - fakeHeader.height
420
target: bottomEdgePageLoaded ? shaderSource : null
421
property: "anchors.topMargin"
422
value: bottomEdgePage && bottomEdgePage.flickable ? bottomEdgePage.flickable.contentY : 0