1
0
Fork 0

Fix a zooming bug on linux

The preview window would change in width, when the video was being zoomed.
Possibly, because on windows, zooming only calls UpdateSize once, but on
linux, it gets called multiple, like 8 times.
Rounding fixed it.
This commit is contained in:
moex3 2021-04-21 00:24:07 +02:00 committed by Sodra
parent 09ea0f54d3
commit 14d078fb9f
1 changed files with 5 additions and 4 deletions

View File

@ -330,11 +330,12 @@ void VideoDisplay::UpdateSize() {
wxWindow *top = GetParent();
while (!top->IsTopLevel()) top = top->GetParent();
wxSize cs = GetClientSize();
float csAr = (float)cs.GetWidth() / (float)cs.GetHeight();
wxSize oldClientSize = GetClientSize();
double csAr = (double)oldClientSize.GetWidth() / (double)oldClientSize.GetHeight();
wxSize newClientSize = wxSize(std::lround(provider->GetHeight() * csAr), provider->GetHeight()) * windowZoomValue / scale_factor;
wxSize oldSize = top->GetSize();
top->SetSize(top->GetSize() + wxSize(provider->GetHeight() * csAr, provider->GetHeight()) * windowZoomValue / scale_factor - cs);
SetClientSize(cs + top->GetSize() - oldSize);
top->SetSize(oldSize + (newClientSize - oldClientSize));
SetClientSize(oldClientSize + (top->GetSize() - oldSize));
}
else {
wxSize newSize = wxSize(provider->GetWidth(), provider->GetHeight()) * windowZoomValue / scale_factor;