From 85bed94731c75a5af333462b258c1c198b5ec2d9 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Sat, 27 Oct 2012 20:44:09 -0700 Subject: [PATCH] Fix some cases where the detached video dialog would get set to bogus sizes At very large and very small sizes, setting the window's size with SetSize may not actually result in the window changing to the requested size. Once this happened future adjustments to the size were incorrect, and the video display would sometimes not fit in the window, and on os x the window could get set to a negative size, with weird results. --- aegisub/src/video_display.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/aegisub/src/video_display.cpp b/aegisub/src/video_display.cpp index d2cfae86e..83d982064 100644 --- a/aegisub/src/video_display.cpp +++ b/aegisub/src/video_display.cpp @@ -320,8 +320,11 @@ void VideoDisplay::UpdateSize() { if (freeSize) { wxWindow *top = GetParent(); while (!top->IsTopLevel()) top = top->GetParent(); - top->SetSize(top->GetSize() + videoSize - GetClientSize()); - SetClientSize(videoSize); + + wxSize cs = GetClientSize(); + wxSize oldSize = top->GetSize(); + top->SetSize(top->GetSize() + videoSize - cs); + SetClientSize(cs + top->GetSize() - oldSize); } else { SetMinClientSize(videoSize); @@ -380,7 +383,7 @@ void VideoDisplay::OnKeyDown(wxKeyEvent &event) { void VideoDisplay::SetZoom(double value) { zoomValue = std::max(value, .125); - size_t selIndex = value / .125 - 1; + size_t selIndex = zoomValue / .125 - 1; if (selIndex < zoomBox->GetCount()) zoomBox->SetSelection(selIndex); zoomBox->ChangeValue(wxString::Format("%g%%", zoomValue * 100.));