Merge lp:~cimi/unity8/fix-previewoverlay into lp:unity8

Proposed by Andrea Cimitan on 2015-03-04
Status: Merged
Approved by: Albert Astals Cid on 2015-03-10
Approved revision: 1629
Merged at revision: 1683
Proposed branch: lp:~cimi/unity8/fix-previewoverlay
Merge into: lp:unity8
Diff against target: 230 lines (+106/-36)
4 files modified
qml/Dash/Previews/PreviewImageGallery.qml (+25/-6)
qml/Dash/Previews/PreviewOverlay.qml (+77/-26)
qml/Dash/Previews/PreviewZoomableImage.qml (+3/-3)
tests/qmltests/Dash/Previews/tst_PreviewImageGallery.qml (+1/-1)
To merge this branch: bzr merge lp:~cimi/unity8/fix-previewoverlay
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing on 2015-03-10
Albert Astals Cid (community) 2015-03-04 Approve on 2015-03-10
Review via email: mp+251728@code.launchpad.net

Commit Message

Refactor PreviewOverlay to fix weird zoom out/in animations when previewing images from the Previews

Description of the Change

* Are there any related MPs required for this MP to build/function as expected? Please list.
n
 * Did you perform an exploratory manual test run of your code change and any related functionality?
y
 * Did you make sure that your branch does not contain spurious tags?
y
 * If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
n/a
 * If you changed the UI, has there been a design review?
n/a

To post a comment you must log in.
lp:~cimi/unity8/fix-previewoverlay updated on 2015-03-05
1626. By Andrea Cimitan on 2015-03-05

More fixes

lp:~cimi/unity8/fix-previewoverlay updated on 2015-03-09
1627. By Andrea Cimitan on 2015-03-09

Fix aspect ratio overlay

Albert Astals Cid (aacid) wrote :

It works better but there's still some rough edges. For example:

* Go to "Machines vs Machines" in the store scope
* Click on the first image
* Nice animation for opening
* While in preview, swipe to the second image
* Now close it
* Not nice animation
* Now open and close second image again
* Nice animation

So the code knows how to do the nice animation for the second image, but not if coming from the first one

Also if you close the second image fast after having scrolled to it, you can still see the bottom list moving, i guess we should make that animation/speed dependant on wheter the preview is open on top or not.

review: Needs Fixing
lp:~cimi/unity8/fix-previewoverlay updated on 2015-03-10
1628. By Andrea Cimitan on 2015-03-10

Fix as review

1629. By Andrea Cimitan on 2015-03-10

A couple of minor tweaks

Albert Astals Cid (aacid) wrote :

 * Did you perform an exploratory manual test run of the code change and any related functionality?
Yes, works nicely

 * Did CI run pass?
No, known tests to fail, elsewhere not related to changes here

 * Did you make sure that the branch does not contain spurious tags?
