on xenial help sign in
Make all items in the spread have the very same size when stacked on the left side
commite6b6168c2afa3ba8a3907b24aa83bab73b93cc48 authorDaniel d'Andrada <daniel.dandrada@canonical.com> dateTue 28 Apr 2015, 17:20 (12 years ago) parent45a59d6
2 files changed+17−23
qml/Stages/SpreadDelegate.qml+15−7 qml/Stages/TransformedSpreadDelegate.qml+2−16
qml/Stages/SpreadDelegate.qml+15−7
@@ -131,6 +131,14 @@ FocusScope {
131131 }
132132 }
133133
134+ // Ensures the given angle is in the form (0,90,180,270)
135+ function normalizeAngle(angle) {
136+ while (angle < 0) {
137+ angle += 360;
138+ }
139+ return angle % 360;
140+ }
141+
134142 states: [
135143 // Sets the initial orientationAngle of the window, when it first slides into view
136144 // (with the splash screen likely being displayed). At that point we just try to
@@ -172,16 +180,16 @@ FocusScope {
172180 return Screen.angleBetween(root.nativeOrientation, chosenOrientation);
173181 }
174182
175− rotation: appWindowWithShadow.orientationAngle - root.shellOrientationAngle
183+ rotation: normalizeAngle(appWindowWithShadow.orientationAngle - root.shellOrientationAngle)
176184 width: {
177− if (rotation == 0 || Math.abs(rotation) == 180) {
185+ if (rotation == 0 || rotation == 180) {
178186 return root.width;
179187 } else {
180188 return root.height;
181189 }
182190 }
183191 height: {
184− if (rotation == 0 || Math.abs(rotation) == 180)
192+ if (rotation == 0 || rotation == 180)
185193 return root.height;
186194 else
187195 return root.width;
@@ -201,16 +209,16 @@ FocusScope {
201209 PropertyChanges {
202210 target: appWindowWithShadow
203211 restoreEntryValues: false
204− rotation: appWindowWithShadow.orientationAngle - root.shellOrientationAngle
212+ rotation: normalizeAngle(appWindowWithShadow.orientationAngle - root.shellOrientationAngle)
205213 width: {
206− if (rotation == 0 || Math.abs(rotation) == 180) {
214+ if (rotation == 0 || rotation == 180) {
207215 return root.width;
208216 } else {
209217 return root.height;
210218 }
211219 }
212220 height: {
213− if (rotation == 0 || Math.abs(rotation) == 180)
221+ if (rotation == 0 || rotation == 180)
214222 return root.height;
215223 else
216224 return root.width;
@@ -229,7 +237,7 @@ FocusScope {
229237 target: appWindowWithShadow
230238 width: root.shellOrientationAngle == 0 || root.shellOrientationAngle == 180 ? root.width : root.height
231239 height: root.shellOrientationAngle == 0 || root.shellOrientationAngle == 180 ? root.height : root.width
232− rotation: -root.shellOrientationAngle
240+ rotation: normalizeAngle(-root.shellOrientationAngle)
233241 }
234242 PropertyChanges {
235243 target: appWindow
qml/Stages/TransformedSpreadDelegate.qml+2−16
@@ -312,27 +312,13 @@ SpreadDelegate {
312312 // non-fullscreen window when they're stacked on top of each other on the
313313 // far left of the spread.
314314 Translate {
315− y: !fullscreen && Math.abs(appWindowRotation) === 180
315+ y: !fullscreen && appWindowRotation === 180
316316 ? priv.topMarginProgress * maximizedAppTopMargin
317317 : 0
318318 },
319319 Scale {
320320 origin {
321− x: {
322− switch (appWindowRotation) {
323− case 0:
324− return 0;
325− break;
326− case 90:
327− return 0;
328− break;
329− case 270:
330− return spreadView.width;
331− break;
332− default: // 180
333− return 0;
334− }
335− }
321+ x: appWindowRotation === 270 ? spreadView.width : 0
336322 y: spreadView.height
337323 }
338324