incoming patches from Dansolo; fix aspect ratio bug & minor kanjitimer issue

Originally committed to SVN as r785.
This commit is contained in:
David Lamparter 2007-01-13 08:34:42 +00:00
parent f470100ccd
commit 8bae6a855a
2 changed files with 24 additions and 27 deletions

View file

@ -56,6 +56,7 @@ DialogKanjiTimer::DialogKanjiTimer(wxWindow *parent, SubtitlesGrid *_grid)
AssFile *subs = AssFile::top; AssFile *subs = AssFile::top;
grid = _grid; grid = _grid;
vid = grid->video; vid = grid->video;
RegroupSourceSelected = 0;
//Sizers //Sizers
wxSizer *ResBoxSizer1 = new wxStaticBoxSizer(wxVERTICAL,this,_("Text")); wxSizer *ResBoxSizer1 = new wxStaticBoxSizer(wxVERTICAL,this,_("Text"));

View file

@ -1200,43 +1200,39 @@ void FrameMain::OnSetAR235 (wxCommandEvent &event) {
void FrameMain::OnSetARCustom (wxCommandEvent &event) { void FrameMain::OnSetARCustom (wxCommandEvent &event) {
// Get text // Get text
videoBox->videoDisplay->Stop(); 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; if (value.IsEmpty()) return;
value.MakeLower(); value.MakeLower();
// Process text // Process text
double numval = 0.0; double numval = 0.0;
if (value.Freq(_T(':')) == 1) { if (value.ToDouble(&numval)) {
doNormalAR: //Nothing to see here, move along
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;
}
} }
else if (value.Freq(_T('x')) == 1) { else {
int pos = value.Find(_T('x')); double a,b;
wxString width = value.Left(pos); int pos=0;
wxString height = value.Mid(pos+1); bool scale=false;
if (width.IsNumber() && height.IsNumber()) {
double w,h; //Why bloat using Contains when we can just check the output of Find?
width.ToDouble(&w); pos = value.Find(':');
height.ToDouble(&h); if (pos==wxNOT_FOUND) pos = value.Find('/');
if (h != 0) { if (pos==wxNOT_FOUND&&value.Contains(_T('x'))) {
numval = w/h; pos = value.Find('x');
videoBox->videoDisplay->SetZoom(h / videoBox->videoDisplay->h); 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 // 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); 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);