Yes

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'qml/Dash/Previews/PreviewImageGallery.qml'
2--- qml/Dash/Previews/PreviewImageGallery.qml 2014-10-29 13:52:58 +0000
3+++ qml/Dash/Previews/PreviewImageGallery.qml 2015-03-10 12:24:03 +0000
4@@ -38,6 +38,8 @@
5 model: root.widgetData["sources"]
6 clip: true
7
8+ onCurrentIndexChanged: overlay.updateInitialItem()
9+
10 LazyImage {
11 objectName: "placeholderScreenshot"
12 anchors {
13@@ -65,9 +67,8 @@
14 id: mouseArea
15 anchors.fill: parent
16 onClicked: {
17- overlay.delegateItem.currentIndex = index;
18- overlay.initialX = rootItem.mapFromItem(parent, 0, 0).x;
19- overlay.initialY = rootItem.mapFromItem(parent, 0, 0).y;
20+ previewImageListView.currentIndex = index;
21+ overlay.updateInitialItem();
22 overlay.show();
23 }
24 }
25@@ -78,9 +79,14 @@
26 id: overlay
27 objectName: "overlay"
28 parent: rootItem
29- width: parent.width
30- height: parent.height
31- initialScale: previewImageListView.height / rootItem.height
32+ anchors.fill: parent
33+
34+ function updateInitialItem() {
35+ initialX = rootItem.mapFromItem(previewImageListView.currentItem, 0, 0).x;
36+ initialY = rootItem.mapFromItem(previewImageListView.currentItem, 0, 0).y;
37+ initialWidth = previewImageListView.currentItem.width;
38+ initialHeight = previewImageListView.currentItem.height;
39+ }
40
41 delegate: ListView {
42 id: overlayListView
43@@ -92,6 +98,19 @@
44 snapMode: ListView.SnapOneItem
45 boundsBehavior: Flickable.DragAndOvershootBounds
46 model: root.widgetData["sources"]
47+ currentIndex: previewImageListView.currentIndex
48+
49+ onCurrentIndexChanged: {
50+ // if the index changed while overlay is visible, it was from user interaction,
51+ // let's update the index of the original listview
52+ if (overlay.visible) {
53+ previewImageListView.highlightMoveDuration = 0;
54+ previewImageListView.highlightResizeDuration = 0;
55+ previewImageListView.currentIndex = currentIndex;
56+ previewImageListView.highlightMoveDuration = -1;
57+ previewImageListView.highlightResizeDuration = -1;
58+ }
59+ }
60
61 delegate: Image {
62 id: screenshot
63
64=== modified file 'qml/Dash/Previews/PreviewOverlay.qml'
65--- qml/Dash/Previews/PreviewOverlay.qml 2014-10-22 20:15:09 +0000
66+++ qml/Dash/Previews/PreviewOverlay.qml 2015-03-10 12:24:03 +0000
67@@ -22,48 +22,99 @@
68 id: overlay
69 objectName: "overlay"
70
71- readonly property real scaleProgress: (scale - initialScale) / (1.0 - initialScale)
72+ readonly property real aspectRatio: width / height
73+ readonly property real initialAspectRatio: initialWidth / initialHeight
74+ readonly property real initialXScale: initialWidth / width
75+ readonly property real initialYScale: initialHeight / height
76
77 property alias delegate: loader.sourceComponent
78 property alias delegateItem: loader.item
79 property alias headerShown: overlayHeader.shown
80- property bool shown: false
81- property bool opening: false
82 property real initialX: 0
83 property real initialY: 0
84- property real initialScale: 0
85-
86- visible: scale > initialScale
87- clip: visible && scale < 1.0
88- scale: shown ? 1.0 : initialScale
89+ property real initialWidth: 1
90+ property real initialHeight: 1
91+
92+ property real xScale: initialXScale
93+ property real yScale: initialYScale
94+ property real progress: 0
95+
96+ implicitWidth: 1
97+ implicitHeight: 1
98+ visible: progress > 0
99+ clip: progress > 0 && progress < 1
100+ color: Qt.rgba(0, 0, 0, progress)
101 transformOrigin: Item.TopLeft
102- transform: Translate {
103- x: overlay.initialX - overlay.initialX * overlay.scaleProgress
104- y: overlay.initialY - overlay.initialY * overlay.scaleProgress
105- }
106- color: Qt.rgba(0, 0, 0, scaleProgress)
107- radius: units.gu(1) - units.gu(1) * scaleProgress
108+ transform: [
109+ Scale {
110+ origin.x: 0
111+ origin.y: 0
112+ xScale: overlay.xScale
113+ yScale: overlay.yScale
114+ },
115+ Translate {
116+ x: overlay.initialX - overlay.initialX * overlay.progress
117+ y: overlay.initialY - overlay.initialY * overlay.progress
118+ }
119+ ]
120+ state: "hidden"
121+ states: [
122+ State {
123+ name: "shown"
124+ PropertyChanges { target: overlay; progress: 1; xScale: 1; yScale: 1 }
125+ },
126+ State {
127+ name: "hidden"
128+ PropertyChanges { target: overlay; progress: 0; xScale: initialXScale; yScale: initialYScale }
129+ }
130+ ]
131+ transitions: [
132+ Transition {
133+ from: "hidden"
134+ to: "shown"
135+ UbuntuNumberAnimation {
136+ target: overlay
137+ properties: "progress,xScale,yScale"
138+ duration: UbuntuAnimation.FastDuration
139+ }
140+ },
141+ Transition {
142+ from: "shown"
143+ to: "hidden"
144+ UbuntuNumberAnimation {
145+ target: overlay
146+ properties: "progress,xScale,yScale"
147+ duration: UbuntuAnimation.FastDuration / 2
148+ }
149+ }
150+ ]
151
152 function show() {
153- opening = true;
154- shown = true;
155+ state = "shown"
156 }
157
158 function hide() {
159- opening = false;
160- shown = false;
161- }
162-
163- Behavior on scale {
164- UbuntuNumberAnimation {
165- duration: overlay.opening ? UbuntuAnimation.FastDuration :
166- UbuntuAnimation.FastDuration / 2
167- }
168+ state = "hidden"
169 }
170
171 Loader {
172 id: loader
173 anchors.fill: parent
174+
175+ readonly property bool verticalScaling: initialAspectRatio / aspectRatio >= 1
176+ readonly property real initialXScale: verticalScaling ? 1 : aspectRatio / initialAspectRatio
177+ readonly property real initialYScale: verticalScaling ? initialAspectRatio / aspectRatio : 1
178+ readonly property real xScale: verticalScaling ? loader.initialXScale - loader.initialXScale * overlay.progress + overlay.progress :
179+ loader.yScale * overlay.yScale / overlay.xScale
180+ readonly property real yScale: verticalScaling ? loader.xScale * overlay.xScale / overlay.yScale :
181+ loader.initialYScale - loader.initialYScale * overlay.progress + overlay.progress
182+
183+ transform: Scale {
184+ origin.x: parent.width / 2
185+ origin.y: parent.height / 2
186+ xScale: loader.xScale
187+ yScale: loader.yScale
188+ }
189 }
190
191 Rectangle {
192@@ -77,7 +128,7 @@
193 }
194 height: units.gu(7)
195 visible: opacity > 0
196- opacity: overlay.scaleProgress > 0.6 && shown ? 0.8 : 0
197+ opacity: overlay.state == "shown" && overlay.progress > 0.8 && shown ? 0.8 : 0
198 color: "black"
199
200 Behavior on opacity {
201
202=== modified file 'qml/Dash/Previews/PreviewZoomableImage.qml'
203--- qml/Dash/Previews/PreviewZoomableImage.qml 2014-11-05 08:37:55 +0000
204+++ qml/Dash/Previews/PreviewZoomableImage.qml 2015-03-10 12:24:03 +0000
205@@ -59,9 +59,9 @@
206 id: overlay
207 objectName: "overlay"
208 parent: rootItem
209- width: parent.width
210- height: parent.height
211- initialScale: lazyImage.height / rootItem.height
212+ anchors.fill: parent
213+ initialWidth: lazyImage.width
214+ initialHeight: lazyImage.height
215
216 delegate: ZoomableImage {
217 anchors.fill: parent
218
219=== modified file 'tests/qmltests/Dash/Previews/tst_PreviewImageGallery.qml'
220--- tests/qmltests/Dash/Previews/tst_PreviewImageGallery.qml 2015-01-09 09:15:45 +0000
221+++ tests/qmltests/Dash/Previews/tst_PreviewImageGallery.qml 2015-03-10 12:24:03 +0000
222@@ -22,7 +22,7 @@
223 Rectangle {
224 id: root
225 width: units.gu(80)
226- height: units.gu(80)
227+ height: units.gu(70)
228 color: "lightgrey"
229
230 property var sourcesModel0: {

Subscribers

People subscribed via source and target branches