diff --git a/src/dialog_about.cpp b/src/dialog_about.cpp index d56de1148..217fe358c 100644 --- a/src/dialog_about.cpp +++ b/src/dialog_about.cpp @@ -40,114 +40,102 @@ #include #include -namespace { -struct AboutScreen : wxDialog { - AboutScreen(wxWindow *parent) - : wxDialog(parent, -1, _("About Aegisub"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX, _("About Aegisub")) - { - // Generate library string - wxString libString = "Aegisub includes portions from the following other projects:\n"; - libString += " wxWidgets - Copyright (c) Julian Smart, Robert Roebling et al;\n"; - libString += " wxStyledTextCtrl - Copyright (c) Robin Dunn, Neil Hodgson;\n"; - libString += " Scintilla - Copyright (c) Neil Hodgson;\n"; - libString += " Boost - Copyright (c) Beman Dawes, David Abrahams et al;\n"; - libString += " UniversalCharDet - Copyright (c) Netscape Communications Corp.;\n"; - libString += " ICU - Copyright (c) International Business Machines Corp.;\n"; - libString += " Lua - Copyright (c) Lua.org, PUC-Rio;\n"; - libString += " LuaJIT - Copyright (c) Mike Pall;\n"; - libString += " luabins - Copyright (c) Alexander Gladysh;\n"; +void ShowAboutDialog(wxWindow *parent) { + wxDialog d(parent, -1, _("About Aegisub"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX); + + wxString translatorCredit = _("Translated into LANGUAGE by PERSON\n"); + if (translatorCredit == "Translated into LANGUAGE by PERSON\n") + translatorCredit.clear(); + + // Generate about string + wxString aboutString = wxString("Aegisub ") + GetAegisubShortVersionString() + ".\n" + "Copyright (c) 2005-2014 Rodrigo Braz Monteiro, Niels Martin Hansen, Thomas Goyne et al.\n\n" + "Programmers:\n" + " Alysson Souza e Silva\n" + " Amar Takhar\n" + " Dan Donovan\n" + " Daniel Moscoviter\n" + " David Conrad\n" + " David Lamparter\n" + " Eric Batalitzky\n" + " Evgeniy Stepanov\n" + " Fredrik Mellbin\n" + " Grigori Goronzy\n" + " Karl Blomster\n" + " Mike Matsnev\n" + " Moritz Brunner\n" + " Muhammad Lukman Nasaruddin\n" + " Niels Martin Hansen\n" + " Patryk Pomykalski\n" + " Ravi Pinjala\n" + " Rodrigo Braz Monteiro\n" + " Simone Cociancich\n" + " Thomas Goyne\n" + "User manual written by:\n" + " Karl Blomster\n" + " Niels Martin Hansen\n" + " Rodrigo Braz Monteiro\n" + "Icons by:\n" + " Philip Cash\n" + "Additional thanks to:\n" + " Mentar\n" + " Sigurd Tao Lyngse\n" + " Everyone in the Aegisub IRC channel\n" + " Everyone who ever reported a bug\n" + + translatorCredit + "\n" + "Aegisub includes portions from the following other projects:\n" + " wxWidgets - Copyright (c) Julian Smart, Robert Roebling et al;\n" + " wxStyledTextCtrl - Copyright (c) Robin Dunn, Neil Hodgson;\n" + " Scintilla - Copyright (c) Neil Hodgson;\n" + " Boost - Copyright (c) Beman Dawes, David Abrahams et al;\n" + " UniversalCharDet - Copyright (c) Netscape Communications Corp.;\n" + " ICU - Copyright (c) International Business Machines Corp.;\n" + " Lua - Copyright (c) Lua.org, PUC-Rio;\n" + " LuaJIT - Copyright (c) Mike Pall;\n" + " luabins - Copyright (c) Alexander Gladysh;\n" #ifdef WITH_HUNSPELL - libString += " Hunspell - Copyright (c) Kevin Hendricks;\n"; + " Hunspell - Copyright (c) Kevin Hendricks;\n" #endif #ifdef WITH_PORTAUDIO - libString += " PortAudio - Copyright (c) Ross Bencina, Phil Burk;\n"; + " PortAudio - Copyright (c) Ross Bencina, Phil Burk;\n" #endif #ifdef WITH_FFMS2 - libString += " FFmpeg - Copyright (c) Fabrice Bellard;\n"; - libString += " FFMS2 - Copyright (c) Fredrik Mellbin;\n"; + " FFmpeg - Copyright (c) Fabrice Bellard;\n" + " FFMS2 - Copyright (c) Fredrik Mellbin;\n" #endif #ifdef WITH_AVISYNTH - libString += " Avisynth 2.5 - Copyright (c) Ben Rudiak-Gould et al;\n"; + " Avisynth 2.5 - Copyright (c) Ben Rudiak-Gould et al;\n" #endif #ifdef WITH_CSRI - libString += " csri - Copyright (c) David Lamparter;\n"; + " csri - Copyright (c) David Lamparter;\n" # ifdef __WINDOWS__ - libString += " vsfilter - Copyright (c) Gabest et al;\n"; + " vsfilter - Copyright (c) Gabest et al;\n" # endif #endif - libString += " libass - Copyright (c) Evgeniy Stepanov, Grigori Goronzy;\n"; -#ifdef __WINDOWS__ - libString += " Matroska Parser - Copyright (c) Mike Matsnev;\n"; -#endif - libString += " Freetype - Copyright (c) David Turner, Robert Wilhelm, Werner Lemberg;\n"; - libString += " Fontconfig - Copyright (c) Keith Packard et al;\n"; + " libass - Copyright (c) Evgeniy Stepanov, Grigori Goronzy;\n" + " Matroska Parser - Copyright (c) Mike Matsnev;\n" + " Freetype - Copyright (c) David Turner, Robert Wilhelm, Werner Lemberg;\n" + " Fontconfig - Copyright (c) Keith Packard et al;\n" #ifdef WITH_FFTW3 - libString += " FFTW - Copyright (c) Matteo Frigo, Massachusetts Institute of Technology;\n"; + " FFTW - Copyright (c) Matteo Frigo, Massachusetts Institute of Technology;\n" #endif + + _("\nSee the help file for full credits.\n") + + fmt_tl("Built by %s on %s.", GetAegisubBuildCredit(), GetAegisubBuildTime()); - wxString translatorCredit = _("Translated into LANGUAGE by PERSON\n"); - if (translatorCredit == "Translated into LANGUAGE by PERSON\n") translatorCredit.Clear(); + // Replace copyright symbol + wxChar copySymbol = 0xA9; + aboutString.Replace("(c)", wxString(copySymbol)); - // Generate about string - wxString aboutString; - aboutString += wxString("Aegisub ") + GetAegisubShortVersionString() + ".\n"; - aboutString += "Copyright (c) 2005-2014 Rodrigo Braz Monteiro, Niels Martin Hansen, Thomas Goyne et al.\n\n"; - aboutString += "Programmers:\n"; - aboutString += " Alysson Souza e Silva\n"; - aboutString += " Amar Takhar\n"; - aboutString += " Dan Donovan\n"; - aboutString += " Daniel Moscoviter\n"; - aboutString += " David Conrad\n"; - aboutString += " David Lamparter\n"; - aboutString += " Eric Batalitzky\n"; - aboutString += " Evgeniy Stepanov\n"; - aboutString += " Fredrik Mellbin\n"; - aboutString += " Grigori Goronzy\n"; - aboutString += " Karl Blomster\n"; - aboutString += " Mike Matsnev\n"; - aboutString += " Moritz Brunner\n"; - aboutString += " Muhammad Lukman Nasaruddin\n"; - aboutString += " Niels Martin Hansen\n"; - aboutString += " Patryk Pomykalski\n"; - aboutString += " Ravi Pinjala\n"; - aboutString += " Rodrigo Braz Monteiro\n"; - aboutString += " Simone Cociancich\n"; - aboutString += " Thomas Goyne\n"; - aboutString += "User manual written by:\n"; - aboutString += " Karl Blomster\n"; - aboutString += " Niels Martin Hansen\n"; - aboutString += " Rodrigo Braz Monteiro\n"; - aboutString += "Icons by:\n"; - aboutString += " Philip Cash\n"; - aboutString += "Additional thanks to:\n"; - aboutString += " Mentar\n"; - aboutString += " Sigurd Tao Lyngse\n"; - aboutString += " Everyone in the Aegisub IRC channel\n"; - aboutString += " Everyone who ever reported a bug\n"; - aboutString += translatorCredit; - aboutString += "\n" + libString; - aboutString += _("\nSee the help file for full credits.\n"); - aboutString += fmt_tl("Built by %s on %s.", GetAegisubBuildCredit(), GetAegisubBuildTime()); + wxTextCtrl *textctrl = new wxTextCtrl(&d, -1, aboutString, wxDefaultPosition, wxSize(-1, 200), wxTE_MULTILINE | wxTE_READONLY | wxBORDER_NONE); - // Replace copyright symbol - wxChar copySymbol = 0xA9; - aboutString.Replace("(c)", wxString(copySymbol)); + wxSizer *MainSizer = new wxBoxSizer(wxVERTICAL); + MainSizer->Add(new wxStaticBitmap(&d, -1, GETIMAGE(splash)), 0, wxCENTER, 0); + MainSizer->Add(new wxStaticLine(&d, wxID_ANY), 0, wxEXPAND | wxALL, 0); + MainSizer->Add(textctrl, 0, wxEXPAND | wxALL, 0); + MainSizer->Add(new wxStaticLine(&d, wxID_ANY), 0, wxEXPAND | wxALL, 0); + MainSizer->Add(d.CreateButtonSizer(wxOK), 0, wxEXPAND | wxALL, 6); - wxTextCtrl *textctrl = new wxTextCtrl(this, -1, aboutString, wxDefaultPosition, wxSize(-1, 200), wxTE_MULTILINE | wxTE_READONLY | wxBORDER_NONE); - - wxSizer *MainSizer = new wxBoxSizer(wxVERTICAL); - MainSizer->Add(new wxStaticBitmap(this, -1, GETIMAGE(splash)), 0, wxCENTER, 0); - MainSizer->Add(new wxStaticLine(this, wxID_ANY), 0, wxEXPAND | wxALL, 0); - MainSizer->Add(textctrl, 0, wxEXPAND | wxALL, 0); - MainSizer->Add(new wxStaticLine(this, wxID_ANY), 0, wxEXPAND | wxALL, 0); - MainSizer->Add(CreateButtonSizer(wxOK), 0, wxEXPAND | wxALL, 6); - - SetSizerAndFit(MainSizer); - CentreOnParent(); - } -}; -} - -void ShowAboutDialog(wxWindow *parent) { - AboutScreen(parent).ShowModal(); + d.SetSizerAndFit(MainSizer); + d.CentreOnParent(); + d.ShowModal(); } diff --git a/src/dialog_attachments.cpp b/src/dialog_attachments.cpp index 4e20be6cd..706b202d2 100644 --- a/src/dialog_attachments.cpp +++ b/src/dialog_attachments.cpp @@ -43,7 +43,8 @@ #include namespace { -class DialogAttachments final : public wxDialog { +struct DialogAttachments { + wxDialog d; AssFile *ass; wxListView *listView; @@ -64,18 +65,18 @@ public: }; DialogAttachments::DialogAttachments(wxWindow *parent, AssFile *ass) -: wxDialog(parent, -1, _("Attachment List"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE) +: d(parent, -1, _("Attachment List")) , ass(ass) { - SetIcon(GETICON(attach_button_16)); + d.SetIcon(GETICON(attach_button_16)); - listView = new wxListView(this, -1, wxDefaultPosition, wxSize(500, 200)); + listView = new wxListView(&d, -1, wxDefaultPosition, wxSize(500, 200)); UpdateList(); - auto attachFont = new wxButton(this, -1, _("Attach &Font")); - auto attachGraphics = new wxButton(this, -1, _("Attach &Graphics")); - extractButton = new wxButton(this, -1, _("E&xtract")); - deleteButton = new wxButton(this, -1, _("&Delete")); + auto attachFont = new wxButton(&d, -1, _("Attach &Font")); + auto attachGraphics = new wxButton(&d, -1, _("Attach &Graphics")); + extractButton = new wxButton(&d, -1, _("E&xtract")); + deleteButton = new wxButton(&d, -1, _("&Delete")); extractButton->Enable(false); deleteButton->Enable(false); @@ -84,14 +85,14 @@ DialogAttachments::DialogAttachments(wxWindow *parent, AssFile *ass) buttonSizer->Add(attachGraphics, 1); buttonSizer->Add(extractButton, 1); buttonSizer->Add(deleteButton, 1); - buttonSizer->Add(new HelpButton(this, "Attachment Manager"), 1, wxLEFT, 5); - buttonSizer->Add(new wxButton(this, wxID_CANCEL, _("&Close")), 1); + buttonSizer->Add(new HelpButton(&d, "Attachment Manager"), 1, wxLEFT, 5); + buttonSizer->Add(new wxButton(&d, wxID_CANCEL, _("&Close")), 1); auto mainSizer = new wxBoxSizer(wxVERTICAL); mainSizer->Add(listView, 1, wxTOP | wxLEFT | wxRIGHT | wxEXPAND, 5); mainSizer->Add(buttonSizer, 0, wxALL | wxEXPAND, 5); - SetSizerAndFit(mainSizer); - CenterOnParent(); + d.SetSizerAndFit(mainSizer); + d.CenterOnParent(); attachFont->Bind(wxEVT_BUTTON, &DialogAttachments::OnAttachFont, this); attachGraphics->Bind(wxEVT_BUTTON, &DialogAttachments::OnAttachGraphics, this); @@ -133,7 +134,7 @@ void DialogAttachments::AttachFile(wxFileDialog &diag, wxString const& commit_ms } void DialogAttachments::OnAttachFont(wxCommandEvent &) { - wxFileDialog diag(this, + wxFileDialog diag(&d, _("Choose file to be attached"), to_wx(OPT_GET("Path/Fonts Collector Destination")->GetString()), "", "Font Files (*.ttf)|*.ttf", wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_MULTIPLE); @@ -142,7 +143,7 @@ void DialogAttachments::OnAttachFont(wxCommandEvent &) { } void DialogAttachments::OnAttachGraphics(wxCommandEvent &) { - wxFileDialog diag(this, + wxFileDialog diag(&d, _("Choose file to be attached"), "", "", "Graphic Files (*.bmp, *.gif, *.jpg, *.ico, *.wmf)|*.bmp;*.gif;*.jpg;*.ico;*.wmf", @@ -167,7 +168,7 @@ void DialogAttachments::OnExtract(wxCommandEvent &) { "Path/Fonts Collector Destination", ass->Attachments[i].GetFileName(), ".ttf", "Font Files (*.ttf)|*.ttf", - this); + &d); fullPath = true; } if (path.empty()) return; @@ -200,5 +201,5 @@ void DialogAttachments::OnListClick(wxListEvent &) { } void ShowAttachmentsDialog(wxWindow *parent, AssFile *file) { - DialogAttachments(parent, file).ShowModal(); + DialogAttachments(parent, file).d.ShowModal(); } diff --git a/src/dialog_autosave.cpp b/src/dialog_autosave.cpp index 73981005f..c5a5f61cb 100644 --- a/src/dialog_autosave.cpp +++ b/src/dialog_autosave.cpp @@ -45,7 +45,8 @@ struct AutosaveFile { std::vector versions; }; -class DialogAutosave final : public wxDialog { +class DialogAutosave { + wxDialog d; std::vector files; wxListBox *file_list; @@ -57,34 +58,36 @@ class DialogAutosave final : public wxDialog { public: DialogAutosave(wxWindow *parent); std::string ChosenFile() const; + + int ShowModal() { return d.ShowModal(); } }; DialogAutosave::DialogAutosave(wxWindow *parent) -: wxDialog(parent, -1, _("Open autosave file"), wxDefaultPosition, wxSize(800, 350), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) +: d(parent, -1, _("Open autosave file"), wxDefaultPosition, wxSize(800, 350), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) { - SetIcon(GETICON(open_toolbutton_16)); + d.SetIcon(GETICON(open_toolbutton_16)); - wxSizer *files_box = new wxStaticBoxSizer(wxVERTICAL, this, _("Files")); - file_list = new wxListBox(this, -1); + wxSizer *files_box = new wxStaticBoxSizer(wxVERTICAL, &d, _("Files")); + file_list = new wxListBox(&d, -1); file_list->Bind(wxEVT_LISTBOX, &DialogAutosave::OnSelectFile, this); files_box->Add(file_list, wxSizerFlags(1).Expand().Border()); - wxSizer *versions_box = new wxStaticBoxSizer(wxVERTICAL, this, _("Versions")); - version_list = new wxListBox(this, -1); - version_list->Bind(wxEVT_LISTBOX_DCLICK, [=](wxCommandEvent&) { EndModal(wxID_OK); }); + wxSizer *versions_box = new wxStaticBoxSizer(wxVERTICAL, &d, _("Versions")); + version_list = new wxListBox(&d, -1); + version_list->Bind(wxEVT_LISTBOX_DCLICK, [=](wxCommandEvent&) { d.EndModal(wxID_OK); }); versions_box->Add(version_list, wxSizerFlags(1).Expand().Border()); wxSizer *boxes_sizer = new wxBoxSizer(wxHORIZONTAL); boxes_sizer->Add(files_box, wxSizerFlags(1).Expand().Border()); boxes_sizer->Add(versions_box, wxSizerFlags(1).Expand().Border()); - wxStdDialogButtonSizer *btn_sizer = CreateStdDialogButtonSizer(wxOK | wxCANCEL); + auto *btn_sizer = d.CreateStdDialogButtonSizer(wxOK | wxCANCEL); btn_sizer->GetAffirmativeButton()->SetLabelText(_("Open")); wxSizer *main_sizer = new wxBoxSizer(wxVERTICAL); main_sizer->Add(boxes_sizer, wxSizerFlags(1).Expand().Border()); main_sizer->Add(btn_sizer, wxSizerFlags().Expand().Border(wxALL & ~wxTOP)); - SetSizer(main_sizer); + d.SetSizer(main_sizer); std::map files_map; Populate(files_map, OPT_GET("Path/Auto/Save")->GetString(), ".AUTOSAVE.ass", "%s"); diff --git a/src/dialog_dummy_video.cpp b/src/dialog_dummy_video.cpp index d46e6f53d..9338a54a9 100644 --- a/src/dialog_dummy_video.cpp +++ b/src/dialog_dummy_video.cpp @@ -37,7 +37,9 @@ #include namespace { -struct DialogDummyVideo final : wxDialog { +struct DialogDummyVideo { + wxDialog d; + double fps = OPT_GET("Video/Dummy/FPS")->GetDouble(); int width = OPT_GET("Video/Dummy/Last/Width")->GetInt(); int height = OPT_GET("Video/Dummy/Last/Height")->GetInt(); @@ -98,45 +100,45 @@ wxComboBox *resolution_shortcuts(wxWindow *parent, int width, int height) { } DialogDummyVideo::DialogDummyVideo(wxWindow *parent) -: wxDialog(parent, -1, _("Dummy video options")) +: d(parent, -1, _("Dummy video options")) { - SetIcon(GETICON(use_dummy_video_menu_16)); + d.SetIcon(GETICON(use_dummy_video_menu_16)); auto res_sizer = new wxBoxSizer(wxHORIZONTAL); - res_sizer->Add(spin_ctrl(this, 1, 10000, &width), wxSizerFlags(1).Expand()); - res_sizer->Add(new wxStaticText(this, -1, " x "), wxSizerFlags().Center()); - res_sizer->Add(spin_ctrl(this, 1, 10000, &height), wxSizerFlags(1).Expand()); + res_sizer->Add(spin_ctrl(&d, 1, 10000, &width), wxSizerFlags(1).Expand()); + res_sizer->Add(new wxStaticText(&d, -1, " x "), wxSizerFlags().Center()); + res_sizer->Add(spin_ctrl(&d, 1, 10000, &height), wxSizerFlags(1).Expand()); auto color_sizer = new wxBoxSizer(wxHORIZONTAL); - auto color_btn = new ColourButton(this, wxSize(30, 17), false, color); + auto color_btn = new ColourButton(&d, wxSize(30, 17), false, color); color_sizer->Add(color_btn, wxSizerFlags().DoubleBorder(wxRIGHT)); - color_sizer->Add(new wxCheckBox(this, -1, _("Checkerboard &pattern"), wxDefaultPosition, wxDefaultSize, 0, wxGenericValidator(&pattern)), wxSizerFlags(1).Center()); + color_sizer->Add(new wxCheckBox(&d, -1, _("Checkerboard &pattern"), wxDefaultPosition, wxDefaultSize, 0, wxGenericValidator(&pattern)), wxSizerFlags(1).Center()); sizer = new wxFlexGridSizer(2, 5, 5); - AddCtrl(_("Video resolution:"), resolution_shortcuts(this, width, height)); + AddCtrl(_("Video resolution:"), resolution_shortcuts(&d, width, height)); AddCtrl("", res_sizer); AddCtrl(_("Color:"), color_sizer); - AddCtrl(_("Frame rate (fps):"), spin_ctrl(this, .1, 1000.0, &fps)); - AddCtrl(_("Duration (frames):"), spin_ctrl(this, 2, 36000000, &length)); // Ten hours of 1k FPS - AddCtrl("", length_display = new wxStaticText(this, -1, "")); + AddCtrl(_("Frame rate (fps):"), spin_ctrl(&d, .1, 1000.0, &fps)); + AddCtrl(_("Duration (frames):"), spin_ctrl(&d, 2, 36000000, &length)); // Ten hours of 1k FPS + AddCtrl("", length_display = new wxStaticText(&d, -1, "")); - wxStdDialogButtonSizer *btn_sizer = CreateStdDialogButtonSizer(wxOK | wxCANCEL | wxHELP); + auto btn_sizer = d.CreateStdDialogButtonSizer(wxOK | wxCANCEL | wxHELP); btn_sizer->GetHelpButton()->Bind(wxEVT_BUTTON, std::bind(&HelpButton::OpenPage, "Dummy Video")); auto main_sizer = new wxBoxSizer(wxVERTICAL); main_sizer->Add(sizer, wxSizerFlags(1).Border().Expand()); - main_sizer->Add(new wxStaticLine(this, wxHORIZONTAL), wxSizerFlags().HorzBorder().Expand()); + main_sizer->Add(new wxStaticLine(&d, wxHORIZONTAL), wxSizerFlags().HorzBorder().Expand()); main_sizer->Add(btn_sizer, wxSizerFlags().Expand().Border()); UpdateLengthDisplay(); - SetSizerAndFit(main_sizer); - CenterOnParent(); + d.SetSizerAndFit(main_sizer); + d.CenterOnParent(); - Bind(wxEVT_COMBOBOX, &DialogDummyVideo::OnResolutionShortcut, this); + d.Bind(wxEVT_COMBOBOX, &DialogDummyVideo::OnResolutionShortcut, this); color_btn->Bind(EVT_COLOR, [=](wxThreadEvent& e) { color = color_btn->GetColor(); }); - Bind(wxEVT_SPINCTRL, [=](wxCommandEvent&) { - TransferDataFromWindow(); + d.Bind(wxEVT_SPINCTRL, [&](wxCommandEvent&) { + d.TransferDataFromWindow(); UpdateLengthDisplay(); }); } @@ -146,16 +148,16 @@ void DialogDummyVideo::AddCtrl(wxString const& label, T *ctrl) { if (!label) sizer->AddStretchSpacer(); else - sizer->Add(new wxStaticText(this, -1, label), wxSizerFlags().Center().Left()); + sizer->Add(new wxStaticText(&d, -1, label), wxSizerFlags().Center().Left()); sizer->Add(ctrl, wxSizerFlags().Expand().Center().Left()); } void DialogDummyVideo::OnResolutionShortcut(wxCommandEvent &e) { - TransferDataFromWindow(); + d.TransferDataFromWindow(); int rs = e.GetSelection(); width = resolutions[rs].width; height = resolutions[rs].height; - TransferDataToWindow(); + d.TransferDataToWindow(); } void DialogDummyVideo::UpdateLengthDisplay() { @@ -165,7 +167,7 @@ void DialogDummyVideo::UpdateLengthDisplay() { std::string CreateDummyVideo(wxWindow *parent) { DialogDummyVideo dlg(parent); - if (dlg.ShowModal() != wxID_OK) + if (dlg.d.ShowModal() != wxID_OK) return ""; OPT_SET("Video/Dummy/FPS")->SetDouble(dlg.fps); diff --git a/src/dialog_export.cpp b/src/dialog_export.cpp index a6e5d455f..f038bf1b7 100644 --- a/src/dialog_export.cpp +++ b/src/dialog_export.cpp @@ -51,7 +51,8 @@ #include namespace { -class DialogExport final : public wxDialog { +class DialogExport { + wxDialog d; agi::Context *c; /// The export transform engine @@ -79,6 +80,7 @@ class DialogExport final : public wxDialog { public: DialogExport(agi::Context *c); ~DialogExport(); + void ShowModal() { d.ShowModal(); } }; // Swap the items at idx and idx + 1 @@ -97,15 +99,15 @@ void swap(wxCheckListBox *list, int idx, int sel_dir) { } DialogExport::DialogExport(agi::Context *c) -: wxDialog(c->parent, -1, _("Export"), wxDefaultPosition, wxSize(200, 100), wxCAPTION | wxCLOSE_BOX) +: d(c->parent, -1, _("Export"), wxDefaultPosition, wxSize(200, 100), wxCAPTION | wxCLOSE_BOX) , c(c) , exporter(c) { - SetIcon(GETICON(export_menu_16)); - SetExtraStyle(wxWS_EX_VALIDATE_RECURSIVELY); + d.SetIcon(GETICON(export_menu_16)); + d.SetExtraStyle(wxWS_EX_VALIDATE_RECURSIVELY); std::vector filters = exporter.GetAllFilterNames(); - filter_list = new wxCheckListBox(this, -1, wxDefaultPosition, wxSize(200, 100), to_wx(filters)); + filter_list = new wxCheckListBox(&d, -1, wxDefaultPosition, wxSize(200, 100), to_wx(filters)); filter_list->Bind(wxEVT_CHECKLISTBOX, [=](wxCommandEvent&) { RefreshOptions(); }); filter_list->Bind(wxEVT_LISTBOX, &DialogExport::OnChange, this); @@ -118,10 +120,10 @@ DialogExport::DialogExport(agi::Context *c) filter_list->Check(distance(begin(filters), it)); } - wxButton *btn_up = new wxButton(this, -1, _("Move &Up"), wxDefaultPosition, wxSize(90, -1)); - wxButton *btn_down = new wxButton(this, -1, _("Move &Down"), wxDefaultPosition, wxSize(90, -1)); - wxButton *btn_all = new wxButton(this, -1, _("Select &All"), wxDefaultPosition, wxSize(80, -1)); - wxButton *btn_none = new wxButton(this, -1, _("Select &None"), wxDefaultPosition, wxSize(80, -1)); + wxButton *btn_up = new wxButton(&d, -1, _("Move &Up"), wxDefaultPosition, wxSize(90, -1)); + wxButton *btn_down = new wxButton(&d, -1, _("Move &Down"), wxDefaultPosition, wxSize(90, -1)); + wxButton *btn_all = new wxButton(&d, -1, _("Select &All"), wxDefaultPosition, wxSize(80, -1)); + wxButton *btn_none = new wxButton(&d, -1, _("Select &None"), wxDefaultPosition, wxSize(80, -1)); btn_up->Bind(wxEVT_BUTTON, [=](wxCommandEvent&) { swap(filter_list, filter_list->GetSelection() - 1, 0); }); btn_down->Bind(wxEVT_BUTTON, [=](wxCommandEvent&) { swap(filter_list, filter_list->GetSelection() - 1, 0); }); @@ -134,40 +136,40 @@ DialogExport::DialogExport(agi::Context *c) top_buttons->Add(btn_all, wxSizerFlags(1).Expand()); top_buttons->Add(btn_none, wxSizerFlags(1).Expand()); - filter_description = new wxTextCtrl(this, -1, "", wxDefaultPosition, wxSize(200, 60), wxTE_MULTILINE | wxTE_READONLY); + filter_description = new wxTextCtrl(&d, -1, "", wxDefaultPosition, wxSize(200, 60), wxTE_MULTILINE | wxTE_READONLY); // Charset dropdown list - wxStaticText *charset_list_label = new wxStaticText(this, -1, _("Text encoding:")); - charset_list = new wxChoice(this, -1, wxDefaultPosition, wxDefaultSize, agi::charset::GetEncodingsList()); + wxStaticText *charset_list_label = new wxStaticText(&d, -1, _("Text encoding:")); + charset_list = new wxChoice(&d, -1, wxDefaultPosition, wxDefaultSize, agi::charset::GetEncodingsList()); wxSizer *charset_list_sizer = new wxBoxSizer(wxHORIZONTAL); charset_list_sizer->Add(charset_list_label, wxSizerFlags().Center().Border(wxRIGHT)); charset_list_sizer->Add(charset_list, wxSizerFlags(1).Expand()); if (!charset_list->SetStringSelection(to_wx(c->ass->Properties.export_encoding))) charset_list->SetStringSelection("Unicode (UTF-8)"); - wxSizer *top_sizer = new wxStaticBoxSizer(wxVERTICAL, this, _("Filters")); + wxSizer *top_sizer = new wxStaticBoxSizer(wxVERTICAL, &d, _("Filters")); top_sizer->Add(filter_list, wxSizerFlags(1).Expand()); top_sizer->Add(top_buttons, wxSizerFlags(0).Expand()); top_sizer->Add(filter_description, wxSizerFlags(0).Expand().Border(wxTOP)); top_sizer->Add(charset_list_sizer, wxSizerFlags(0).Expand().Border(wxTOP)); - wxStdDialogButtonSizer *btn_sizer = CreateStdDialogButtonSizer(wxOK | wxCANCEL | wxHELP); + auto btn_sizer = d.CreateStdDialogButtonSizer(wxOK | wxCANCEL | wxHELP); btn_sizer->GetAffirmativeButton()->SetLabelText(_("Export...")); - Bind(wxEVT_BUTTON, &DialogExport::OnProcess, this, wxID_OK); - Bind(wxEVT_BUTTON, std::bind(&HelpButton::OpenPage, "Export"), wxID_HELP); + d.Bind(wxEVT_BUTTON, &DialogExport::OnProcess, this, wxID_OK); + d.Bind(wxEVT_BUTTON, std::bind(&HelpButton::OpenPage, "Export"), wxID_HELP); wxSizer *horz_sizer = new wxBoxSizer(wxHORIZONTAL); opt_sizer = new wxBoxSizer(wxVERTICAL); - exporter.DrawSettings(this, opt_sizer); + exporter.DrawSettings(&d, opt_sizer); horz_sizer->Add(top_sizer, wxSizerFlags().Expand().Border(wxALL & ~wxRIGHT)); horz_sizer->Add(opt_sizer, wxSizerFlags(1).Expand().Border(wxALL & ~wxLEFT)); wxSizer *main_sizer = new wxBoxSizer(wxVERTICAL); main_sizer->Add(horz_sizer, wxSizerFlags(1).Expand()); main_sizer->Add(btn_sizer, wxSizerFlags().Expand().Border(wxALL & ~wxTOP)); - SetSizerAndFit(main_sizer); + d.SetSizerAndFit(main_sizer); RefreshOptions(); - CenterOnParent(); + d.CenterOnParent(); } DialogExport::~DialogExport() { @@ -182,9 +184,9 @@ DialogExport::~DialogExport() { } void DialogExport::OnProcess(wxCommandEvent &) { - if (!TransferDataFromWindow()) return; + if (!d.TransferDataFromWindow()) return; - auto filename = SaveFileSelector(_("Export subtitles file"), "", "", "", to_wx(SubtitleFormat::GetWildcards(1)), this); + auto filename = SaveFileSelector(_("Export subtitles file"), "", "", "", to_wx(SubtitleFormat::GetWildcards(1)), &d); if (filename.empty()) return; for (size_t i = 0; i < filter_list->GetCount(); ++i) { @@ -195,27 +197,27 @@ void DialogExport::OnProcess(wxCommandEvent &) { try { wxBusyCursor busy; c->ass->Properties.export_encoding = from_wx(charset_list->GetStringSelection()); - exporter.Export(filename, from_wx(charset_list->GetStringSelection()), this); + exporter.Export(filename, from_wx(charset_list->GetStringSelection()), &d); } catch (agi::UserCancelException const&) { } catch (const char *error) { - wxMessageBox(error, "Error exporting subtitles", wxOK | wxICON_ERROR | wxCENTER, this); + wxMessageBox(error, "Error exporting subtitles", wxOK | wxICON_ERROR | wxCENTER, &d); } catch (wxString const& error) { - wxMessageBox(error, "Error exporting subtitles", wxOK | wxICON_ERROR | wxCENTER, this); + wxMessageBox(error, "Error exporting subtitles", wxOK | wxICON_ERROR | wxCENTER, &d); } catch (agi::Exception const& err) { - wxMessageBox(to_wx(err.GetMessage()), "Error exporting subtitles", wxOK | wxICON_ERROR | wxCENTER, this); + wxMessageBox(to_wx(err.GetMessage()), "Error exporting subtitles", wxOK | wxICON_ERROR | wxCENTER, &d); } catch (std::exception const& err) { - wxMessageBox(to_wx(err.what()), "Error exporting subtitles", wxOK | wxICON_ERROR | wxCENTER, this); + wxMessageBox(to_wx(err.what()), "Error exporting subtitles", wxOK | wxICON_ERROR | wxCENTER, &d); } catch (...) { - wxMessageBox("Unknown error", "Error exporting subtitles", wxOK | wxICON_ERROR | wxCENTER, this); + wxMessageBox("Unknown error", "Error exporting subtitles", wxOK | wxICON_ERROR | wxCENTER, &d); } - EndModal(0); + d.EndModal(0); } void DialogExport::OnChange(wxCommandEvent &) { @@ -238,8 +240,8 @@ void DialogExport::RefreshOptions() { if (wxSizer *sizer = exporter.GetSettingsSizer(from_wx(filter_list->GetString(i)))) opt_sizer->Show(sizer, filter_list->IsChecked(i), true); } - Layout(); - GetSizer()->Fit(this); + d.Layout(); + d.GetSizer()->Fit(&d); } } diff --git a/src/dialog_export_ebu3264.cpp b/src/dialog_export_ebu3264.cpp index 9216416bd..77fb10fd3 100644 --- a/src/dialog_export_ebu3264.cpp +++ b/src/dialog_export_ebu3264.cpp @@ -33,6 +33,7 @@ #include #include +#include #include #include #include @@ -92,11 +93,12 @@ namespace { TimecodeValidator(EbuTimecode *target) : value(target) { assert(target); } TimecodeValidator(TimecodeValidator const& other) : wxValidator(other), value(other.value) { } }; + } // namespace { -EbuExportConfigurationDialog::EbuExportConfigurationDialog(wxWindow *owner, EbuExportSettings &s) -: wxDialog(owner, -1, _("Export to EBU STL format")) -{ +int ShowEbuExportConfigurationDialog(wxWindow *owner, EbuExportSettings &s) { + wxDialog d(owner, -1, _("Export to EBU STL format")); + wxString tv_standards[] = { _("23.976 fps (non-standard, STL24.01)"), _("24 fps (non-standard, STL24.01)"), @@ -105,10 +107,10 @@ EbuExportConfigurationDialog::EbuExportConfigurationDialog(wxWindow *owner, EbuE _("29.97 fps (dropframe, STL30.01)"), _("30 fps (STL30.01)") }; - wxRadioBox *tv_standard_box = new wxRadioBox(this, -1, _("TV standard"), wxDefaultPosition, wxDefaultSize, 6, tv_standards, 0, wxRA_SPECIFY_ROWS); + wxRadioBox *tv_standard_box = new wxRadioBox(&d, -1, _("TV standard"), wxDefaultPosition, wxDefaultSize, 6, tv_standards, 0, wxRA_SPECIFY_ROWS); - wxTextCtrl *timecode_offset_entry = new wxTextCtrl(this, -1, "00:00:00:00"); - wxCheckBox *inclusive_end_times_check = new wxCheckBox(this, -1, _("Out-times are inclusive")); + wxTextCtrl *timecode_offset_entry = new wxTextCtrl(&d, -1, "00:00:00:00"); + wxCheckBox *inclusive_end_times_check = new wxCheckBox(&d, -1, _("Out-times are inclusive")); wxString text_encodings[] = { _("ISO 6937-2 (Latin/Western Europe)"), @@ -118,7 +120,7 @@ EbuExportConfigurationDialog::EbuExportConfigurationDialog(wxWindow *owner, EbuE _("ISO 8859-8 (Hebrew)"), _("UTF-8 Unicode (non-standard)") }; - wxRadioBox *text_encoding_box = new wxRadioBox(this, -1, _("Text encoding"), wxDefaultPosition, wxDefaultSize, 6, text_encodings, 0, wxRA_SPECIFY_ROWS); + wxRadioBox *text_encoding_box = new wxRadioBox(&d, -1, _("Text encoding"), wxDefaultPosition, wxDefaultSize, 6, text_encodings, 0, wxRA_SPECIFY_ROWS); wxString wrap_modes[] = { _("Automatically wrap long lines (ASS)"), @@ -127,9 +129,9 @@ EbuExportConfigurationDialog::EbuExportConfigurationDialog(wxWindow *owner, EbuE _("Skip lines that are too long") }; - wxSpinCtrl *max_line_length_ctrl = new wxSpinCtrl(this, -1, wxString(), wxDefaultPosition, wxSize(65, -1)); - wxComboBox *wrap_mode_ctrl = new wxComboBox(this, -1, wrap_modes[0], wxDefaultPosition, wxDefaultSize, 4, wrap_modes, wxCB_DROPDOWN | wxCB_READONLY); - wxCheckBox *translate_alignments_check = new wxCheckBox(this, -1, _("Translate alignments")); + wxSpinCtrl *max_line_length_ctrl = new wxSpinCtrl(&d, -1, wxString(), wxDefaultPosition, wxSize(65, -1)); + wxComboBox *wrap_mode_ctrl = new wxComboBox(&d, -1, wrap_modes[0], wxDefaultPosition, wxDefaultSize, 4, wrap_modes, wxCB_DROPDOWN | wxCB_READONLY); + wxCheckBox *translate_alignments_check = new wxCheckBox(&d, -1, _("Translate alignments")); max_line_length_ctrl->SetRange(10, 99); @@ -139,26 +141,26 @@ EbuExportConfigurationDialog::EbuExportConfigurationDialog(wxWindow *owner, EbuE _("Level-2 teletext") }; - wxComboBox *display_standard_ctrl = new wxComboBox(this, -1, "", wxDefaultPosition, wxDefaultSize, 2, display_standards, wxCB_DROPDOWN | wxCB_READONLY); + wxComboBox *display_standard_ctrl = new wxComboBox(&d, -1, "", wxDefaultPosition, wxDefaultSize, 2, display_standards, wxCB_DROPDOWN | wxCB_READONLY); wxSizer *max_line_length_labelled = new wxBoxSizer(wxHORIZONTAL); - max_line_length_labelled->Add(new wxStaticText(this, -1, _("Max. line length:")), 1, wxALIGN_CENTRE|wxRIGHT, 12); + max_line_length_labelled->Add(new wxStaticText(&d, -1, _("Max. line length:")), 1, wxALIGN_CENTRE|wxRIGHT, 12); max_line_length_labelled->Add(max_line_length_ctrl, 0, 0, 0); wxSizer *timecode_offset_labelled = new wxBoxSizer(wxHORIZONTAL); - timecode_offset_labelled->Add(new wxStaticText(this, -1, _("Time code offset:")), 1, wxALIGN_CENTRE|wxRIGHT, 12); + timecode_offset_labelled->Add(new wxStaticText(&d, -1, _("Time code offset:")), 1, wxALIGN_CENTRE|wxRIGHT, 12); timecode_offset_labelled->Add(timecode_offset_entry, 0, 0, 0); - wxSizer *text_formatting_sizer = new wxStaticBoxSizer(wxVERTICAL, this, _("Text formatting")); + wxSizer *text_formatting_sizer = new wxStaticBoxSizer(wxVERTICAL, &d, _("Text formatting")); text_formatting_sizer->Add(max_line_length_labelled, 0, wxEXPAND | (wxALL & ~wxTOP), 6); text_formatting_sizer->Add(wrap_mode_ctrl, 0, wxEXPAND | (wxALL & ~wxTOP), 6); text_formatting_sizer->Add(translate_alignments_check, 0, wxEXPAND | (wxALL & ~wxTOP), 6); - wxSizer *timecode_control_sizer = new wxStaticBoxSizer(wxVERTICAL, this, _("Time codes")); + wxSizer *timecode_control_sizer = new wxStaticBoxSizer(wxVERTICAL, &d, _("Time codes")); timecode_control_sizer->Add(timecode_offset_labelled, 0, wxEXPAND | (wxALL & ~wxTOP), 6); timecode_control_sizer->Add(inclusive_end_times_check, 0, wxEXPAND | (wxALL & ~wxTOP), 6); - wxSizer *display_standard_sizer = new wxStaticBoxSizer(wxVERTICAL, this, _("Display standard")); + wxSizer *display_standard_sizer = new wxStaticBoxSizer(wxVERTICAL, &d, _("Display standard")); display_standard_sizer->Add(display_standard_ctrl, 0, wxEXPAND | (wxALL & ~wxTOP), 6); wxSizer *left_column = new wxBoxSizer(wxVERTICAL); @@ -175,18 +177,18 @@ EbuExportConfigurationDialog::EbuExportConfigurationDialog(wxWindow *owner, EbuE vertical_split_sizer->Add(right_column, 0, 0, 0); wxSizer *buttons_sizer = new wxBoxSizer(wxHORIZONTAL); - // Developers are requested to leave this message in! Intentionally not translatable. - wxStaticText *sponsor_label = new wxStaticText(this, -1, "EBU STL format writing sponsored by Bandai"); + // Developers are requested to leave &d message in! Intentionally not translatable. + wxStaticText *sponsor_label = new wxStaticText(&d, -1, "EBU STL format writing sponsored by Bandai"); sponsor_label->Enable(false); buttons_sizer->Add(sponsor_label, 1, wxALIGN_BOTTOM, 0); - buttons_sizer->Add(CreateStdDialogButtonSizer(wxOK | wxCANCEL), 0, wxLEFT, 6); + buttons_sizer->Add(d.CreateStdDialogButtonSizer(wxOK | wxCANCEL), 0, wxLEFT, 6); wxSizer *main_sizer = new wxBoxSizer(wxVERTICAL); main_sizer->Add(vertical_split_sizer, 0, wxEXPAND|wxALL, 12); main_sizer->Add(buttons_sizer, 0, wxEXPAND | (wxALL & ~wxTOP), 12); - SetSizerAndFit(main_sizer); - CenterOnParent(); + d.SetSizerAndFit(main_sizer); + d.CenterOnParent(); // set up validators to move data in and out tv_standard_box->SetValidator(wxGenericValidator((int*)&s.tv_standard)); @@ -197,6 +199,8 @@ EbuExportConfigurationDialog::EbuExportConfigurationDialog(wxWindow *owner, EbuE inclusive_end_times_check->SetValidator(wxGenericValidator(&s.inclusive_end_times)); timecode_offset_entry->SetValidator(TimecodeValidator(&s.timecode_offset)); display_standard_ctrl->SetValidator(wxGenericValidator((int*)&s.display_standard)); + + return d.ShowModal(); } agi::vfr::Framerate EbuExportSettings::GetFramerate() const { diff --git a/src/dialog_export_ebu3264.h b/src/dialog_export_ebu3264.h index 1ab54f000..4722fe0e7 100644 --- a/src/dialog_export_ebu3264.h +++ b/src/dialog_export_ebu3264.h @@ -22,7 +22,6 @@ #include #include -#include namespace agi { namespace charset { class IconvWrapper; } } @@ -111,11 +110,7 @@ public: void Save() const; }; -/// Dialog box for getting an export configuration for EBU Tech 3264-1991 -class EbuExportConfigurationDialog final : public wxDialog { -public: - /// Constructor - /// @param owner Parent window of the dialog - /// @param s Struct with initial values and to fill with the chosen settings - EbuExportConfigurationDialog(wxWindow *owner, EbuExportSettings &s); -}; +/// Show a dialog box for getting an export configuration for EBU Tech 3264-1991 +/// @param owner Parent window of the dialog +/// @param s Struct with initial values and to fill with the chosen settings +int ShowEbuExportConfigurationDialog(wxWindow *owner, EbuExportSettings &s); diff --git a/src/dialog_jumpto.cpp b/src/dialog_jumpto.cpp index ec7919aaf..4f8e7bcf1 100644 --- a/src/dialog_jumpto.cpp +++ b/src/dialog_jumpto.cpp @@ -43,7 +43,8 @@ #include namespace { -class DialogJumpTo final : public wxDialog { +struct DialogJumpTo { + wxDialog d; agi::Context *c; ///< Project context long jumpframe; ///< Target frame to jump to TimeEdit *JumpTime; ///< Target time edit control @@ -58,23 +59,22 @@ class DialogJumpTo final : public wxDialog { /// Dialog initializer to set default focus and selection void OnInitDialog(wxInitDialogEvent&); -public: DialogJumpTo(agi::Context *c); }; DialogJumpTo::DialogJumpTo(agi::Context *c) -: wxDialog(c->parent, -1, _("Jump to"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxWANTS_CHARS) +: d(c->parent, -1, _("Jump to"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxWANTS_CHARS) , c(c) , jumpframe(c->videoController->GetFrameN()) { - SetIcon(GETICON(jumpto_button_16)); + d.SetIcon(GETICON(jumpto_button_16)); - auto LabelFrame = new wxStaticText(this, -1, _("Frame: ")); - auto LabelTime = new wxStaticText(this, -1, _("Time: ")); + auto LabelFrame = new wxStaticText(&d, -1, _("Frame: ")); + auto LabelTime = new wxStaticText(&d, -1, _("Time: ")); - JumpFrame = new wxTextCtrl(this,-1,"",wxDefaultPosition,wxSize(-1,-1),wxTE_PROCESS_ENTER, IntValidator((int)jumpframe)); + JumpFrame = new wxTextCtrl(&d,-1,"",wxDefaultPosition,wxSize(-1,-1),wxTE_PROCESS_ENTER, IntValidator((int)jumpframe)); JumpFrame->SetMaxLength(std::to_string(c->project->VideoProvider()->GetFrameCount() - 1).size()); - JumpTime = new TimeEdit(this, -1, c, AssTime(c->videoController->TimeAtFrame(jumpframe)).GetAssFormated(), wxSize(-1,-1)); + JumpTime = new TimeEdit(&d, -1, c, AssTime(c->videoController->TimeAtFrame(jumpframe)).GetAssFormated(), wxSize(-1,-1)); auto TimesSizer = new wxGridSizer(2, 5, 5); @@ -84,25 +84,25 @@ DialogJumpTo::DialogJumpTo(agi::Context *c) TimesSizer->Add(LabelTime, 1, wxALIGN_CENTER_VERTICAL); TimesSizer->Add(JumpTime, wxEXPAND); - auto ButtonSizer = CreateStdDialogButtonSizer(wxOK | wxCANCEL); + auto ButtonSizer = d.CreateStdDialogButtonSizer(wxOK | wxCANCEL); // General layout auto MainSizer = new wxBoxSizer(wxVERTICAL); MainSizer->Add(TimesSizer, 0, wxALL | wxALIGN_CENTER, 5); MainSizer->Add(ButtonSizer, 0, wxEXPAND | wxLEFT | wxBOTTOM | wxRIGHT, 5); - SetSizerAndFit(MainSizer); - CenterOnParent(); + d.SetSizerAndFit(MainSizer); + d.CenterOnParent(); - Bind(wxEVT_INIT_DIALOG, &DialogJumpTo::OnInitDialog, this); - Bind(wxEVT_TEXT_ENTER, &DialogJumpTo::OnOK, this); - Bind(wxEVT_BUTTON, &DialogJumpTo::OnOK, this, wxID_OK); + d.Bind(wxEVT_INIT_DIALOG, &DialogJumpTo::OnInitDialog, this); + d.Bind(wxEVT_TEXT_ENTER, &DialogJumpTo::OnOK, this); + d.Bind(wxEVT_BUTTON, &DialogJumpTo::OnOK, this, wxID_OK); JumpTime->Bind(wxEVT_TEXT, &DialogJumpTo::OnEditTime, this); JumpFrame->Bind(wxEVT_TEXT, &DialogJumpTo::OnEditFrame, this); } void DialogJumpTo::OnInitDialog(wxInitDialogEvent&) { - TransferDataToWindow(); - UpdateWindowUI(wxUPDATE_UI_RECURSE); + d.TransferDataToWindow(); + d.UpdateWindowUI(wxUPDATE_UI_RECURSE); // This can't simply be done in the constructor as the value hasn't been set yet JumpFrame->SetFocus(); @@ -110,7 +110,7 @@ void DialogJumpTo::OnInitDialog(wxInitDialogEvent&) { } void DialogJumpTo::OnOK(wxCommandEvent &) { - EndModal(0); + d.EndModal(0); c->videoController->JumpToFrame(jumpframe); } @@ -129,5 +129,5 @@ void DialogJumpTo::OnEditFrame (wxCommandEvent &event) { } void ShowJumpToDialog(agi::Context *c) { - DialogJumpTo(c).ShowModal(); + DialogJumpTo(c).d.ShowModal(); } diff --git a/src/dialog_paste_over.cpp b/src/dialog_paste_over.cpp index 8a8c33b29..1bc0df8a5 100644 --- a/src/dialog_paste_over.cpp +++ b/src/dialog_paste_over.cpp @@ -38,7 +38,8 @@ #include namespace { -class DialogPasteOver final : public wxDialog { +struct DialogPasteOver { + wxDialog d; wxCheckListBox *ListBox; void CheckAll(bool check); @@ -47,16 +48,15 @@ class DialogPasteOver final : public wxDialog { void OnTimes(wxCommandEvent &); void OnText(wxCommandEvent &); -public: DialogPasteOver(wxWindow *parent); }; DialogPasteOver::DialogPasteOver(wxWindow *parent) -: wxDialog(parent, -1, _("Select Fields to Paste Over")) +: d(parent, -1, _("Select Fields to Paste Over")) { // Label and list sizer - wxSizer *ListSizer = new wxStaticBoxSizer(wxVERTICAL, this, _("Fields")); - ListSizer->Add(new wxStaticText(this, -1, _("Please select the fields that you want to paste over:")), wxSizerFlags()); + wxSizer *ListSizer = new wxStaticBoxSizer(wxVERTICAL, &d, _("Fields")); + ListSizer->Add(new wxStaticText(&d, -1, _("Please select the fields that you want to paste over:")), wxSizerFlags()); // List box wxArrayString choices; @@ -71,7 +71,7 @@ DialogPasteOver::DialogPasteOver(wxWindow *parent) choices.Add(_("Margin Vertical")); choices.Add(_("Effect")); choices.Add(_("Text")); - ListBox = new wxCheckListBox(this, -1, wxDefaultPosition, wxDefaultSize, choices); + ListBox = new wxCheckListBox(&d, -1, wxDefaultPosition, wxDefaultSize, choices); ListSizer->Add(ListBox, wxSizerFlags(0).Expand().Border(wxTOP)); std::vector options = OPT_GET("Tool/Paste Lines Over/Fields")->GetListBool(); @@ -85,27 +85,27 @@ DialogPasteOver::DialogPasteOver(wxWindow *parent) wxButton *btn; wxSizer *TopButtonSizer = new wxBoxSizer(wxHORIZONTAL); - TopButtonSizer->Add(btn = new wxButton(this, -1, _("&All")), wxSizerFlags(1)); + TopButtonSizer->Add(btn = new wxButton(&d, -1, _("&All")), wxSizerFlags(1)); btn->Bind(wxEVT_BUTTON, std::bind(&DialogPasteOver::CheckAll, this, true)); - TopButtonSizer->Add(btn = new wxButton(this, -1, _("&None")), wxSizerFlags(1)); + TopButtonSizer->Add(btn = new wxButton(&d, -1, _("&None")), wxSizerFlags(1)); btn->Bind(wxEVT_BUTTON, std::bind(&DialogPasteOver::CheckAll, this, false)); - TopButtonSizer->Add(btn = new wxButton(this, -1, _("&Times")), wxSizerFlags(1)); + TopButtonSizer->Add(btn = new wxButton(&d, -1, _("&Times")), wxSizerFlags(1)); btn->Bind(wxEVT_BUTTON, &DialogPasteOver::OnTimes, this); - TopButtonSizer->Add(btn = new wxButton(this, -1, _("T&ext")), wxSizerFlags(1)); + TopButtonSizer->Add(btn = new wxButton(&d, -1, _("T&ext")), wxSizerFlags(1)); btn->Bind(wxEVT_BUTTON, &DialogPasteOver::OnText, this); // Buttons - wxStdDialogButtonSizer *ButtonSizer = CreateStdDialogButtonSizer(wxOK | wxCANCEL | wxHELP); - Bind(wxEVT_BUTTON, &DialogPasteOver::OnOK, this, wxID_OK); - Bind(wxEVT_BUTTON, std::bind(&HelpButton::OpenPage, "Paste Over"), wxID_HELP); + auto ButtonSizer = d.CreateStdDialogButtonSizer(wxOK | wxCANCEL | wxHELP); + d.Bind(wxEVT_BUTTON, &DialogPasteOver::OnOK, this, wxID_OK); + d.Bind(wxEVT_BUTTON, std::bind(&HelpButton::OpenPage, "Paste Over"), wxID_HELP); // Main sizer wxSizer *MainSizer = new wxBoxSizer(wxVERTICAL); MainSizer->Add(ListSizer,0,wxEXPAND | wxLEFT | wxRIGHT,5); MainSizer->Add(TopButtonSizer,0,wxLEFT | wxRIGHT | wxEXPAND,5); MainSizer->Add(ButtonSizer,0,wxALL | wxEXPAND,5); - SetSizerAndFit(MainSizer); - CenterOnParent(); + d.SetSizerAndFit(MainSizer); + d.CenterOnParent(); } void DialogPasteOver::OnOK(wxCommandEvent &) { @@ -114,7 +114,7 @@ void DialogPasteOver::OnOK(wxCommandEvent &) { options.push_back(ListBox->IsChecked(i)); OPT_SET("Tool/Paste Lines Over/Fields")->SetListBool(std::move(options)); - EndModal(wxID_OK); + d.EndModal(wxID_OK); } void DialogPasteOver::OnText(wxCommandEvent &) { @@ -135,5 +135,5 @@ void DialogPasteOver::CheckAll(bool check) { } bool ShowPasteOverDialog(wxWindow *parent) { - return DialogPasteOver(parent).ShowModal() == wxID_OK; + return DialogPasteOver(parent).d.ShowModal() == wxID_OK; } diff --git a/src/dialog_properties.cpp b/src/dialog_properties.cpp index 5b0f21996..7c0399402 100644 --- a/src/dialog_properties.cpp +++ b/src/dialog_properties.cpp @@ -48,7 +48,8 @@ #include namespace { -class DialogProperties final : public wxDialog { +class DialogProperties { + wxDialog d; agi::Context *c; ///< Project this dialog is adjusting the properties of /// Pairs of a script property and a text control for that property @@ -81,16 +82,17 @@ public: /// Constructor /// @param c Project context DialogProperties(agi::Context *c); + void ShowModal() { d.ShowModal(); } }; DialogProperties::DialogProperties(agi::Context *c) -: wxDialog(c->parent, -1, _("Script Properties")) +: d(c->parent, -1, _("Script Properties")) , c(c) { - SetIcon(GETICON(properties_toolbutton_16)); + d.SetIcon(GETICON(properties_toolbutton_16)); // Script details crap - wxSizer *TopSizer = new wxStaticBoxSizer(wxHORIZONTAL,this,_("Script")); + wxSizer *TopSizer = new wxStaticBoxSizer(wxHORIZONTAL,&d,_("Script")); auto TopSizerGrid = new wxFlexGridSizer(0,2,5,5); AddProperty(TopSizerGrid, _("Title:"), "Title"); @@ -106,10 +108,10 @@ DialogProperties::DialogProperties(agi::Context *c) TopSizer->Add(TopSizerGrid,1,wxALL | wxEXPAND,0); // Resolution box - ResX = new wxTextCtrl(this,-1,"",wxDefaultPosition,wxSize(50,20),0,IntValidator(c->ass->GetScriptInfoAsInt("PlayResX"))); - ResY = new wxTextCtrl(this,-1,"",wxDefaultPosition,wxSize(50,20),0,IntValidator(c->ass->GetScriptInfoAsInt("PlayResY"))); + ResX = new wxTextCtrl(&d,-1,"",wxDefaultPosition,wxSize(50,20),0,IntValidator(c->ass->GetScriptInfoAsInt("PlayResX"))); + ResY = new wxTextCtrl(&d,-1,"",wxDefaultPosition,wxSize(50,20),0,IntValidator(c->ass->GetScriptInfoAsInt("PlayResY"))); - wxButton *FromVideo = new wxButton(this,-1,_("From &video")); + wxButton *FromVideo = new wxButton(&d,-1,_("From &video")); if (!c->project->VideoProvider()) FromVideo->Enable(false); else @@ -117,23 +119,23 @@ DialogProperties::DialogProperties(agi::Context *c) auto res_sizer = new wxBoxSizer(wxHORIZONTAL); res_sizer->Add(ResX, 1, wxRIGHT | wxALIGN_CENTER_VERTICAL, 5); - res_sizer->Add(new wxStaticText(this, -1, "x"), 0, wxALIGN_CENTER | wxRIGHT, 5); + res_sizer->Add(new wxStaticText(&d, -1, "x"), 0, wxALIGN_CENTER | wxRIGHT, 5); res_sizer->Add(ResY, 1, wxRIGHT | wxALIGN_CENTER_VERTICAL, 5); res_sizer->Add(FromVideo, 1, 0, 0); - YCbCrMatrix = new wxComboBox(this, -1, c->ass->GetScriptInfo("YCbCr Matrix"), + YCbCrMatrix = new wxComboBox(&d, -1, c->ass->GetScriptInfo("YCbCr Matrix"), wxDefaultPosition, wxDefaultSize, to_wx(MatrixNames()), wxCB_READONLY); auto matrix_sizer = new wxBoxSizer(wxHORIZONTAL); - matrix_sizer->Add(new wxStaticText(this, -1, "YCbCr Matrix:"), wxSizerFlags().Center()); + matrix_sizer->Add(new wxStaticText(&d, -1, "YCbCr Matrix:"), wxSizerFlags().Center()); matrix_sizer->Add(YCbCrMatrix, wxSizerFlags(1).Expand().Border(wxLEFT)); - auto res_box = new wxStaticBoxSizer(wxVERTICAL, this, _("Resolution")); + auto res_box = new wxStaticBoxSizer(wxVERTICAL, &d, _("Resolution")); res_box->Add(res_sizer, wxSizerFlags().Expand()); res_box->Add(matrix_sizer, wxSizerFlags().Border(wxTOP).Expand()); // Options - wxSizer *optionsBox = new wxStaticBoxSizer(wxHORIZONTAL,this,_("Options")); + wxSizer *optionsBox = new wxStaticBoxSizer(wxHORIZONTAL,&d,_("Options")); auto optionsGrid = new wxFlexGridSizer(3,2,5,5); wxString wrap_opts[] = { _("0: Smart wrapping, top line is wider"), @@ -141,12 +143,12 @@ DialogProperties::DialogProperties(agi::Context *c) _("2: No word wrapping, both \\n and \\N break"), _("3: Smart wrapping, bottom line is wider") }; - WrapStyle = new wxComboBox(this, -1, "", wxDefaultPosition, wxDefaultSize, 4, wrap_opts, wxCB_READONLY); + WrapStyle = new wxComboBox(&d, -1, "", wxDefaultPosition, wxDefaultSize, 4, wrap_opts, wxCB_READONLY); WrapStyle->SetSelection(c->ass->GetScriptInfoAsInt("WrapStyle")); - optionsGrid->Add(new wxStaticText(this,-1,_("Wrap Style: ")),0,wxALIGN_CENTER_VERTICAL,0); + optionsGrid->Add(new wxStaticText(&d,-1,_("Wrap Style: ")),0,wxALIGN_CENTER_VERTICAL,0); optionsGrid->Add(WrapStyle,1,wxEXPAND,0); - ScaleBorder = new wxCheckBox(this,-1,_("Scale Border and Shadow")); + ScaleBorder = new wxCheckBox(&d,-1,_("Scale Border and Shadow")); ScaleBorder->SetToolTip(_("Scale border and shadow together with script/render resolution. If this is unchecked, relative border and shadow size will depend on renderer.")); ScaleBorder->SetValue(boost::iequals(c->ass->GetScriptInfo("ScaledBorderAndShadow"), "yes")); optionsGrid->AddSpacer(0); @@ -155,9 +157,9 @@ DialogProperties::DialogProperties(agi::Context *c) optionsBox->Add(optionsGrid,1,wxEXPAND,0); // Button sizer - wxStdDialogButtonSizer *ButtonSizer = CreateStdDialogButtonSizer(wxOK | wxCANCEL | wxHELP); - Bind(wxEVT_BUTTON, &DialogProperties::OnOK, this, wxID_OK); - Bind(wxEVT_BUTTON, std::bind(&HelpButton::OpenPage, "Properties"), wxID_HELP); + auto ButtonSizer = d.CreateStdDialogButtonSizer(wxOK | wxCANCEL | wxHELP); + d.Bind(wxEVT_BUTTON, &DialogProperties::OnOK, this, wxID_OK); + d.Bind(wxEVT_BUTTON, std::bind(&HelpButton::OpenPage, "Properties"), wxID_HELP); // MainSizer wxSizer *MainSizer = new wxBoxSizer(wxVERTICAL); @@ -166,13 +168,13 @@ DialogProperties::DialogProperties(agi::Context *c) MainSizer->Add(optionsBox,0,wxLEFT | wxRIGHT | wxBOTTOM | wxEXPAND,5); MainSizer->Add(ButtonSizer,0,wxLEFT | wxRIGHT | wxBOTTOM | wxEXPAND,5); - SetSizerAndFit(MainSizer); - CenterOnParent(); + d.SetSizerAndFit(MainSizer); + d.CenterOnParent(); } void DialogProperties::AddProperty(wxSizer *sizer, wxString const& label, std::string const& property) { - wxTextCtrl *ctrl = new wxTextCtrl(this, -1, to_wx(c->ass->GetScriptInfo(property)), wxDefaultPosition, wxSize(200, 20)); - sizer->Add(new wxStaticText(this, -1, label), wxSizerFlags().Center().Left()); + wxTextCtrl *ctrl = new wxTextCtrl(&d, -1, to_wx(c->ass->GetScriptInfo(property)), wxDefaultPosition, wxSize(200, 20)); + sizer->Add(new wxStaticText(&d, -1, label), wxSizerFlags().Center().Left()); sizer->Add(ctrl, wxSizerFlags(1).Expand()); properties.push_back({property, ctrl}); } @@ -190,7 +192,7 @@ void DialogProperties::OnOK(wxCommandEvent &) { if (count) c->ass->Commit(_("property changes"), AssFile::COMMIT_SCRIPTINFO); - EndModal(!!count); + d.EndModal(!!count); } int DialogProperties::SetInfoIfDifferent(std::string const& key, std::string const&value) { diff --git a/src/dialog_resample.cpp b/src/dialog_resample.cpp index e0271d6b3..7575aaa31 100644 --- a/src/dialog_resample.cpp +++ b/src/dialog_resample.cpp @@ -39,7 +39,8 @@ namespace { /// @brief Configuration dialog for resolution resampling /// /// Populate a ResampleSettings structure with data from the user -class DialogResample final : public wxDialog { +struct DialogResample { + wxDialog d; agi::Context *c; ///< Project context int script_w; @@ -86,10 +87,10 @@ enum { }; DialogResample::DialogResample(agi::Context *c, ResampleSettings &settings) -: wxDialog(c->parent, -1, _("Resample Resolution")) +: d(c->parent, -1, _("Resample Resolution")) , c(c) { - SetIcon(GETICON(resample_toolbutton_16)); + d.SetIcon(GETICON(resample_toolbutton_16)); memset(&settings, 0, sizeof(settings)); c->ass->GetResolution(script_w, script_h); @@ -111,23 +112,23 @@ DialogResample::DialogResample(agi::Context *c, ResampleSettings &settings) // Create all controls and set validators for (size_t i = 0; i < 4; ++i) { - margin_ctrl[i] = new wxSpinCtrl(this, -1, "0", wxDefaultPosition, wxSize(50, -1), wxSP_ARROW_KEYS, -9999, 9999, 0); + margin_ctrl[i] = new wxSpinCtrl(&d, -1, "0", wxDefaultPosition, wxSize(50, -1), wxSP_ARROW_KEYS, -9999, 9999, 0); margin_ctrl[i]->SetValidator(wxGenericValidator(&settings.margin[i])); } - symmetrical = new wxCheckBox(this, -1, _("&Symmetrical")); + symmetrical = new wxCheckBox(&d, -1, _("&Symmetrical")); symmetrical->SetValue(true); margin_ctrl[RIGHT]->Enable(false); margin_ctrl[BOTTOM]->Enable(false); - source_x = new wxSpinCtrl(this, -1, "", wxDefaultPosition, wxSize(50, -1), wxSP_ARROW_KEYS, 1, INT_MAX); - source_y = new wxSpinCtrl(this, -1, "", wxDefaultPosition, wxSize(50, -1), wxSP_ARROW_KEYS, 1, INT_MAX); - source_matrix = new wxComboBox(this, -1, "", wxDefaultPosition, + source_x = new wxSpinCtrl(&d, -1, "", wxDefaultPosition, wxSize(50, -1), wxSP_ARROW_KEYS, 1, INT_MAX); + source_y = new wxSpinCtrl(&d, -1, "", wxDefaultPosition, wxSize(50, -1), wxSP_ARROW_KEYS, 1, INT_MAX); + source_matrix = new wxComboBox(&d, -1, "", wxDefaultPosition, wxDefaultSize, to_wx(MatrixNames()), wxCB_READONLY); - dest_x = new wxSpinCtrl(this, -1, "", wxDefaultPosition, wxSize(50, -1), wxSP_ARROW_KEYS, 1, INT_MAX); - dest_y = new wxSpinCtrl(this, -1, "", wxDefaultPosition, wxSize(50, -1), wxSP_ARROW_KEYS, 1, INT_MAX); - dest_matrix = new wxComboBox(this, -1, "", wxDefaultPosition, wxDefaultSize, + dest_x = new wxSpinCtrl(&d, -1, "", wxDefaultPosition, wxSize(50, -1), wxSP_ARROW_KEYS, 1, INT_MAX); + dest_y = new wxSpinCtrl(&d, -1, "", wxDefaultPosition, wxSize(50, -1), wxSP_ARROW_KEYS, 1, INT_MAX); + dest_matrix = new wxComboBox(&d, -1, "", wxDefaultPosition, wxDefaultSize, to_wx(MatrixNames()), wxCB_READONLY); source_x->SetValidator(wxGenericValidator(&settings.source_x)); @@ -137,13 +138,13 @@ DialogResample::DialogResample(agi::Context *c, ResampleSettings &settings) dest_y->SetValidator(wxGenericValidator(&settings.dest_y)); dest_matrix->SetValidator(MakeEnumBinder(&settings.dest_matrix)); - from_video = new wxButton(this, -1, _("From &video")); + from_video = new wxButton(&d, -1, _("From &video")); from_video->Enable(false); - from_script = new wxButton(this, -1, _("From s&cript")); + from_script = new wxButton(&d, -1, _("From s&cript")); from_script->Enable(false); wxString ar_modes[] = {_("Stretch"), _("Add borders"), _("Remove borders"), _("Manual")}; - ar_mode = new wxRadioBox(this, -1, _("Aspect Ratio Handling"), wxDefaultPosition, + ar_mode = new wxRadioBox(&d, -1, _("Aspect Ratio Handling"), wxDefaultPosition, wxDefaultSize, boost::size(ar_modes), ar_modes, 1, 4, MakeEnumBinder(&settings.ar_mode)); // Position the controls @@ -158,34 +159,34 @@ DialogResample::DialogResample(agi::Context *c, ResampleSettings &settings) margin_sizer->Add(margin_ctrl[BOTTOM], wxSizerFlags(1).Expand()); margin_sizer->AddSpacer(1); - auto margin_box = new wxStaticBoxSizer(wxVERTICAL, this, _("Margin offset")); + auto margin_box = new wxStaticBoxSizer(wxVERTICAL, &d, _("Margin offset")); margin_box->Add(margin_sizer, wxSizerFlags(1).Expand().Border(wxBOTTOM)); auto source_res_sizer = new wxBoxSizer(wxHORIZONTAL); source_res_sizer->Add(source_x, wxSizerFlags(1).Border(wxRIGHT).Align(wxALIGN_CENTER_VERTICAL)); - source_res_sizer->Add(new wxStaticText(this, -1, _("x")), wxSizerFlags().Center().Border(wxRIGHT)); + source_res_sizer->Add(new wxStaticText(&d, -1, _("x")), wxSizerFlags().Center().Border(wxRIGHT)); source_res_sizer->Add(source_y, wxSizerFlags(1).Border(wxRIGHT).Align(wxALIGN_CENTER_VERTICAL)); source_res_sizer->Add(from_script, wxSizerFlags(1)); auto source_matrix_sizer = new wxBoxSizer(wxHORIZONTAL); - source_matrix_sizer->Add(new wxStaticText(this, -1, _("YCbCr Matrix:")), wxSizerFlags().Border(wxRIGHT).Center()); + source_matrix_sizer->Add(new wxStaticText(&d, -1, _("YCbCr Matrix:")), wxSizerFlags().Border(wxRIGHT).Center()); source_matrix_sizer->Add(source_matrix, wxSizerFlags(1).Center().Right()); - auto source_res_box = new wxStaticBoxSizer(wxVERTICAL, this, _("Source Resolution")); + auto source_res_box = new wxStaticBoxSizer(wxVERTICAL, &d, _("Source Resolution")); source_res_box->Add(source_res_sizer, wxSizerFlags(1).Expand().Border(wxBOTTOM)); source_res_box->Add(source_matrix_sizer, wxSizerFlags(1).Expand()); auto dest_res_sizer = new wxBoxSizer(wxHORIZONTAL); dest_res_sizer->Add(dest_x, wxSizerFlags(1).Border(wxRIGHT).Align(wxALIGN_CENTER_VERTICAL)); - dest_res_sizer->Add(new wxStaticText(this, -1, _("x")), wxSizerFlags().Center().Border(wxRIGHT)); + dest_res_sizer->Add(new wxStaticText(&d, -1, _("x")), wxSizerFlags().Center().Border(wxRIGHT)); dest_res_sizer->Add(dest_y, wxSizerFlags(1).Border(wxRIGHT).Align(wxALIGN_CENTER_VERTICAL)); dest_res_sizer->Add(from_video, wxSizerFlags(1)); auto dest_matrix_sizer = new wxBoxSizer(wxHORIZONTAL); - dest_matrix_sizer->Add(new wxStaticText(this, -1, _("YCbCr Matrix:")), wxSizerFlags().Border(wxRIGHT).Center()); + dest_matrix_sizer->Add(new wxStaticText(&d, -1, _("YCbCr Matrix:")), wxSizerFlags().Border(wxRIGHT).Center()); dest_matrix_sizer->Add(dest_matrix, wxSizerFlags(1).Center().Right()); - auto dest_res_box = new wxStaticBoxSizer(wxVERTICAL, this, _("Destination Resolution")); + auto dest_res_box = new wxStaticBoxSizer(wxVERTICAL, &d, _("Destination Resolution")); dest_res_box->Add(dest_res_sizer, wxSizerFlags(1).Expand().Border(wxBOTTOM)); dest_res_box->Add(dest_matrix_sizer, wxSizerFlags(1).Expand()); @@ -194,18 +195,18 @@ DialogResample::DialogResample(agi::Context *c, ResampleSettings &settings) main_sizer->Add(dest_res_box, wxSizerFlags().Expand().Border()); main_sizer->Add(ar_mode, wxSizerFlags().Expand().Border()); main_sizer->Add(margin_box, wxSizerFlags(1).Expand().Border()); - main_sizer->Add(CreateStdDialogButtonSizer(wxOK | wxCANCEL | wxHELP), wxSizerFlags().Expand().Border(wxALL & ~wxTOP)); - SetSizerAndFit(main_sizer); - CenterOnParent(); + main_sizer->Add(d.CreateStdDialogButtonSizer(wxOK | wxCANCEL | wxHELP), wxSizerFlags().Expand().Border(wxALL & ~wxTOP)); + d.SetSizerAndFit(main_sizer); + d.CenterOnParent(); - TransferDataToWindow(); + d.TransferDataToWindow(); UpdateButtons(); // Bind events using std::bind; - Bind(wxEVT_BUTTON, bind(&HelpButton::OpenPage, "Resample resolution"), wxID_HELP); - Bind(wxEVT_SPINCTRL, [=](wxCommandEvent&) { UpdateButtons(); }); - Bind(wxEVT_RADIOBOX, [=](wxCommandEvent&) { UpdateButtons(); }); + d.Bind(wxEVT_BUTTON, bind(&HelpButton::OpenPage, "Resample resolution"), wxID_HELP); + d.Bind(wxEVT_SPINCTRL, [=](wxCommandEvent&) { UpdateButtons(); }); + d.Bind(wxEVT_RADIOBOX, [=](wxCommandEvent&) { UpdateButtons(); }); from_video->Bind(wxEVT_BUTTON, &DialogResample::SetDestFromVideo, this); from_script->Bind(wxEVT_BUTTON, &DialogResample::SetSourceFromScript, this); symmetrical->Bind(wxEVT_CHECKBOX, &DialogResample::OnSymmetrical, this); @@ -263,5 +264,5 @@ void DialogResample::OnMarginChange(wxSpinCtrl *src, wxSpinCtrl *dst) { } bool PromptForResampleSettings(agi::Context *c, ResampleSettings &settings) { - return DialogResample(c, settings).ShowModal() == wxID_OK; + return DialogResample(c, settings).d.ShowModal() == wxID_OK; } diff --git a/src/dialog_selected_choices.cpp b/src/dialog_selected_choices.cpp index 27b3b3a97..e0fd0488c 100644 --- a/src/dialog_selected_choices.cpp +++ b/src/dialog_selected_choices.cpp @@ -20,42 +20,27 @@ #include #include -namespace { -/// @class SelectedChoicesDialog -/// @brief wxMultiChoiceDialog with Select All and Select None -class SelectedChoicesDialog final : public wxMultiChoiceDialog { - void SelectAll(wxCommandEvent&); +int GetSelectedChoices(wxWindow *parent, wxArrayInt& selections, wxString const& message, wxString const& caption, wxArrayString const& choices) { + wxMultiChoiceDialog dialog(parent, message, caption, choices); -public: - SelectedChoicesDialog(wxWindow *parent, wxString const& message, wxString const& caption, wxArrayString const& choices); -}; + auto selAll = new wxButton(&dialog, -1, _("Select &All")); + selAll->Bind(wxEVT_BUTTON, [&](wxCommandEvent&) { + wxArrayInt sel(selections.size()); + std::iota(sel.begin(), sel.end(), 0); + dialog.SetSelections(sel); + }); -SelectedChoicesDialog::SelectedChoicesDialog(wxWindow *parent, wxString const& message, wxString const& caption, wxArrayString const& choices) { - Create(parent, message, caption, choices); - - wxButton *selAll = new wxButton(this, -1, _("Select &All")); - wxButton *selNone = new wxButton(this, -1, _("Select &None")); - selAll->Bind(wxEVT_BUTTON, &SelectedChoicesDialog::SelectAll, this); - selNone->Bind(wxEVT_BUTTON, [=](wxCommandEvent&) { SetSelections(wxArrayInt()); }); + auto selNone = new wxButton(&dialog, -1, _("Select &None")); + selNone->Bind(wxEVT_BUTTON, [&](wxCommandEvent&) { dialog.SetSelections(wxArrayInt()); }); auto buttonSizer = new wxBoxSizer(wxHORIZONTAL); buttonSizer->Add(selAll, wxSizerFlags(0).Left()); buttonSizer->Add(selNone, wxSizerFlags(0).Right()); - wxSizer *sizer = GetSizer(); + auto sizer = dialog.GetSizer(); sizer->Insert(2, buttonSizer, wxSizerFlags(0).Center()); - sizer->Fit(this); -} + sizer->Fit(&dialog); -void SelectedChoicesDialog::SelectAll(wxCommandEvent&) { - wxArrayInt sel(m_listbox->GetCount()); - std::iota(sel.begin(), sel.end(), 0); - SetSelections(sel); -} -} - -int GetSelectedChoices(wxWindow *parent, wxArrayInt& selections, wxString const& message, wxString const& caption, wxArrayString const& choices) { - SelectedChoicesDialog dialog(parent, message, caption, choices); dialog.SetSelections(selections); if (dialog.ShowModal() != wxID_OK) return -1; diff --git a/src/dialog_text_import.cpp b/src/dialog_text_import.cpp index 27145d8b0..0da35b741 100644 --- a/src/dialog_text_import.cpp +++ b/src/dialog_text_import.cpp @@ -37,55 +37,41 @@ #include #include -namespace { -/// @class DialogTextImport -/// @brief Plain text import separator character selection dialog -/// /// A simple dialog to let the user select the format of a plain text file /// being imported into Aegisub -class DialogTextImport final : public wxDialog { - std::string seperator; - std::string comment; - bool include_blank; +bool ShowPlainTextImportDialog() { + auto seperator = OPT_GET("Tool/Import/Text/Actor Separator")->GetString(); + auto comment = OPT_GET("Tool/Import/Text/Comment Starter")->GetString(); + auto include_blank = OPT_GET("Tool/Import/Text/Include Blank")->GetBool(); -public: - DialogTextImport(); -}; + wxDialog d(nullptr, -1, _("Text import options")); -DialogTextImport::DialogTextImport() -: wxDialog(nullptr , -1, _("Text import options")) -, seperator(OPT_GET("Tool/Import/Text/Actor Separator")->GetString()) -, comment(OPT_GET("Tool/Import/Text/Comment Starter")->GetString()) -, include_blank(OPT_GET("Tool/Import/Text/Include Blank")->GetBool()) -{ - auto make_text_ctrl = [=](std::string *var) { - return new wxTextCtrl(this, -1, "", wxDefaultPosition, wxDefaultSize, 0, StringBinder(var)); + auto make_text_ctrl = [&](std::string *var) { + return new wxTextCtrl(&d, -1, "", wxDefaultPosition, wxDefaultSize, 0, StringBinder(var)); }; auto fg = new wxFlexGridSizer(2, 5, 5); - fg->Add(new wxStaticText(this, -1, _("Actor separator:")), 0, wxALIGN_CENTRE_VERTICAL); + fg->Add(new wxStaticText(&d, -1, _("Actor separator:")), 0, wxALIGN_CENTRE_VERTICAL); fg->Add(make_text_ctrl(&seperator), 0, wxEXPAND); - fg->Add(new wxStaticText(this, -1, _("Comment starter:")), 0, wxALIGN_CENTRE_VERTICAL); + fg->Add(new wxStaticText(&d, -1, _("Comment starter:")), 0, wxALIGN_CENTRE_VERTICAL); fg->Add(make_text_ctrl(&comment), 0, wxEXPAND); auto main_sizer = new wxBoxSizer(wxVERTICAL); main_sizer->Add(fg, 1, wxALL|wxEXPAND, 5); - main_sizer->Add(new wxCheckBox(this, -1, _("Include blank lines"), wxDefaultPosition, wxDefaultSize, 0, wxGenericValidator(&include_blank)), 0, wxLEFT|wxRIGHT|wxALIGN_RIGHT, 5); - main_sizer->Add(CreateSeparatedButtonSizer(wxOK|wxCANCEL), 0, wxALL|wxEXPAND, 5); - SetSizerAndFit(main_sizer); + main_sizer->Add(new wxCheckBox(&d, -1, _("Include blank lines"), wxDefaultPosition, wxDefaultSize, 0, wxGenericValidator(&include_blank)), 0, wxLEFT|wxRIGHT|wxALIGN_RIGHT, 5); + main_sizer->Add(d.CreateSeparatedButtonSizer(wxOK|wxCANCEL), 0, wxALL|wxEXPAND, 5); + d.SetSizerAndFit(main_sizer); - Bind(wxEVT_BUTTON, [=](wxCommandEvent&) { - TransferDataFromWindow(); + d.Bind(wxEVT_BUTTON, [&](wxCommandEvent&) { + d.TransferDataFromWindow(); OPT_SET("Tool/Import/Text/Actor Separator")->SetString(seperator); OPT_SET("Tool/Import/Text/Comment Starter")->SetString(comment); OPT_SET("Tool/Import/Text/Include Blank")->SetBool(include_blank); - EndModal(wxID_OK); + d.EndModal(wxID_OK); }, wxID_OK); -} -} -bool ShowPlainTextImportDialog() { - return DialogTextImport().ShowModal() == wxID_OK; + + return d.ShowModal() == wxID_OK; } diff --git a/src/dialog_timing_processor.cpp b/src/dialog_timing_processor.cpp index cce9ab98e..e03c4b34a 100644 --- a/src/dialog_timing_processor.cpp +++ b/src/dialog_timing_processor.cpp @@ -66,7 +66,8 @@ using namespace boost::adaptors; namespace { /// @class DialogTimingProcessor /// @brief Automatic postprocessor for correcting common timing issues -class DialogTimingProcessor final : public wxDialog { +struct DialogTimingProcessor { + wxDialog d; agi::Context *c; ///< Project context int leadIn; ///< Lead-in to add in milliseconds @@ -101,7 +102,6 @@ class DialogTimingProcessor final : public wxDialog { /// Get a list of dialogue lines in the file sorted by start time std::vector SortDialogues(); -public: DialogTimingProcessor(agi::Context *c); }; @@ -136,12 +136,12 @@ wxCheckBox *make_check(wxStaticBoxSizer *sizer, wxString const& desc, const char } DialogTimingProcessor::DialogTimingProcessor(agi::Context *c) -: wxDialog(c->parent, -1, _("Timing Post-Processor")) +: d(c->parent, -1, _("Timing Post-Processor")) , c(c) { using std::bind; - SetIcon(GETICON(timing_processor_toolbutton_16)); + d.SetIcon(GETICON(timing_processor_toolbutton_16)); // Read options leadIn = OPT_GET("Audio/Lead/IN")->GetInt(); @@ -154,24 +154,24 @@ DialogTimingProcessor::DialogTimingProcessor(agi::Context *c) adjOverlap = OPT_GET("Tool/Timing Post Processor/Threshold/Adjacent Overlap")->GetInt(); // Styles box - auto LeftSizer = new wxStaticBoxSizer(wxVERTICAL,this,_("Apply to styles")); - StyleList = new wxCheckListBox(this, -1, wxDefaultPosition, wxSize(150,150), to_wx(c->ass->GetStyles())); + auto LeftSizer = new wxStaticBoxSizer(wxVERTICAL,&d,_("Apply to styles")); + StyleList = new wxCheckListBox(&d, -1, wxDefaultPosition, wxSize(150,150), to_wx(c->ass->GetStyles())); StyleList->SetToolTip(_("Select styles to process. Unchecked ones will be ignored.")); - auto all = new wxButton(this,-1,_("&All")); + auto all = new wxButton(&d,-1,_("&All")); all->SetToolTip(_("Select all styles")); - auto none = new wxButton(this,-1,_("&None")); + auto none = new wxButton(&d,-1,_("&None")); none->SetToolTip(_("Deselect all styles")); // Options box - auto optionsSizer = new wxStaticBoxSizer(wxHORIZONTAL,this,_("Options")); - onlySelection = new wxCheckBox(this,-1,_("Affect &selection only")); + auto optionsSizer = new wxStaticBoxSizer(wxHORIZONTAL,&d,_("Options")); + onlySelection = new wxCheckBox(&d,-1,_("Affect &selection only")); onlySelection->SetValue(OPT_GET("Tool/Timing Post Processor/Only Selection")->GetBool()); optionsSizer->Add(onlySelection,1,wxALL,0); // Lead-in/out box - auto LeadSizer = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Lead-in/Lead-out")); + auto LeadSizer = new wxStaticBoxSizer(wxHORIZONTAL, &d, _("Lead-in/Lead-out")); hasLeadIn = make_check(LeadSizer, _("Add lead &in:"), "Tool/Timing Post Processor/Enable/Lead/IN", @@ -186,24 +186,24 @@ DialogTimingProcessor::DialogTimingProcessor(agi::Context *c) LeadSizer->AddStretchSpacer(1); // Adjacent subs sizer - auto AdjacentSizer = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Make adjacent subtitles continuous")); + auto AdjacentSizer = new wxStaticBoxSizer(wxHORIZONTAL, &d, _("Make adjacent subtitles continuous")); adjsEnable = make_check(AdjacentSizer, _("&Enable"), "Tool/Timing Post Processor/Enable/Adjacent", _("Enable snapping of subtitles together if they are within a certain distance of each other")); auto adjBoxes = new wxBoxSizer(wxHORIZONTAL); - make_ctrl(this, adjBoxes, _("Max gap:"), &adjGap, adjsEnable, + make_ctrl(&d, adjBoxes, _("Max gap:"), &adjGap, adjsEnable, _("Maximum difference between start and end time for two subtitles to be made continuous, in milliseconds")); - make_ctrl(this, adjBoxes, _("Max overlap:"), &adjOverlap, adjsEnable, + make_ctrl(&d, adjBoxes, _("Max overlap:"), &adjOverlap, adjsEnable, _("Maximum overlap between the end and start time for two subtitles to be made continuous, in milliseconds")); - adjacentBias = new wxSlider(this, -1, mid(0, OPT_GET("Tool/Timing Post Processor/Adjacent Bias")->GetDouble() * 100, 100), 0, 100, wxDefaultPosition, wxSize(-1,20)); + adjacentBias = new wxSlider(&d, -1, mid(0, OPT_GET("Tool/Timing Post Processor/Adjacent Bias")->GetDouble() * 100, 100), 0, 100, wxDefaultPosition, wxSize(-1,20)); adjacentBias->SetToolTip(_("Sets how to set the adjoining of lines. If set totally to left, it will extend or shrink start time of the second line; if totally to right, it will extend or shrink the end time of the first line.")); auto adjSliderSizer = new wxBoxSizer(wxHORIZONTAL); - adjSliderSizer->Add(new wxStaticText(this, -1, _("Bias: Start <- ")), wxSizerFlags().Center()); + adjSliderSizer->Add(new wxStaticText(&d, -1, _("Bias: Start <- ")), wxSizerFlags().Center()); adjSliderSizer->Add(adjacentBias, wxSizerFlags(1).Center()); - adjSliderSizer->Add(new wxStaticText(this, -1, _(" -> End")), wxSizerFlags().Center()); + adjSliderSizer->Add(new wxStaticText(&d, -1, _(" -> End")), wxSizerFlags().Center()); auto adjRightSizer = new wxBoxSizer(wxVERTICAL); adjRightSizer->Add(adjBoxes, wxSizerFlags().Expand()); @@ -211,10 +211,10 @@ DialogTimingProcessor::DialogTimingProcessor(agi::Context *c) AdjacentSizer->Add(adjRightSizer); // Keyframes sizer - auto KeyframesSizer = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Keyframe snapping")); + auto KeyframesSizer = new wxStaticBoxSizer(wxHORIZONTAL, &d, _("Keyframe snapping")); auto KeyframesFlexSizer = new wxFlexGridSizer(2,5,5,0); - keysEnable = new wxCheckBox(this, -1, _("E&nable")); + keysEnable = new wxCheckBox(&d, -1, _("E&nable")); keysEnable->SetToolTip(_("Enable snapping of subtitles to nearest keyframe, if distance is within threshold")); keysEnable->SetValue(OPT_GET("Tool/Timing Post Processor/Enable/Keyframe")->GetBool()); KeyframesFlexSizer->Add(keysEnable,0,wxRIGHT|wxEXPAND,10); @@ -226,25 +226,25 @@ DialogTimingProcessor::DialogTimingProcessor(agi::Context *c) keysEnable->Enable(false); } - make_ctrl(this, KeyframesFlexSizer, _("Starts before thres.:"), &beforeStart, keysEnable, + make_ctrl(&d, KeyframesFlexSizer, _("Starts before thres.:"), &beforeStart, keysEnable, _("Threshold for 'before start' distance, that is, how many milliseconds a subtitle must start before a keyframe to snap to it")); - make_ctrl(this, KeyframesFlexSizer, _("Starts after thres.:"), &afterStart, keysEnable, + make_ctrl(&d, KeyframesFlexSizer, _("Starts after thres.:"), &afterStart, keysEnable, _("Threshold for 'after start' distance, that is, how many milliseconds a subtitle must start after a keyframe to snap to it")); KeyframesFlexSizer->AddStretchSpacer(1); - make_ctrl(this, KeyframesFlexSizer, _("Ends before thres.:"), &beforeEnd, keysEnable, + make_ctrl(&d, KeyframesFlexSizer, _("Ends before thres.:"), &beforeEnd, keysEnable, _("Threshold for 'before end' distance, that is, how many milliseconds a subtitle must end before a keyframe to snap to it")); - make_ctrl(this, KeyframesFlexSizer, _("Ends after thres.:"), &afterEnd, keysEnable, + make_ctrl(&d, KeyframesFlexSizer, _("Ends after thres.:"), &afterEnd, keysEnable, _("Threshold for 'after end' distance, that is, how many milliseconds a subtitle must end after a keyframe to snap to it")); KeyframesSizer->Add(KeyframesFlexSizer,0,wxEXPAND); KeyframesSizer->AddStretchSpacer(1); // Button sizer - auto ButtonSizer = CreateStdDialogButtonSizer(wxOK | wxCANCEL | wxHELP); + auto ButtonSizer = d.CreateStdDialogButtonSizer(wxOK | wxCANCEL | wxHELP); ApplyButton = ButtonSizer->GetAffirmativeButton(); ButtonSizer->GetHelpButton()->Bind(wxEVT_BUTTON, bind(&HelpButton::OpenPage, "Timing Processor")); @@ -274,12 +274,12 @@ DialogTimingProcessor::DialogTimingProcessor(agi::Context *c) // Main Sizer auto MainSizer = new wxBoxSizer(wxVERTICAL); MainSizer->Add(TopSizer,1,wxALL|wxEXPAND,5); - SetSizerAndFit(MainSizer); - CenterOnParent(); + d.SetSizerAndFit(MainSizer); + d.CenterOnParent(); - Bind(wxEVT_CHECKBOX, bind(&DialogTimingProcessor::UpdateControls, this)); - Bind(wxEVT_CHECKLISTBOX, bind(&DialogTimingProcessor::UpdateControls, this)); - Bind(wxEVT_BUTTON, &DialogTimingProcessor::OnApply, this, wxID_OK); + d.Bind(wxEVT_CHECKBOX, bind(&DialogTimingProcessor::UpdateControls, this)); + d.Bind(wxEVT_CHECKLISTBOX, bind(&DialogTimingProcessor::UpdateControls, this)); + d.Bind(wxEVT_BUTTON, &DialogTimingProcessor::OnApply, this, wxID_OK); all->Bind(wxEVT_BUTTON, bind(&DialogTimingProcessor::CheckAll, this, true)); none->Bind(wxEVT_BUTTON, bind(&DialogTimingProcessor::CheckAll, this, false)); @@ -303,7 +303,7 @@ void DialogTimingProcessor::UpdateControls() { } void DialogTimingProcessor::OnApply(wxCommandEvent &) { - TransferDataFromWindow(); + d.TransferDataFromWindow(); // Save settings OPT_SET("Audio/Lead/IN")->SetInt(leadIn); OPT_SET("Audio/Lead/OUT")->SetInt(leadOut); @@ -321,7 +321,7 @@ void DialogTimingProcessor::OnApply(wxCommandEvent &) { OPT_SET("Tool/Timing Post Processor/Only Selection")->SetBool(onlySelection->IsChecked()); Process(); - EndModal(0); + d.EndModal(0); } std::vector DialogTimingProcessor::SortDialogues() { @@ -447,5 +447,5 @@ void DialogTimingProcessor::Process() { } void ShowTimingProcessorDialog(agi::Context *c) { - DialogTimingProcessor(c).ShowModal(); + DialogTimingProcessor(c).d.ShowModal(); } diff --git a/src/dialog_video_details.cpp b/src/dialog_video_details.cpp index 7ed9c5141..277928dd8 100644 --- a/src/dialog_video_details.cpp +++ b/src/dialog_video_details.cpp @@ -40,16 +40,9 @@ #include #include -namespace { -/// @class DialogVideoDetails -/// @brief Display information about the video in a dialog -struct DialogVideoDetails final : wxDialog { - DialogVideoDetails(agi::Context *c); -}; +void ShowVideoDetailsDialog(agi::Context *c) { + wxDialog d(c->parent, -1, _("Video Details")); -DialogVideoDetails::DialogVideoDetails(agi::Context *c) -: wxDialog(c->parent , -1, _("Video Details")) -{ auto provider = c->project->VideoProvider(); auto width = provider->GetWidth(); auto height = provider->GetHeight(); @@ -59,8 +52,8 @@ DialogVideoDetails::DialogVideoDetails(agi::Context *c) auto fg = new wxFlexGridSizer(2, 5, 10); auto make_field = [&](wxString const& name, wxString const& value) { - fg->Add(new wxStaticText(this, -1, name), 0, wxALIGN_CENTRE_VERTICAL); - fg->Add(new wxTextCtrl(this, -1, value, wxDefaultPosition, wxSize(300,-1), wxTE_READONLY), 0, wxALIGN_CENTRE_VERTICAL | wxEXPAND); + fg->Add(new wxStaticText(&d, -1, name), 0, wxALIGN_CENTRE_VERTICAL); + fg->Add(new wxTextCtrl(&d, -1, value, wxDefaultPosition, wxSize(300,-1), wxTE_READONLY), 0, wxALIGN_CENTRE_VERTICAL | wxEXPAND); }; make_field(_("File name:"), c->project->VideoName().wstring()); make_field(_("FPS:"), fmt_wx("%.3f", fps.FPS())); @@ -69,18 +62,14 @@ DialogVideoDetails::DialogVideoDetails(agi::Context *c) framecount, AssTime(fps.TimeAtFrame(framecount - 1)).GetAssFormated(true))); make_field(_("Decoder:"), to_wx(provider->GetDecoderName())); - wxStaticBoxSizer *video_sizer = new wxStaticBoxSizer(wxVERTICAL, this, _("Video")); + auto video_sizer = new wxStaticBoxSizer(wxVERTICAL, &d, _("Video")); video_sizer->Add(fg); auto main_sizer = new wxBoxSizer(wxVERTICAL); main_sizer->Add(video_sizer, 1, wxALL|wxEXPAND, 5); - main_sizer->Add(CreateSeparatedButtonSizer(wxOK), 0, wxALL|wxEXPAND, 5); - SetSizerAndFit(main_sizer); + main_sizer->Add(d.CreateSeparatedButtonSizer(wxOK), 0, wxALL|wxEXPAND, 5); + d.SetSizerAndFit(main_sizer); - CenterOnParent(); -} -} - -void ShowVideoDetailsDialog(agi::Context *c) { - DialogVideoDetails(c).ShowModal(); + d.CenterOnParent(); + d.ShowModal(); } diff --git a/src/dialog_video_properties.cpp b/src/dialog_video_properties.cpp index 3d2dad45b..272fcb107 100644 --- a/src/dialog_video_properties.cpp +++ b/src/dialog_video_properties.cpp @@ -39,46 +39,46 @@ enum { FIX_RESAMPLE }; -class Prompt : public wxDialog { -public: - Prompt(wxWindow *parent, bool ar_changed, int sx, int sy, int vx, int vy) - : wxDialog(parent, -1, _("Resolution mismatch")) - { - auto label_text = fmt_tl("The resolution of the loaded video and the resolution specified for the subtitles don't match.\n\nVideo resolution:\t%d x %d\nScript resolution:\t%d x %d\n\nChange subtitles resolution to match video?", vx, vy, sx, sy); +int prompt(wxWindow *parent, bool ar_changed, int sx, int sy, int vx, int vy) { + wxDialog d(parent, -1, _("Resolution mismatch")); - auto sizer = new wxBoxSizer(wxVERTICAL); - sizer->Add(new wxStaticText(this, -1, label_text), wxSizerFlags().Border()); + auto label_text = fmt_tl("The resolution of the loaded video and the resolution specified for the subtitles don't match.\n\nVideo resolution:\t%d x %d\nScript resolution:\t%d x %d\n\nChange subtitles resolution to match video?", vx, vy, sx, sy); - wxRadioBox *rb; - if (ar_changed) { - wxString choices[] = { - _("Set to video resolution"), - _("Resample script (stretch to new aspect ratio)"), - _("Resample script (add borders)"), - _("Resample script (remove borders)") - }; - rb = new wxRadioBox(this, -1, "", wxDefaultPosition, wxDefaultSize, 4, choices, 1); - } - else { - wxString choices[] = { - _("Set to video resolution"), - _("Resample script"), - }; - rb = new wxRadioBox(this, -1, "", wxDefaultPosition, wxDefaultSize, 2, choices, 1); - } - sizer->Add(rb, wxSizerFlags().Border(wxALL & ~wxTOP).Expand()); - sizer->Add(CreateStdDialogButtonSizer(wxOK | wxCANCEL | wxHELP), wxSizerFlags().Border().Expand()); + auto sizer = new wxBoxSizer(wxVERTICAL); + sizer->Add(new wxStaticText(&d, -1, label_text), wxSizerFlags().Border()); - unsigned int sel = OPT_GET("Video/Last Script Resolution Mismatch Choice")->GetInt(); - rb->SetSelection(std::min(sel - 1, rb->GetCount())); - - SetSizerAndFit(sizer); - CenterOnParent(); - - Bind(wxEVT_BUTTON, [=](wxCommandEvent&) { EndModal(rb->GetSelection() + 1); }, wxID_OK); - Bind(wxEVT_BUTTON, [=](wxCommandEvent&) { EndModal(0); }, wxID_CANCEL); + wxRadioBox *rb; + if (ar_changed) { + wxString choices[] = { + _("Set to video resolution"), + _("Resample script (stretch to new aspect ratio)"), + _("Resample script (add borders)"), + _("Resample script (remove borders)") + }; + rb = new wxRadioBox(&d, -1, "", wxDefaultPosition, wxDefaultSize, 4, choices, 1); } -}; + else { + wxString choices[] = { + _("Set to video resolution"), + _("Resample script"), + }; + rb = new wxRadioBox(&d, -1, "", wxDefaultPosition, wxDefaultSize, 2, choices, 1); + } + sizer->Add(rb, wxSizerFlags().Border(wxALL & ~wxTOP).Expand()); + sizer->Add(d.CreateStdDialogButtonSizer(wxOK | wxCANCEL | wxHELP), wxSizerFlags().Border().Expand()); + + unsigned int sel = OPT_GET("Video/Last Script Resolution Mismatch Choice")->GetInt(); + rb->SetSelection(std::min(sel - 1, rb->GetCount())); + + d.SetSizerAndFit(sizer); + d.CenterOnParent(); + + d.Bind(wxEVT_BUTTON, [&](wxCommandEvent&) { d.EndModal(rb->GetSelection() + 1); }, wxID_OK); + d.Bind(wxEVT_BUTTON, [&](wxCommandEvent&) { d.EndModal(0); }, wxID_CANCEL); + + return d.ShowModal(); +} + bool update_video_properties(AssFile *file, const AsyncVideoProvider *new_provider, wxWindow *parent) { bool commit_subs = false; @@ -141,7 +141,7 @@ bool update_video_properties(AssFile *file, const AsyncVideoProvider *new_provid } case MISMATCH_PROMPT: - int res = Prompt(parent, ar_changed, sx, sy, vx, vy).ShowModal(); + int res = prompt(parent, ar_changed, sx, sy, vx, vy); if (res == FIX_IGNORE) return commit_subs; OPT_SET("Video/Last Script Resolution Mismatch Choice")->SetInt(res); diff --git a/src/subtitle_format_ebu3264.cpp b/src/subtitle_format_ebu3264.cpp index 2e3d98172..d8ab6ee16 100644 --- a/src/subtitle_format_ebu3264.cpp +++ b/src/subtitle_format_ebu3264.cpp @@ -611,7 +611,7 @@ namespace // Disable the busy cursor set by the exporter while the dialog is visible wxEndBusyCursor(); - int res = EbuExportConfigurationDialog(parent, s).ShowModal(); + int res = ShowEbuExportConfigurationDialog(parent, s); wxBeginBusyCursor(); if (res != wxID_OK)