on xenial help sign in
Make launcher demo transitions smoother
commitcac9b5925710f657eb382b162f26b077843fe1cf authorMichael Terry <michael.terry@canonical.com> dateWed 21 Aug 2013, 15:31 (13 years ago) parent7d72d31
2 files changed+48−39
Components/DemoOverlay.qml+30−23 Shell.qml+18−16
Components/DemoOverlay.qml+30−23
@@ -19,7 +19,7 @@ import QtGraphicalEffects 1.0
1919import Ubuntu.Application 0.1
2020import Ubuntu.Components 0.1
2121
22−Item {
22+Showable {
2323 id: overlay
2424
2525 /*
@@ -42,24 +42,45 @@ Item {
4242 */
4343 property string skipText: i18n.tr("Skip intro")
4444
45− /*
46− * Whether this demo is allowed to run.
47− */
48− property bool enabled: true
49−
5045 /*
5146 * Whether this demo is running currently.
5247 */
53− readonly property bool active: enabled && visible
48+ readonly property bool active: available && visible
5449
5550 property color __orange: Qt.hsla(16.0/360.0, 0.83, 0.47, 1.0)
5651 property color __orange_transparent: Qt.hsla(16.0/360.0, 0.83, 0.47, 0.4)
5752 property int __edge_margin: units.gu(4)
5853 property int __text_margin: units.gu(3)
54+ property bool __skip_on_hide: false
5955 property int __anim_running: wholeAnimation.running // for testing
6056
6157 signal skip()
6258
59+ function doSkip() {
60+ __skip_on_hide = true;
61+ hide();
62+ }
63+
64+ function hideNow() {
65+ overlay.visible = false;
66+ overlay.available = false;
67+ if (overlay.__skip_on_hide) {
68+ overlay.skip();
69+ }
70+ }
71+
72+ showAnimation: StandardAnimation {
73+ property: "opacity"
74+ to: 1
75+ onRunningChanged: if (running) overlay.visible = true
76+ }
77+ hideAnimation: StandardAnimation {
78+ property: "opacity"
79+ to: 0
80+ duration: UbuntuAnimation.BriskDuration
81+ onRunningChanged: if (!running) overlay.hideNow()
82+ }
83+
6384 Rectangle {
6485 id: backgroundShade
6586 anchors.fill: parent
@@ -70,7 +91,7 @@ Item {
7091 MouseArea {
7192 anchors.fill: parent
7293 enabled: overlay.edge == "none" && overlay.opacity == 1.0
73− onClicked: fadeOutAnimation.running = true
94+ onClicked: overlay.doSkip()
7495 }
7596 }
7697
@@ -119,7 +140,7 @@ Item {
119140
120141 MouseArea {
121142 anchors.fill: parent
122− onClicked: fadeOutAnimation.running = true
143+ onClicked: overlay.doSkip()
123144 }
124145 }
125146 }
@@ -165,20 +186,6 @@ Item {
165186 }
166187 }
167188
168− PropertyAnimation {
169− id: fadeOutAnimation
170− target: overlay
171− property: "opacity"
172− to: 0
173− duration: 250
174−
175− onStopped: {
176− overlay.enabled = false;
177− overlay.visible = false;
178− skip()
179− }
180− }
181−
182189 SequentialAnimation {
183190 id: wholeAnimation
184191 running: overlay.active
Shell.qml+18−16
@@ -241,17 +241,17 @@ FocusScope {
241241 text: i18n.tr("Try swiping from the top edge to access the indicators")
242242 anchors.fill: dash
243243 visible: false
244− enabled: shell.showEdgeDemo
244+ available: shell.showEdgeDemo
245245 onSkip: shell.hideEdgeDemo()
246246
247247 Connections {
248248 target: greeter
249− onShownChanged: if (!greeter.shown) topEdgeDemo.visible = true
249+ onShownChanged: if (!greeter.shown) topEdgeDemo.show()
250250 }
251251
252252 Connections {
253253 target: panel.indicators
254− onFullyOpenedChanged: if (panel.indicators.fullyOpened) topEdgeDemo.enabled = false
254+ onFullyOpenedChanged: if (panel.indicators.fullyOpened) topEdgeDemo.hideNow()
255255 }
256256 }
257257
@@ -263,17 +263,17 @@ FocusScope {
263263 text: i18n.tr("Swipe from the left to reveal the launcher for quick access to apps")
264264 anchors.fill: dash
265265 visible: false
266− enabled: shell.showEdgeDemo
266+ available: shell.showEdgeDemo
267267 onSkip: shell.hideEdgeDemo()
268268
269269 Connections {
270270 target: bottomEdgeDemo
271− onActiveChanged: if (!bottomEdgeDemo.active) leftEdgeDemo.visible = true
271+ onActiveChanged: if (!bottomEdgeDemo.active) leftEdgeDemo.show()
272272 }
273273
274274 Connections {
275275 target: launcher
276− onProgressChanged: if (launcher.progress >= 1.0) leftEdgeDemo.enabled = false
276+ onStateChanged: if (launcher.state == "visible") leftEdgeDemo.hide()
277277 }
278278 }
279279 }
@@ -548,7 +548,7 @@ FocusScope {
548548
549549 function hide() {
550550 if (rightEdgeDemo.active) {
551− rightEdgeDemo.enabled = false
551+ rightEdgeDemo.hide()
552552 shell.hideEdgeDemoInGreeter()
553553 }
554554 }
@@ -629,13 +629,13 @@ FocusScope {
629629 text: i18n.tr("Swipe up again to close the settings screen")
630630 anchors.fill: panel.indicators
631631 visible: false
632− enabled: shell.showEdgeDemo
632+ available: shell.showEdgeDemo
633633 onSkip: shell.hideEdgeDemo()
634634
635635 Connections {
636636 target: panel.indicators
637− onFullyOpenedChanged: if (panel.indicators.fullyOpened) bottomEdgeDemo.visible = true
638− onPartiallyOpenedChanged: if (!panel.indicators.partiallyOpened && !panel.indicators.fullyOpened) bottomEdgeDemo.enabled = false
637+ onFullyOpenedChanged: if (panel.indicators.fullyOpened) bottomEdgeDemo.show()
638+ onPartiallyOpenedChanged: if (!panel.indicators.partiallyOpened && !panel.indicators.fullyOpened) bottomEdgeDemo.hideNow()
639639 }
640640 }
641641 }
@@ -771,15 +771,17 @@ FocusScope {
771771 skipText: i18n.tr("Finish")
772772 anchors.fill: overlay
773773 visible: false
774− enabled: shell.showEdgeDemo
775− onSkip: {
776− launcher.hide();
777− shell.hideEdgeDemo();
778− }
774+ available: shell.showEdgeDemo
775+ onSkip: shell.hideEdgeDemo()
779776
780777 Connections {
781778 target: leftEdgeDemo
782− onActiveChanged: if (!leftEdgeDemo.active) finalEdgeDemo.visible = true
779+ onActiveChanged: {
780+ if (!leftEdgeDemo.active) {
781+ finalEdgeDemo.show();
782+ launcher.hide();
783+ }
784+ }
783785 }
784786 }
785787