Fixed bug #142 (Custom AR "cancel" button throwing error.)

Implemented req #141 (Use custom AR to specify exact resolution.)

Originally committed to SVN as r425.
This commit is contained in:
Niels Martin Hansen 2006-06-21 23:07:03 +00:00
parent c456f9dab8
commit f33dc46a5f
2 changed files with 28 additions and 9 deletions

View file

@ -1018,15 +1018,15 @@ 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(_T("Enter aspect ratio in either decimal (e.g. 2.35) or fractional (e.g. 16:9) form:"),_T("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 // Process text
double numval = 0.0; double numval = 0.0;
value.Replace(_T(","),_T(".")); if (value.Freq(_T(':')) == 1) {
if (value.Freq(_T('.')) == 1) { doNormalAR:
value.ToDouble(&numval);
}
else if (value.Freq(_T(':')) == 1) {
int pos = value.Find(_T(':')); int pos = value.Find(_T(':'));
wxString num = value.Left(pos); wxString num = value.Left(pos);
wxString denum = value.Mid(pos+1); wxString denum = value.Mid(pos+1);
@ -1037,9 +1037,27 @@ void FrameMain::OnSetARCustom (wxCommandEvent &event) {
if (b != 0) numval = a/b; if (b != 0) numval = a/b;
} }
} }
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 if (value.Freq(_T(':')) < 1) {
value.Append(_T(":1"));
goto doNormalAR;
}
// Sanity check // Sanity check
if (numval < 0.5 || numval > 5.0) wxMessageBox(_T("Invalid value! Aspect ratio must be between 0.5 and 5.0."),_T("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);
// Set value // Set value
else { else {

View file

@ -166,7 +166,8 @@ void VideoDisplay::SetVideo(const wxString &filename) {
// Choose a provider // Choose a provider
provider = VideoProvider::GetProvider(filename,GetTempWorkFile()); provider = VideoProvider::GetProvider(filename,GetTempWorkFile());
provider->SetZoom(zoomValue); provider->SetZoom(zoomValue);
provider->SetDAR(GetARFromType(arType)); if (arType != 4) arValue = GetARFromType(arType); // 4 = custom
provider->SetDAR(arValue);
KeyFrames.Clear(); KeyFrames.Clear();
@ -184,7 +185,7 @@ void VideoDisplay::SetVideo(const wxString &filename) {
// Ask to override timecodes // Ask to override timecodes
int override = wxYES; int override = wxYES;
if (VFR_Output.GetFrameRateType() == VFR) override = wxMessageBox(_T("You already have timecodes loaded. Replace them with the timecodes from the Matroska file?"),_T("Replace timecodes?"),wxYES_NO | wxICON_QUESTION); if (VFR_Output.IsLoaded()) override = wxMessageBox(_("You already have timecodes loaded. Replace them with the timecodes from the Matroska file?"),_("Replace timecodes?"),wxYES_NO | wxICON_QUESTION);
if (override == wxYES) MatroskaWrapper::wrapper.SetToTimecodes(VFR_Output); if (override == wxYES) MatroskaWrapper::wrapper.SetToTimecodes(VFR_Output);
// Close mkv // Close mkv