on xenial help sign in
Animate Dash growing from the All screen
commit8cc984d9af9e0b9e982708e6c0195eef4917c182 authorAlbert Astals <albert.astals@canonical.com> dateTue 15 Jul 2014, 13:39 (12 years ago) parente21eb51
2 files changed+55−15
qml/Dash/Dash.qml+34−8 qml/Dash/ScopesOverview.qml+21−7
qml/Dash/Dash.qml+34−8
@@ -81,6 +81,7 @@ Showable {
8181 property alias enableAnimation: progressAnimation.enabled
8282 property real progress: 0
8383 property bool showingNonFavoriteScope: false
84+ property bool growingDashFromAll: false
8485 Behavior on progress {
8586 id: progressAnimation
8687 UbuntuNumberAnimation { }
@@ -96,7 +97,20 @@ Showable {
9697 scopeScale: 1 - overviewController.progress * 0.6
9798 visible: scopeScale != 1
9899 currentIndex: dashContent.currentIndex
99− onDone: hide();
100+ onDone: {
101+ if (dashContent.parent == scopesOverviewXYScaler) {
102+ // Animate Dash growing from the All screen
103+ // TODO find where the thing comes from for that x, y
104+ scopesOverviewXYScaler.scale = scopesOverview.allCardSize.width / scopesOverviewXYScaler.width;
105+ scopesOverviewXYScaler.x = /*scopesOverview.allScopeClickedPos.x*/ -(scopesOverviewXYScaler.width - scopesOverviewXYScaler.width * scopesOverviewXYScaler.scale) / 2;
106+ scopesOverviewXYScaler.y = /*scopesOverview.allScopeClickedPos.y*/ -(scopesOverviewXYScaler.height - scopesOverviewXYScaler.height * scopesOverviewXYScaler.scale) / 2;
107+ overviewController.growingDashFromAll = true;
108+ scopesOverviewXYScaler.scale = 1;
109+ scopesOverviewXYScaler.x = 0;
110+ scopesOverviewXYScaler.y = 0;
111+ }
112+ hide();
113+ }
100114 onFavoriteSelected: {
101115 dashContent.setCurrentScopeAtIndex(index, false, false);
102116 hide();
@@ -126,7 +140,15 @@ Showable {
126140
127141 DashContent {
128142 id: dashContent
129− parent: overviewController.progress == 0 ? dash : scopesOverview.dashItemEater
143+ parent: {
144+ if (overviewController.progress == 0) {
145+ return dash;
146+ } else if (scopesOverview.dashItemEater) {
147+ return scopesOverview.dashItemEater;
148+ } else {
149+ return scopesOverviewXYScaler;
150+ }
151+ }
130152 objectName: "dashContent"
131153 width: dash.width
132154 height: dash.height
@@ -160,7 +182,7 @@ Showable {
160182 }
161183
162184 enabled: opacity == 1
163− opacity: 1 - overviewController.progress
185+ opacity: overviewController.growingDashFromAll ? 1 : 1 - overviewController.progress
164186 }
165187
166188 DashBackground
@@ -216,25 +238,29 @@ Showable {
216238 enabled: scale == 1
217239 opacity: scale
218240
241+ property bool animationsEnabled: overviewController.showingNonFavoriteScope || overviewController.growingDashFromAll
242+
219243 Behavior on x {
220− enabled: overviewController.showingNonFavoriteScope
244+ enabled: scopesOverviewXYScaler.animationsEnabled
221245 UbuntuNumberAnimation { }
222246 }
223247 Behavior on y {
224− enabled: overviewController.showingNonFavoriteScope
248+ enabled: scopesOverviewXYScaler.animationsEnabled
225249 UbuntuNumberAnimation { }
226250 }
227251
228252 Behavior on scale {
229− enabled: overviewController.showingNonFavoriteScope
253+ enabled: scopesOverviewXYScaler.animationsEnabled
230254 UbuntuNumberAnimation {
231255 onRunningChanged: {
232− if (overviewController.showingNonFavoriteScope) {
233− if (!running && scopesOverviewXYScaler.scale != 1) {
256+ if (!running) {
257+ if (overviewController.showingNonFavoriteScope && scopesOverviewXYScaler.scale != 1) {
234258 scopesOverview.scope.closeScope(scopeItem.scope);
235259 overviewController.showingNonFavoriteScope = false;
236260 scopeItem.scope = null;
237261 scopeItem.parent = dash;
262+ } else if (overviewController.growingDashFromAll) {
263+ overviewController.growingDashFromAll = false;
238264 }
239265 }
240266 }
qml/Dash/ScopesOverview.qml+21−7
@@ -24,7 +24,7 @@ Item {
2424 property real progress: 0
2525 property var scope: null
2626 property var dashItemEater: {
27− if (middleItems.count > 0) {
27+ if (tabBarHolder.currentTab == 0 && middleItems.count > 0) {
2828 var loaderItem = middleItems.itemAt(0).item;
2929 return loaderItem && loaderItem.currentItem ? loaderItem.currentItem : null;
3030 }
@@ -53,6 +53,12 @@ Item {
5353 signal favoriteSelected(int index)
5454 signal allSelected(var scope)
5555
56+ onProgressChanged: {
57+ if (progress == 0) {
58+ tabBarHolder.currentTab = 0;
59+ }
60+ }
61+
5662 DashBackground {
5763 anchors.fill: parent
5864 Rectangle {
@@ -144,8 +150,19 @@ Item {
144150
145151 scale: index == 0 ? scopeScale : 1
146152
147− opacity: root.overrideOpacity >= 0 ? root.overrideOpacity : tabBarHolder.currentTab == index ? 1 : 0
148− Behavior on opacity { UbuntuNumberAnimation { } }
153+ opacity: {
154+ if (root.overrideOpacity >= 0)
155+ return root.overrideOpacity;
156+
157+ if (tabBarHolder.currentTab != index)
158+ return 0;
159+
160+ return index == 0 ? 1 : root.progress;
161+ }
162+ Behavior on opacity {
163+ enabled: root.progress == 1
164+ UbuntuNumberAnimation { }
165+ }
149166 enabled: opacity == 1
150167
151168 clip: index == 1
@@ -238,10 +255,7 @@ Item {
238255 text: i18n.tr("Done")
239256 color: parent.pressed ? "black" : "white"
240257 }
241− onClicked: {
242− root.done();
243− tabBarHolder.currentTab = 0;
244− }
258+ onClicked: root.done();
245259 }
246260 }
247261 }