From 8bae6a855a14e23dd5a2a42e4d4b15e3bed0c24d Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Sat, 13 Jan 2007 08:34:42 +0000 Subject: [PATCH] incoming patches from Dansolo; fix aspect ratio bug & minor kanjitimer issue Originally committed to SVN as r785. --- aegisub/dialog_kanji_timer.cpp | 1 + aegisub/frame_main_events.cpp | 50 ++++++++++++++++------------------ 2 files changed, 24 insertions(+), 27 deletions(-) diff --git a/aegisub/dialog_kanji_timer.cpp b/aegisub/dialog_kanji_timer.cpp index 509836680..3611d8097 100644 --- a/aegisub/dialog_kanji_timer.cpp +++ b/aegisub/dialog_kanji_timer.cpp @@ -56,6 +56,7 @@ DialogKanjiTimer::DialogKanjiTimer(wxWindow *parent, SubtitlesGrid *_grid) AssFile *subs = AssFile::top; grid = _grid; vid = grid->video; + RegroupSourceSelected = 0; //Sizers wxSizer *ResBoxSizer1 = new wxStaticBoxSizer(wxVERTICAL,this,_("Text")); diff --git a/aegisub/frame_main_events.cpp b/aegisub/frame_main_events.cpp index 84c8768d0..bbb3b61f0 100644 --- a/aegisub/frame_main_events.cpp +++ b/aegisub/frame_main_events.cpp @@ -1200,43 +1200,39 @@ void FrameMain::OnSetAR235 (wxCommandEvent &event) { void FrameMain::OnSetARCustom (wxCommandEvent &event) { // Get text videoBox->videoDisplay->Stop(); - wxString value = wxGetTextFromUser(_("Enter aspect ratio in either decimal (e.g. 2.35) or fractional (e.g. 16:9) form. Enter a value like 853x480 to set a specific resolution."),_("Enter aspect ratio"),FloatToString(videoBox->videoDisplay->GetAspectRatioValue())); + wxString value = wxGetTextFromUser(_("Enter aspect ratio in either decimal (e.g. 2.35) or fractional (e.g. 16:9) form. Enter a value like 853x480 to set a specific resolution."),_("Enter aspect ratio"),FloatToString(videoBox->videoDisplay->GetAspectRatioValue())); if (value.IsEmpty()) return; + value.MakeLower(); // Process text double numval = 0.0; - if (value.Freq(_T(':')) == 1) { -doNormalAR: - int pos = value.Find(_T(':')); - wxString num = value.Left(pos); - wxString denum = value.Mid(pos+1); - if (num.IsNumber() && denum.IsNumber()) { - double a,b; - num.ToDouble(&a); - denum.ToDouble(&b); - if (b != 0) numval = a/b; - } + if (value.ToDouble(&numval)) { + //Nothing to see here, move along } - else if (value.Freq(_T('x')) == 1) { - int pos = value.Find(_T('x')); - wxString width = value.Left(pos); - wxString height = value.Mid(pos+1); - if (width.IsNumber() && height.IsNumber()) { - double w,h; - width.ToDouble(&w); - height.ToDouble(&h); - if (h != 0) { - numval = w/h; - videoBox->videoDisplay->SetZoom(h / videoBox->videoDisplay->h); + else { + double a,b; + int pos=0; + bool scale=false; + + //Why bloat using Contains when we can just check the output of Find? + pos = value.Find(':'); + if (pos==wxNOT_FOUND) pos = value.Find('/'); + if (pos==wxNOT_FOUND&&value.Contains(_T('x'))) { + pos = value.Find('x'); + scale=true; + } + + if (pos>0) { + wxString num = value.Left(pos); + wxString denum = value.Mid(pos+1); + if (num.ToDouble(&a) && denum.ToDouble(&b) && b!=0) { + numval = a/b; + if (scale) videoBox->videoDisplay->SetZoom(b / videoBox->videoDisplay->h); } } } - else if (value.Freq(_T(':')) < 1) { - value.Append(_T(":1")); - goto doNormalAR; - } // Sanity check if (numval < 0.5 || numval > 5.0) wxMessageBox(_("Invalid value! Aspect ratio must be between 0.5 and 5.0."),_("Invalid Aspect Ratio"),wxICON_ERROR);