Skip to content

Commit

Permalink
Keep rotation and scale when toggling stabilization
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianEddy committed Jun 7, 2022
1 parent 3c62671 commit c076468
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
11 changes: 6 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 15 additions & 1 deletion src/ui/VideoArea.qml
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ Item {
height: (w / ratio) > h? h : (w / ratio);
anchors.centerIn: parent;
opacity: da.containsDrag? 0.5 : 1.0;
clip: !vid.stabEnabled;

/*Image {
// Transparency grid
Expand All @@ -218,6 +219,19 @@ Item {
anchors.fill: parent;
property bool loaded: false;

property bool stabEnabled: true;
transform: [
Scale {
origin.x: vid.width / 2; origin.y: vid.height / 2;
xScale: vid.stabEnabled? 1 : vid.videoWidth / Math.max(1, root.outWidth);
yScale: vid.stabEnabled? 1 : vid.videoHeight / Math.max(1, root.outHeight);
},
Rotation {
origin.x: vid.width / 2; origin.y: vid.height / 2;
angle: vid.stabEnabled? 0 : -vidInfo.videoRotation;
}
]

function fovChanged() {
const fov = controller.get_current_fov();
// const ratio = controller.get_scaling_ratio(); // this shouldn't be called every frame because it locks the params mutex
Expand Down Expand Up @@ -485,7 +499,7 @@ Item {
SmallLinkButton {
id: stabEnabledBtn;
icon.name: "gyroflow";
onCheckedChanged: { controller.stab_enabled = checked; vid.forceRedraw(); vid.fovChanged(); }
onCheckedChanged: { vid.stabEnabled = checked; controller.stab_enabled = checked; vid.forceRedraw(); vid.fovChanged(); }
tooltip: qsTr("Toggle stabilization");
}

Expand Down
4 changes: 4 additions & 0 deletions src/ui/menu/Stabilization.qml
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,10 @@ MenuItem {
case 1: controller.adaptive_zoom = adaptiveZoom.value; break;
case 2: controller.adaptive_zoom = -1.0; break;
}
if (currentIndex == 0) {
zoomingCenterX.value = 0;
zoomingCenterY.value = 0;
}
}
}
Label {
Expand Down

0 comments on commit c076468

Please sign in to comment.