From 98d476102eebd669896db89f783a79e0207a190f Mon Sep 17 00:00:00 2001 From: arch1t3cht Date: Tue, 23 Aug 2022 04:44:42 +0200 Subject: [PATCH] video zoom: Fix aspect ratio forcing Do this by partially reverting the changes to UpdateSize in favor of just multiplying by videoZoomValue *after* setting all the window sizes. --- src/video_display.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/video_display.cpp b/src/video_display.cpp index 3ceb12083..f4d899847 100644 --- a/src/video_display.cpp +++ b/src/video_display.cpp @@ -323,7 +323,9 @@ void VideoDisplay::UpdateSize() { if (!provider || !IsShownOnScreen()) return; videoSize.Set(provider->GetWidth(), provider->GetHeight()); - videoSize *= videoZoomValue * windowZoomValue; + videoSize *= windowZoomValue; + if (con->videoController->GetAspectRatioType() != AspectRatio::Default) + videoSize.SetWidth(videoSize.GetHeight() * con->videoController->GetAspectRatioValue()); wxEventBlocker blocker(this); if (freeSize) { @@ -338,12 +340,12 @@ void VideoDisplay::UpdateSize() { SetClientSize(oldClientSize + (top->GetSize() - oldSize)); } else { - wxSize newSize = wxSize(provider->GetWidth(), provider->GetHeight()) * windowZoomValue / scale_factor; - SetMinClientSize(newSize); - SetMaxClientSize(newSize); + SetMinClientSize(videoSize / scale_factor); + SetMaxClientSize(videoSize / scale_factor); GetGrandParent()->Layout(); } + videoSize *= videoZoomValue; PositionVideo(); } @@ -477,7 +479,10 @@ void VideoDisplay::SetVideoZoom(int step) { int pixelChangeW = std::lround(videoSize.GetWidth() * (newVideoZoom / videoZoomValue - 1.0)); int pixelChangeH = std::lround(videoSize.GetHeight() * (newVideoZoom / videoZoomValue - 1.0)); - pan_x -= pixelChangeW * (mp.X() / videoSize.GetWidth()); + AsyncVideoProvider *provider = con->project->VideoProvider(); + double arfactor = (double) provider->GetHeight() * (double) videoSize.GetWidth() / (double) provider->GetWidth() / (double) videoSize.GetHeight(); + + pan_x -= pixelChangeW * (mp.X() / videoSize.GetWidth() * arfactor); pan_y -= pixelChangeH * (mp.Y() / videoSize.GetHeight()); videoZoomValue = newVideoZoom;