@@ -190,11 +190,12 @@ Item {
190// print("touchX changed", touchX)
190// print("touchX changed", touchX)
191 coverFlip.progress = -(touchX - root.dragAreaWidth) / root.width
191 coverFlip.progress = -(touchX - root.dragAreaWidth) / root.width
193−// onDraggingChanged: {
194+ onDraggingChanged: {
194−// if (dragging) {
195+ if (!dragging) {
195−// coverFlip.visible = true
196+ coverFlip.snap();
199 Rectangle {
200 Rectangle {
200 anchors.fill: parent
201 anchors.fill: parent
@@ -210,6 +211,22 @@ Item {
210 visible: coverFlip.visible
211 visible: coverFlip.visible
216+ blockInput: coverFlip.visible
219+// anchors.fill: root
220+// enabled: coverFlip.visible
221+// property int oldMouseX
223+// onPressed: oldMouseX = mouseX
224+// onMouseXChanged: {
225+// coverFlip.progress += (oldMouseX - mouseX) * .001
226+// oldMouseX = mouseX
214 id: coverFlip
231 id: coverFlip
215 height: parent.height
232 height: parent.height
@@ -221,6 +238,36 @@ Item {
221 property real minScale: .6
238 property real minScale: .6
222// onProgressChanged: print("CoverFlip progress changed", progress)
239// onProgressChanged: print("CoverFlip progress changed", progress)
242+ if (coverFlip.progress < 0.25) {
243+ snapAnimation.targetProgress = 0
244+ } else if (coverFlip.progress < 0.75) {
245+ snapAnimation.targetProgress = 0.5
247+ snapAnimation.targetProgress = 1;
249+ snapAnimation.start();
252+ SequentialAnimation {
254+ property var targetProgress
256+ UbuntuNumberAnimation {
258+ properties: "progress"
259+ to: snapAnimation.targetProgress
263+ if (snapAnimation.targetProgress == 0.5) {
264+ ApplicationManager.focusApplication(ApplicationManager.get(1).appId);
265+ coverFlip.progress = 0;
224 Repeater {
271 Repeater {
225 model: ApplicationManager
272 model: ApplicationManager
@@ -234,6 +281,8 @@ Item {
234 source: ApplicationManager.get(index).screenshot
281 source: ApplicationManager.get(index).screenshot
284+ property real progress: coverFlip.progress
237 transform: [
286 transform: [
238 Rotation {
287 Rotation {
239 origin { x: units.gu(5); y: height / 2 }
288 origin { x: units.gu(5); y: height / 2 }
@@ -242,21 +291,21 @@ Item {
242 var newAngle = 0;
291 var newAngle = 0;
243 switch (index) {
292 switch (index) {
245− if (coverFlip.progress < .5) {
294+ if (appImage.progress < .5) {
246− newAngle = coverFlip.progress * coverFlip.maxAngle;
295+ newAngle = appImage.progress * coverFlip.maxAngle;
248− newAngle = (coverFlip.progress - .5) * coverFlip.maxAngle * 2;
297+ newAngle = (appImage.progress - .5) * coverFlip.maxAngle * 2;
252− if (coverFlip.progress < .5) {
301+ if (appImage.progress < .5) {
253− newAngle = coverFlip.maxAngle - (coverFlip.progress * coverFlip.maxAngle * 2);
302+ newAngle = coverFlip.maxAngle - (appImage.progress * coverFlip.maxAngle * 2);
255− newAngle = (coverFlip.progress - .5) * coverFlip.maxAngle * 2;
304+ newAngle = (appImage.progress - .5) * coverFlip.maxAngle * 2;
259− newAngle = Math.min(coverFlip.progress, .75) * coverFlip.maxAngle;
308+ newAngle = Math.min(appImage.progress, .75) * coverFlip.maxAngle;
261 return Math.min(newAngle, coverFlip.maxAngle);
310 return Math.min(newAngle, coverFlip.maxAngle);
@@ -265,11 +314,11 @@ Item {
266 switch (index) {
315 switch (index) {
268− if (coverFlip.progress < .5) {
317+ if (appImage.progress < .5) {
269− return -root.width * coverFlip.progress;
318+ return -root.width * appImage.progress;
270− } else if (coverFlip.progress < .75) {
319+ } else if (appImage.progress < .75) {
271 // relation equation: x : width/2 = progress-.5 : 0.25
320 // relation equation: x : width/2 = progress-.5 : 0.25
272− return (-root.width * .5) + (root.width/2) * (coverFlip.progress - .5) / 0.25
321+ return (-root.width * .5) + (root.width/2) * (appImage.progress - .5) / 0.25
275 return 0;
324 return 0;
@@ -281,35 +330,51 @@ Item {
281 var scale = 1;
330 var scale = 1;
282 // progress : 1 = x : root.width
331 // progress : 1 = x : root.width
283 var progress = root.width / (root.width - x)
332 var progress = root.width / (root.width - x)
284− if (coverFlip.progress > .5) {
333+ if (appImage.progress > .5) {
285 // relation equation: scale : (1-minScale) = progress-.5 : 0.5
334 // relation equation: scale : (1-minScale) = progress-.5 : 0.5
286− scale = 1 - (1 - coverFlip.minScale) * (coverFlip.progress - 0.5) / 0.5
335+ scale = 1 - (1 - coverFlip.minScale) * (appImage.progress - 0.5) / 0.5
288 scale = Math.max(coverFlip.minScale, scale);
337 scale = Math.max(coverFlip.minScale, scale);
289− print("scaling to", scale)
290 return scale;
338 return scale;
292 yScale: xScale
340 yScale: xScale
297− }
346+ anchors.fill: parent
302− blockInput: coverFlip.visible
306− enabled: coverFlip.visible
307− property int oldMouseX
348+ property int oldMouseX
350+ onPressed: oldMouseX = mouseX
352+ coverFlip.progress += (oldMouseX - mouseX) * .001
357+ print("clicked item", index)
358+ switchToAppAnimation.start();
309− onPressed: oldMouseX = mouseX
362+ SequentialAnimation {
310− onMouseXChanged: {
363+ id: switchToAppAnimation
311− coverFlip.progress += (oldMouseX - mouseX) * .001
364+ ParallelAnimation {
312− oldMouseX = mouseX
365+ UbuntuNumberAnimation { target: appImage; property: "progress"; to: 0 }
366+ UbuntuNumberAnimation { target: appImage; property: "x"; to: -width * index }
370+ ApplicationManager.focusApplication(ApplicationManager.get(index).appId);
371+ coverFlip.progress = 0;