Skip to content
This repository has been archived by the owner on Nov 4, 2023. It is now read-only.

Commit

Permalink
Use shellContainer for animations and sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
capsia37 committed Aug 5, 2021
1 parent 7fea6c3 commit bb9bc8d
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 20 deletions.
13 changes: 7 additions & 6 deletions qml/OrientedShell.qml
Original file line number Diff line number Diff line change
Expand Up @@ -264,18 +264,19 @@ Item {
}

Item {
id: shellContainer
anchors.fill: parent
anchors.topMargin: !unity8Settings.disableTopMargin ? deviceConfiguration.topMargin : 0

Shell {
id: shell
objectName: "shell"
width: root.width
height: root.height
width: parent.width
height: parent.height
orientation: root.angleToOrientation(orientationAngle)
orientations: root.orientations
nativeWidth: root.width
nativeHeight: root.height
nativeWidth: parent.width
nativeHeight: parent.height
mode: applicationArguments.mode
hasMouse: pointerInputDevices > 0
hasKeyboard: keyboardsModel.count > 0
Expand Down Expand Up @@ -323,8 +324,8 @@ Item {
id: shellSnapshot
target: shell
visible: false
width: root.width
height: root.height
width: parent.width
height: parent.height

property real transformRotationAngle
property real transformOriginX
Expand Down
4 changes: 2 additions & 2 deletions qml/Rotation/HalfLoopRotationAnimation.qml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ SequentialAnimation {
ScriptAction { script: {
info.transitioning = true;
shell.orientationAngle = root.toAngle;
shell.x = (orientedShell.width - shell.width) / 2
shell.y = (orientedShell.height - shell.height) / 2;
shell.x = (shellContainer.width - shell.width) / 2
shell.y = (shellContainer.height - shell.height) / 2;
shell.transformOriginX = shell.width / 2;
shell.transformOriginY = shell.height / 2;
shell.updateFocusedAppOrientation();
Expand Down
12 changes: 6 additions & 6 deletions qml/Rotation/NinetyRotationAnimation.qml
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@ SequentialAnimation {
property var info
property var shell

readonly property real fromY: fromAngle === 0 || fromAngle === 90 ? 0 : orientedShell.height - orientedShell.width;
readonly property real toY: toAngle === 0 || toAngle === 90 ? 0 : orientedShell.height - orientedShell.width;
readonly property real fromY: fromAngle === 0 || fromAngle === 90 ? 0 : shellContainer.height - shellContainer.width;
readonly property real toY: toAngle === 0 || toAngle === 90 ? 0 : shellContainer.height - shellContainer.width;
readonly property bool flipShellDimensions: toAngle == 90 || toAngle == 270

ScriptAction { script: {
info.transitioning = true;

shell.orientationAngle = root.toAngle;
shell.x = 0;
shell.width = flipShellDimensions ? orientedShell.height : orientedShell.width;
shell.height = flipShellDimensions ? orientedShell.width : orientedShell.height;
shell.transformOriginX = orientedShell.width / 2;
shell.transformOriginY = orientedShell.width / 2;
shell.width = flipShellDimensions ? shellContainer.height : shellContainer.width;
shell.height = flipShellDimensions ? shellContainer.width : shellContainer.height;
shell.transformOriginX = shellContainer.width / 2;
shell.transformOriginY = shellContainer.width / 2;
shell.updateFocusedAppOrientation();
shellCover.visible = true;

Expand Down
13 changes: 7 additions & 6 deletions qml/Rotation/UpdateShellTransformations.qml
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,18 @@ ScriptAction {
shell.transformRotationAngle = rotationAngle;

// They must all be bindings as orientedShell's size can change
// ( shellContainer takes into account the margin in case a notch is present )

if (rotationAngle === 90 || rotationAngle === 270) {
shell.width = Qt.binding(function() { return orientedShell.height; });
shell.height = Qt.binding(function() { return orientedShell.width; });
shell.width = Qt.binding(function() { return shellContainer.height; });
shell.height = Qt.binding(function() { return shellContainer.width; });
} else {
shell.width = Qt.binding(function() { return orientedShell.width; });
shell.height = Qt.binding(function() { return orientedShell.height; });
shell.width = Qt.binding(function() { return shellContainer.width; });
shell.height = Qt.binding(function() { return shellContainer.height; });
}

shell.x = Qt.binding(function() { return (orientedShell.width - shell.width) / 2; });
shell.y = Qt.binding(function() { return (orientedShell.height - shell.height) / 2; });
shell.x = Qt.binding(function() { return (shellContainer.width - shell.width) / 2; });
shell.y = Qt.binding(function() { return (shellContainer.height - shell.height) / 2; });
shell.transformOriginX = Qt.binding(function() { return shell.width / 2; });
shell.transformOriginY = Qt.binding(function() { return shell.height / 2; });
}
Expand Down

0 comments on commit bb9bc8d

Please sign in to comment.