Commit 443b798b authored by Filip Matijević's avatar Filip Matijević

[rotation] apply rotation to LockScreen to always keep it in native orientation

parent 5238406a
...@@ -35,10 +35,24 @@ import org.nemomobile.lipstick 0.1 ...@@ -35,10 +35,24 @@ import org.nemomobile.lipstick 0.1
Item { Item {
property int _nativeRotation: Screen.angleBetween(nativeOrientation, Screen.primaryOrientation)
property bool _nativeIsPortrait: ((_nativeRotation === 0) || (_nativeRotation === 180))
property Item rotationParent property Item rotationParent
property variant unrotatedItems: []
function rotationDiff(a, b) {
var r =_nativeRotation - rotationParent.rotation
if (r < 360)
r += 360
return r
}
function rotateRotationParent(o) { function rotateRotationParent(o) {
rotateObject(rotationParent, o) rotateObject(rotationParent, o)
for(var i = 0; i < unrotatedItems.length; i++) {
rotateObjectToAngle(unrotatedItems[i], rotationDiff(_nativeRotation, rotationParent.rotation))
}
} }
function rotateObject(obj, o) { function rotateObject(obj, o) {
...@@ -50,7 +64,16 @@ Item { ...@@ -50,7 +64,16 @@ Item {
function rotateObjectToAngle(obj, r) { function rotateObjectToAngle(obj, r) {
obj.width = Screen.width; obj.height = Screen.height; obj.x = 0; obj.y = 0 obj.width = Screen.width; obj.height = Screen.height; obj.x = 0; obj.y = 0
obj.rotation = r obj.rotation = r
var res = obj.mapToItem(rotationParent.parent, 0, 0, obj.width, obj.height) var res = obj.mapToItem((obj === rotationParent) ? rotationParent.parent : rotationParent, 0, 0, obj.width, obj.height)
if (obj !== rotationParent) {
if (_nativeIsPortrait) {
var i = res.x
res.x = res.y
res.y = i
}
var res2 = rotationParent.mapToItem(rotationParent.parent, 0, 0, res.width, res.height)
res.width = res2.width; res.height = res2.height
}
obj.x = res.x; obj.y = res.y; obj.width = res.width; obj.height = res.height obj.x = res.x; obj.y = res.y; obj.width = res.width; obj.height = res.height
} }
} }
...@@ -73,6 +73,7 @@ Page { ...@@ -73,6 +73,7 @@ Page {
GlacierRotation { GlacierRotation {
id: glacierRotation id: glacierRotation
rotationParent: desktop.parent rotationParent: desktop.parent
unrotatedItems: [lockScreen]
} }
orientation: Lipstick.compositor.screenOrientation orientation: Lipstick.compositor.screenOrientation
...@@ -94,13 +95,10 @@ Page { ...@@ -94,13 +95,10 @@ Page {
Connections { Connections {
target: LipstickSettings target: LipstickSettings
onLockscreenVisibleChanged: { onLockscreenVisibleChanged: {
if (lockscreenVisible()) { if (!lockscreenVisible())
glacierRotation.rotateRotationParent(nativeOrientation)
} else {
glacierRotation.rotateRotationParent(desktop.orientation) glacierRotation.rotateRotationParent(desktop.orientation)
} }
} }
}
function lockscreenVisible() { function lockscreenVisible() {
return LipstickSettings.lockscreenVisible === true return LipstickSettings.lockscreenVisible === true
......
...@@ -131,6 +131,8 @@ Compositor { ...@@ -131,6 +131,8 @@ Compositor {
property real swipeThreshold: 0.15 property real swipeThreshold: 0.15
property real lockThreshold: 0.25 property real lockThreshold: 0.25
property int lockscreenX
property int lockscreenY
onGestureStarted: { onGestureStarted: {
swipeAnimation.stop() swipeAnimation.stop()
...@@ -139,6 +141,8 @@ Compositor { ...@@ -139,6 +141,8 @@ Compositor {
if (root.appActive) { if (root.appActive) {
state = "swipe" state = "swipe"
} else if (root.homeActive) { } else if (root.homeActive) {
lockscreenX = Desktop.instance.lockscreen.x
lockscreenY = Desktop.instance.lockscreen.y
state = "lock" state = "lock"
} }
} }
...@@ -199,14 +203,22 @@ Compositor { ...@@ -199,14 +203,22 @@ Compositor {
} }
PropertyChanges { PropertyChanges {
target: Desktop.instance.lockscreen target: Desktop.instance.lockscreen
x: gestureArea.horizontal ? (Desktop.instance.lockscreenVisible()?(gestureArea.value): x: gestureArea.lockscreenX + ((gestureArea.horizontal) ? (Desktop.instance.lockscreenVisible()?(gestureArea.value) :
(gestureArea.gesture == "right" ? (gestureArea.gesture == "right" ?
-Desktop.instance.lockscreen.width+Math.abs(gestureArea.value) : ((Desktop.instance.lockscreen.width === topmostWindow.width) ?
Desktop.instance.lockscreen.width+gestureArea.value) ) : 0 -Desktop.instance.lockscreen.width :
y: gestureArea.horizontal ? 0 : (Desktop.instance.lockscreenVisible()?(gestureArea.value): -Desktop.instance.lockscreen.height)+Math.abs(gestureArea.value) :
((Desktop.instance.lockscreen.width === topmostWindow.width) ?
Desktop.instance.lockscreen.width :
Desktop.instance.lockscreen.height)+gestureArea.value) ) : 0 )
y: gestureArea.lockscreenY + ((gestureArea.horizontal) ? 0 : (Desktop.instance.lockscreenVisible()?(gestureArea.value) :
(gestureArea.gesture == "down" ? (gestureArea.gesture == "down" ?
-Desktop.instance.lockscreen.height+Math.abs(gestureArea.value) : ((Desktop.instance.lockscreen.width === topmostWindow.width) ?
Desktop.instance.lockscreen.height+gestureArea.value) ) -Desktop.instance.lockscreen.height :
-Desktop.instance.lockscreen.width)+Math.abs(gestureArea.value) :
((Desktop.instance.lockscreen.width === topmostWindow.width) ?
Desktop.instance.lockscreen.height :
Desktop.instance.lockscreen.width)+gestureArea.value) ) )
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment