From eb938aa5edd4ff5fd49ab669db2421ac07b1646c Mon Sep 17 00:00:00 2001 From: Niels Martin Hansen Date: Sat, 12 Dec 2009 01:38:09 +0000 Subject: [PATCH] Check video size on open and change zoom level to 50% or 25% if the video is greater than some proportions of the window size. Updates #1054. Originally committed to SVN as r3858. --- aegisub/src/frame_main.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/aegisub/src/frame_main.cpp b/aegisub/src/frame_main.cpp index e065c92d3..d469b5fa6 100644 --- a/aegisub/src/frame_main.cpp +++ b/aegisub/src/frame_main.cpp @@ -1159,11 +1159,22 @@ void FrameMain::LoadVideo(wxString file,bool autoload) { wxMessageBox(_T("Unknown error"), _T("Error opening video file"), wxOK | wxICON_ERROR, this); } - // Check that the video size matches the script video size specified if (VideoContext::Get()->IsLoaded()) { + int vidx = VideoContext::Get()->GetWidth(), vidy = VideoContext::Get()->GetHeight(); + + // Set zoom level based on video resolution and window size + int target_zoom = 7; // 100% + wxSize windowSize = GetSize(); + if (vidx*3 > windowSize.GetX()*2 || vidy*4 > windowSize.GetY()*3) + target_zoom = 3; // 50% + if (vidx*3 > windowSize.GetX()*4 || vidy*4 > windowSize.GetY()*6) + target_zoom = 1; // 25% + videoBox->videoDisplay->zoomBox->SetSelection(target_zoom); + videoBox->videoDisplay->SetZoomPos(target_zoom); + + // Check that the video size matches the script video size specified int scriptx = SubsBox->ass->GetScriptInfoAsInt(_T("PlayResX")); int scripty = SubsBox->ass->GetScriptInfoAsInt(_T("PlayResY")); - int vidx = VideoContext::Get()->GetWidth(), vidy = VideoContext::Get()->GetHeight(); if (scriptx != vidx || scripty != vidy) { switch (Options.AsInt(_T("Video Check Script Res"))) { case 1: