Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
glacier-home
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
NemoMobile
glacier-home
Commits
5238406a
Commit
5238406a
authored
Nov 21, 2014
by
Filip Matijević
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[rotation] simplify rotation code by using mapToItem
parent
9bbe3191
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
27 deletions
+8
-27
GlacierRotation.qml
src/qml/GlacierRotation.qml
+8
-27
No files found.
src/qml/GlacierRotation.qml
View file @
5238406a
...
...
@@ -35,12 +35,6 @@ import org.nemomobile.lipstick 0.1
Item
{
QtObject
{
id
:
privateProperties
property
int
nativeRotation
:
Screen
.
angleBetween
(
nativeOrientation
,
Screen
.
primaryOrientation
)
property
bool
nativeIsPortrait
:
((
nativeRotation
===
0
)
||
(
nativeRotation
===
180
))
}
property
Item
rotationParent
function
rotateRotationParent
(
o
)
{
...
...
@@ -48,28 +42,15 @@ Item {
}
function
rotateObject
(
obj
,
o
)
{
var
r
=
Screen
.
angleBetween
(
o
,
Screen
.
primaryOrientation
)
if
(
obj
.
rotation
!==
r
)
{
var
isPortrait
=
((
r
===
0
)
||
(
r
===
180
))
var
correction
=
0
var
isNative
=
((
privateProperties
.
nativeIsPortrait
||
isPortrait
)
&&
!
(
privateProperties
.
nativeIsPortrait
&&
isPortrait
))
//xor
var
diff
=
Math
.
abs
(
r
-
obj
.
rotation
)
//xor
if
((
isNative
||
!
privateProperties
.
nativeIsPortrait
)
&&
!
(
isNative
&&
!
privateProperties
.
nativeIsPortrait
))
{
correction
=
obj
.
width
/
2
-
obj
.
height
/
2
if
(
diff
===
180
)
correction
=
-
correction
if
(
obj
.
rotation
!==
r
)
rotateObjectToAngle
(
obj
,
r
)
}
function
rotateObjectToAngle
(
obj
,
r
)
{
obj
.
width
=
Screen
.
width
;
obj
.
height
=
Screen
.
height
;
obj
.
x
=
0
;
obj
.
y
=
0
obj
.
rotation
=
r
if
((
diff
===
90
)
||
(
diff
===
270
))
{
var
w
=
obj
.
width
obj
.
width
=
obj
.
height
obj
.
height
=
w
}
obj
.
x
=
correction
obj
.
y
=
-
correction
}
var
res
=
obj
.
mapToItem
(
rotationParent
.
parent
,
0
,
0
,
obj
.
width
,
obj
.
height
)
obj
.
x
=
res
.
x
;
obj
.
y
=
res
.
y
;
obj
.
width
=
res
.
width
;
obj
.
height
=
res
.
height
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment