Eliminate pointless wxDialog subclasses

A lot of the wxDialog subclasses don't actually override any virtual
functions, so there's no particular need for them to be subclasses at
all, and wxDialog's vtable is so huge that they actually contribute
measureable to the size of the executable.
This commit is contained in:
Thomas Goyne 2014-05-30 17:05:25 -07:00
parent fb27c98ddd
commit 76f0afecaf
17 changed files with 394 additions and 436 deletions

View File

@ -40,114 +40,102 @@
#include <wx/stattext.h> #include <wx/stattext.h>
#include <wx/textctrl.h> #include <wx/textctrl.h>
namespace { void ShowAboutDialog(wxWindow *parent) {
struct AboutScreen : wxDialog { wxDialog d(parent, -1, _("About Aegisub"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX);
AboutScreen(wxWindow *parent)
: wxDialog(parent, -1, _("About Aegisub"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX, _("About Aegisub")) wxString translatorCredit = _("Translated into LANGUAGE by PERSON\n");
{ if (translatorCredit == "Translated into LANGUAGE by PERSON\n")
// Generate library string translatorCredit.clear();
wxString libString = "Aegisub includes portions from the following other projects:\n";
libString += " wxWidgets - Copyright (c) Julian Smart, Robert Roebling et al;\n"; // Generate about string
libString += " wxStyledTextCtrl - Copyright (c) Robin Dunn, Neil Hodgson;\n"; wxString aboutString = wxString("Aegisub ") + GetAegisubShortVersionString() + ".\n"
libString += " Scintilla - Copyright (c) Neil Hodgson;\n"; "Copyright (c) 2005-2014 Rodrigo Braz Monteiro, Niels Martin Hansen, Thomas Goyne et al.\n\n"
libString += " Boost - Copyright (c) Beman Dawes, David Abrahams et al;\n"; "Programmers:\n"
libString += " UniversalCharDet - Copyright (c) Netscape Communications Corp.;\n"; " Alysson Souza e Silva\n"
libString += " ICU - Copyright (c) International Business Machines Corp.;\n"; " Amar Takhar\n"
libString += " Lua - Copyright (c) Lua.org, PUC-Rio;\n"; " Dan Donovan\n"
libString += " LuaJIT - Copyright (c) Mike Pall;\n"; " Daniel Moscoviter\n"
libString += " luabins - Copyright (c) Alexander Gladysh;\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 #ifdef WITH_HUNSPELL
libString += " Hunspell - Copyright (c) Kevin Hendricks;\n"; " Hunspell - Copyright (c) Kevin Hendricks;\n"
#endif #endif
#ifdef WITH_PORTAUDIO #ifdef WITH_PORTAUDIO
libString += " PortAudio - Copyright (c) Ross Bencina, Phil Burk;\n"; " PortAudio - Copyright (c) Ross Bencina, Phil Burk;\n"
#endif #endif
#ifdef WITH_FFMS2 #ifdef WITH_FFMS2
libString += " FFmpeg - Copyright (c) Fabrice Bellard;\n"; " FFmpeg - Copyright (c) Fabrice Bellard;\n"
libString += " FFMS2 - Copyright (c) Fredrik Mellbin;\n"; " FFMS2 - Copyright (c) Fredrik Mellbin;\n"
#endif #endif
#ifdef WITH_AVISYNTH #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 #endif
#ifdef WITH_CSRI #ifdef WITH_CSRI
libString += " csri - Copyright (c) David Lamparter;\n"; " csri - Copyright (c) David Lamparter;\n"
# ifdef __WINDOWS__ # ifdef __WINDOWS__
libString += " vsfilter - Copyright (c) Gabest et al;\n"; " vsfilter - Copyright (c) Gabest et al;\n"
# endif # endif
#endif #endif
libString += " libass - Copyright (c) Evgeniy Stepanov, Grigori Goronzy;\n"; " libass - Copyright (c) Evgeniy Stepanov, Grigori Goronzy;\n"
#ifdef __WINDOWS__ " Matroska Parser - Copyright (c) Mike Matsnev;\n"
libString += " Matroska Parser - Copyright (c) Mike Matsnev;\n"; " Freetype - Copyright (c) David Turner, Robert Wilhelm, Werner Lemberg;\n"
#endif " Fontconfig - Copyright (c) Keith Packard et al;\n"
libString += " Freetype - Copyright (c) David Turner, Robert Wilhelm, Werner Lemberg;\n";
libString += " Fontconfig - Copyright (c) Keith Packard et al;\n";
#ifdef WITH_FFTW3 #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 #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"); // Replace copyright symbol
if (translatorCredit == "Translated into LANGUAGE by PERSON\n") translatorCredit.Clear(); wxChar copySymbol = 0xA9;
aboutString.Replace("(c)", wxString(copySymbol));
// Generate about string wxTextCtrl *textctrl = new wxTextCtrl(&d, -1, aboutString, wxDefaultPosition, wxSize(-1, 200), wxTE_MULTILINE | wxTE_READONLY | wxBORDER_NONE);
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());
// Replace copyright symbol wxSizer *MainSizer = new wxBoxSizer(wxVERTICAL);
wxChar copySymbol = 0xA9; MainSizer->Add(new wxStaticBitmap(&d, -1, GETIMAGE(splash)), 0, wxCENTER, 0);
aboutString.Replace("(c)", wxString(copySymbol)); 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); d.SetSizerAndFit(MainSizer);
d.CentreOnParent();
wxSizer *MainSizer = new wxBoxSizer(wxVERTICAL); d.ShowModal();
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();
} }

View File

@ -43,7 +43,8 @@
#include <wx/sizer.h> #include <wx/sizer.h>
namespace { namespace {
class DialogAttachments final : public wxDialog { struct DialogAttachments {
wxDialog d;
AssFile *ass; AssFile *ass;
wxListView *listView; wxListView *listView;
@ -64,18 +65,18 @@ public:
}; };
DialogAttachments::DialogAttachments(wxWindow *parent, AssFile *ass) DialogAttachments::DialogAttachments(wxWindow *parent, AssFile *ass)
: wxDialog(parent, -1, _("Attachment List"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE) : d(parent, -1, _("Attachment List"))
, ass(ass) , 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(); UpdateList();
auto attachFont = new wxButton(this, -1, _("Attach &Font")); auto attachFont = new wxButton(&d, -1, _("Attach &Font"));
auto attachGraphics = new wxButton(this, -1, _("Attach &Graphics")); auto attachGraphics = new wxButton(&d, -1, _("Attach &Graphics"));
extractButton = new wxButton(this, -1, _("E&xtract")); extractButton = new wxButton(&d, -1, _("E&xtract"));
deleteButton = new wxButton(this, -1, _("&Delete")); deleteButton = new wxButton(&d, -1, _("&Delete"));
extractButton->Enable(false); extractButton->Enable(false);
deleteButton->Enable(false); deleteButton->Enable(false);
@ -84,14 +85,14 @@ DialogAttachments::DialogAttachments(wxWindow *parent, AssFile *ass)
buttonSizer->Add(attachGraphics, 1); buttonSizer->Add(attachGraphics, 1);
buttonSizer->Add(extractButton, 1); buttonSizer->Add(extractButton, 1);
buttonSizer->Add(deleteButton, 1); buttonSizer->Add(deleteButton, 1);
buttonSizer->Add(new HelpButton(this, "Attachment Manager"), 1, wxLEFT, 5); buttonSizer->Add(new HelpButton(&d, "Attachment Manager"), 1, wxLEFT, 5);
buttonSizer->Add(new wxButton(this, wxID_CANCEL, _("&Close")), 1); buttonSizer->Add(new wxButton(&d, wxID_CANCEL, _("&Close")), 1);
auto mainSizer = new wxBoxSizer(wxVERTICAL); auto mainSizer = new wxBoxSizer(wxVERTICAL);
mainSizer->Add(listView, 1, wxTOP | wxLEFT | wxRIGHT | wxEXPAND, 5); mainSizer->Add(listView, 1, wxTOP | wxLEFT | wxRIGHT | wxEXPAND, 5);
mainSizer->Add(buttonSizer, 0, wxALL | wxEXPAND, 5); mainSizer->Add(buttonSizer, 0, wxALL | wxEXPAND, 5);
SetSizerAndFit(mainSizer); d.SetSizerAndFit(mainSizer);
CenterOnParent(); d.CenterOnParent();
attachFont->Bind(wxEVT_BUTTON, &DialogAttachments::OnAttachFont, this); attachFont->Bind(wxEVT_BUTTON, &DialogAttachments::OnAttachFont, this);
attachGraphics->Bind(wxEVT_BUTTON, &DialogAttachments::OnAttachGraphics, 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 &) { void DialogAttachments::OnAttachFont(wxCommandEvent &) {
wxFileDialog diag(this, wxFileDialog diag(&d,
_("Choose file to be attached"), _("Choose file to be attached"),
to_wx(OPT_GET("Path/Fonts Collector Destination")->GetString()), "", "Font Files (*.ttf)|*.ttf", to_wx(OPT_GET("Path/Fonts Collector Destination")->GetString()), "", "Font Files (*.ttf)|*.ttf",
wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_MULTIPLE); wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_MULTIPLE);
@ -142,7 +143,7 @@ void DialogAttachments::OnAttachFont(wxCommandEvent &) {
} }
void DialogAttachments::OnAttachGraphics(wxCommandEvent &) { void DialogAttachments::OnAttachGraphics(wxCommandEvent &) {
wxFileDialog diag(this, wxFileDialog diag(&d,
_("Choose file to be attached"), _("Choose file to be attached"),
"", "", "", "",
"Graphic Files (*.bmp, *.gif, *.jpg, *.ico, *.wmf)|*.bmp;*.gif;*.jpg;*.ico;*.wmf", "Graphic Files (*.bmp, *.gif, *.jpg, *.ico, *.wmf)|*.bmp;*.gif;*.jpg;*.ico;*.wmf",
@ -167,7 +168,7 @@ void DialogAttachments::OnExtract(wxCommandEvent &) {
"Path/Fonts Collector Destination", "Path/Fonts Collector Destination",
ass->Attachments[i].GetFileName(), ass->Attachments[i].GetFileName(),
".ttf", "Font Files (*.ttf)|*.ttf", ".ttf", "Font Files (*.ttf)|*.ttf",
this); &d);
fullPath = true; fullPath = true;
} }
if (path.empty()) return; if (path.empty()) return;
@ -200,5 +201,5 @@ void DialogAttachments::OnListClick(wxListEvent &) {
} }
void ShowAttachmentsDialog(wxWindow *parent, AssFile *file) { void ShowAttachmentsDialog(wxWindow *parent, AssFile *file) {
DialogAttachments(parent, file).ShowModal(); DialogAttachments(parent, file).d.ShowModal();
} }

View File

@ -45,7 +45,8 @@ struct AutosaveFile {
std::vector<Version> versions; std::vector<Version> versions;
}; };
class DialogAutosave final : public wxDialog { class DialogAutosave {
wxDialog d;
std::vector<AutosaveFile> files; std::vector<AutosaveFile> files;
wxListBox *file_list; wxListBox *file_list;
@ -57,34 +58,36 @@ class DialogAutosave final : public wxDialog {
public: public:
DialogAutosave(wxWindow *parent); DialogAutosave(wxWindow *parent);
std::string ChosenFile() const; std::string ChosenFile() const;
int ShowModal() { return d.ShowModal(); }
}; };
DialogAutosave::DialogAutosave(wxWindow *parent) 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")); wxSizer *files_box = new wxStaticBoxSizer(wxVERTICAL, &d, _("Files"));
file_list = new wxListBox(this, -1); file_list = new wxListBox(&d, -1);
file_list->Bind(wxEVT_LISTBOX, &DialogAutosave::OnSelectFile, this); file_list->Bind(wxEVT_LISTBOX, &DialogAutosave::OnSelectFile, this);
files_box->Add(file_list, wxSizerFlags(1).Expand().Border()); files_box->Add(file_list, wxSizerFlags(1).Expand().Border());
wxSizer *versions_box = new wxStaticBoxSizer(wxVERTICAL, this, _("Versions")); wxSizer *versions_box = new wxStaticBoxSizer(wxVERTICAL, &d, _("Versions"));
version_list = new wxListBox(this, -1); version_list = new wxListBox(&d, -1);
version_list->Bind(wxEVT_LISTBOX_DCLICK, [=](wxCommandEvent&) { EndModal(wxID_OK); }); version_list->Bind(wxEVT_LISTBOX_DCLICK, [=](wxCommandEvent&) { d.EndModal(wxID_OK); });
versions_box->Add(version_list, wxSizerFlags(1).Expand().Border()); versions_box->Add(version_list, wxSizerFlags(1).Expand().Border());
wxSizer *boxes_sizer = new wxBoxSizer(wxHORIZONTAL); wxSizer *boxes_sizer = new wxBoxSizer(wxHORIZONTAL);
boxes_sizer->Add(files_box, wxSizerFlags(1).Expand().Border()); boxes_sizer->Add(files_box, wxSizerFlags(1).Expand().Border());
boxes_sizer->Add(versions_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")); btn_sizer->GetAffirmativeButton()->SetLabelText(_("Open"));
wxSizer *main_sizer = new wxBoxSizer(wxVERTICAL); wxSizer *main_sizer = new wxBoxSizer(wxVERTICAL);
main_sizer->Add(boxes_sizer, wxSizerFlags(1).Expand().Border()); main_sizer->Add(boxes_sizer, wxSizerFlags(1).Expand().Border());
main_sizer->Add(btn_sizer, wxSizerFlags().Expand().Border(wxALL & ~wxTOP)); main_sizer->Add(btn_sizer, wxSizerFlags().Expand().Border(wxALL & ~wxTOP));
SetSizer(main_sizer); d.SetSizer(main_sizer);
std::map<wxString, AutosaveFile> files_map; std::map<wxString, AutosaveFile> files_map;
Populate(files_map, OPT_GET("Path/Auto/Save")->GetString(), ".AUTOSAVE.ass", "%s"); Populate(files_map, OPT_GET("Path/Auto/Save")->GetString(), ".AUTOSAVE.ass", "%s");

View File

@ -37,7 +37,9 @@
#include <wx/valgen.h> #include <wx/valgen.h>
namespace { namespace {
struct DialogDummyVideo final : wxDialog { struct DialogDummyVideo {
wxDialog d;
double fps = OPT_GET("Video/Dummy/FPS")->GetDouble(); double fps = OPT_GET("Video/Dummy/FPS")->GetDouble();
int width = OPT_GET("Video/Dummy/Last/Width")->GetInt(); int width = OPT_GET("Video/Dummy/Last/Width")->GetInt();
int height = OPT_GET("Video/Dummy/Last/Height")->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) 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); auto res_sizer = new wxBoxSizer(wxHORIZONTAL);
res_sizer->Add(spin_ctrl(this, 1, 10000, &width), wxSizerFlags(1).Expand()); res_sizer->Add(spin_ctrl(&d, 1, 10000, &width), wxSizerFlags(1).Expand());
res_sizer->Add(new wxStaticText(this, -1, " x "), wxSizerFlags().Center()); res_sizer->Add(new wxStaticText(&d, -1, " x "), wxSizerFlags().Center());
res_sizer->Add(spin_ctrl(this, 1, 10000, &height), wxSizerFlags(1).Expand()); res_sizer->Add(spin_ctrl(&d, 1, 10000, &height), wxSizerFlags(1).Expand());
auto color_sizer = new wxBoxSizer(wxHORIZONTAL); 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(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); 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("", res_sizer);
AddCtrl(_("Color:"), color_sizer); AddCtrl(_("Color:"), color_sizer);
AddCtrl(_("Frame rate (fps):"), spin_ctrl(this, .1, 1000.0, &fps)); AddCtrl(_("Frame rate (fps):"), spin_ctrl(&d, .1, 1000.0, &fps));
AddCtrl(_("Duration (frames):"), spin_ctrl(this, 2, 36000000, &length)); // Ten hours of 1k FPS AddCtrl(_("Duration (frames):"), spin_ctrl(&d, 2, 36000000, &length)); // Ten hours of 1k FPS
AddCtrl("", length_display = new wxStaticText(this, -1, "")); 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")); btn_sizer->GetHelpButton()->Bind(wxEVT_BUTTON, std::bind(&HelpButton::OpenPage, "Dummy Video"));
auto main_sizer = new wxBoxSizer(wxVERTICAL); auto main_sizer = new wxBoxSizer(wxVERTICAL);
main_sizer->Add(sizer, wxSizerFlags(1).Border().Expand()); 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()); main_sizer->Add(btn_sizer, wxSizerFlags().Expand().Border());
UpdateLengthDisplay(); UpdateLengthDisplay();
SetSizerAndFit(main_sizer); d.SetSizerAndFit(main_sizer);
CenterOnParent(); 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(); }); color_btn->Bind(EVT_COLOR, [=](wxThreadEvent& e) { color = color_btn->GetColor(); });
Bind(wxEVT_SPINCTRL, [=](wxCommandEvent&) { d.Bind(wxEVT_SPINCTRL, [&](wxCommandEvent&) {
TransferDataFromWindow(); d.TransferDataFromWindow();
UpdateLengthDisplay(); UpdateLengthDisplay();
}); });
} }
@ -146,16 +148,16 @@ void DialogDummyVideo::AddCtrl(wxString const& label, T *ctrl) {
if (!label) if (!label)
sizer->AddStretchSpacer(); sizer->AddStretchSpacer();
else 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()); sizer->Add(ctrl, wxSizerFlags().Expand().Center().Left());
} }
void DialogDummyVideo::OnResolutionShortcut(wxCommandEvent &e) { void DialogDummyVideo::OnResolutionShortcut(wxCommandEvent &e) {
TransferDataFromWindow(); d.TransferDataFromWindow();
int rs = e.GetSelection(); int rs = e.GetSelection();
width = resolutions[rs].width; width = resolutions[rs].width;
height = resolutions[rs].height; height = resolutions[rs].height;
TransferDataToWindow(); d.TransferDataToWindow();
} }
void DialogDummyVideo::UpdateLengthDisplay() { void DialogDummyVideo::UpdateLengthDisplay() {
@ -165,7 +167,7 @@ void DialogDummyVideo::UpdateLengthDisplay() {
std::string CreateDummyVideo(wxWindow *parent) { std::string CreateDummyVideo(wxWindow *parent) {
DialogDummyVideo dlg(parent); DialogDummyVideo dlg(parent);
if (dlg.ShowModal() != wxID_OK) if (dlg.d.ShowModal() != wxID_OK)
return ""; return "";
OPT_SET("Video/Dummy/FPS")->SetDouble(dlg.fps); OPT_SET("Video/Dummy/FPS")->SetDouble(dlg.fps);

View File

@ -51,7 +51,8 @@
#include <wx/textctrl.h> #include <wx/textctrl.h>
namespace { namespace {
class DialogExport final : public wxDialog { class DialogExport {
wxDialog d;
agi::Context *c; agi::Context *c;
/// The export transform engine /// The export transform engine
@ -79,6 +80,7 @@ class DialogExport final : public wxDialog {
public: public:
DialogExport(agi::Context *c); DialogExport(agi::Context *c);
~DialogExport(); ~DialogExport();
void ShowModal() { d.ShowModal(); }
}; };
// Swap the items at idx and idx + 1 // 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) 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) , c(c)
, exporter(c) , exporter(c)
{ {
SetIcon(GETICON(export_menu_16)); d.SetIcon(GETICON(export_menu_16));
SetExtraStyle(wxWS_EX_VALIDATE_RECURSIVELY); d.SetExtraStyle(wxWS_EX_VALIDATE_RECURSIVELY);
std::vector<std::string> filters = exporter.GetAllFilterNames(); std::vector<std::string> 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_CHECKLISTBOX, [=](wxCommandEvent&) { RefreshOptions(); });
filter_list->Bind(wxEVT_LISTBOX, &DialogExport::OnChange, this); filter_list->Bind(wxEVT_LISTBOX, &DialogExport::OnChange, this);
@ -118,10 +120,10 @@ DialogExport::DialogExport(agi::Context *c)
filter_list->Check(distance(begin(filters), it)); filter_list->Check(distance(begin(filters), it));
} }
wxButton *btn_up = new wxButton(this, -1, _("Move &Up"), wxDefaultPosition, wxSize(90, -1)); wxButton *btn_up = new wxButton(&d, -1, _("Move &Up"), wxDefaultPosition, wxSize(90, -1));
wxButton *btn_down = new wxButton(this, -1, _("Move &Down"), wxDefaultPosition, wxSize(90, -1)); wxButton *btn_down = new wxButton(&d, -1, _("Move &Down"), wxDefaultPosition, wxSize(90, -1));
wxButton *btn_all = new wxButton(this, -1, _("Select &All"), wxDefaultPosition, wxSize(80, -1)); wxButton *btn_all = new wxButton(&d, -1, _("Select &All"), wxDefaultPosition, wxSize(80, -1));
wxButton *btn_none = new wxButton(this, -1, _("Select &None"), 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_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); }); 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_all, wxSizerFlags(1).Expand());
top_buttons->Add(btn_none, 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 // Charset dropdown list
wxStaticText *charset_list_label = new wxStaticText(this, -1, _("Text encoding:")); wxStaticText *charset_list_label = new wxStaticText(&d, -1, _("Text encoding:"));
charset_list = new wxChoice(this, -1, wxDefaultPosition, wxDefaultSize, agi::charset::GetEncodingsList<wxArrayString>()); charset_list = new wxChoice(&d, -1, wxDefaultPosition, wxDefaultSize, agi::charset::GetEncodingsList<wxArrayString>());
wxSizer *charset_list_sizer = new wxBoxSizer(wxHORIZONTAL); wxSizer *charset_list_sizer = new wxBoxSizer(wxHORIZONTAL);
charset_list_sizer->Add(charset_list_label, wxSizerFlags().Center().Border(wxRIGHT)); charset_list_sizer->Add(charset_list_label, wxSizerFlags().Center().Border(wxRIGHT));
charset_list_sizer->Add(charset_list, wxSizerFlags(1).Expand()); charset_list_sizer->Add(charset_list, wxSizerFlags(1).Expand());
if (!charset_list->SetStringSelection(to_wx(c->ass->Properties.export_encoding))) if (!charset_list->SetStringSelection(to_wx(c->ass->Properties.export_encoding)))
charset_list->SetStringSelection("Unicode (UTF-8)"); 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(filter_list, wxSizerFlags(1).Expand());
top_sizer->Add(top_buttons, wxSizerFlags(0).Expand()); top_sizer->Add(top_buttons, wxSizerFlags(0).Expand());
top_sizer->Add(filter_description, wxSizerFlags(0).Expand().Border(wxTOP)); top_sizer->Add(filter_description, wxSizerFlags(0).Expand().Border(wxTOP));
top_sizer->Add(charset_list_sizer, 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...")); btn_sizer->GetAffirmativeButton()->SetLabelText(_("Export..."));
Bind(wxEVT_BUTTON, &DialogExport::OnProcess, this, wxID_OK); d.Bind(wxEVT_BUTTON, &DialogExport::OnProcess, this, wxID_OK);
Bind(wxEVT_BUTTON, std::bind(&HelpButton::OpenPage, "Export"), wxID_HELP); d.Bind(wxEVT_BUTTON, std::bind(&HelpButton::OpenPage, "Export"), wxID_HELP);
wxSizer *horz_sizer = new wxBoxSizer(wxHORIZONTAL); wxSizer *horz_sizer = new wxBoxSizer(wxHORIZONTAL);
opt_sizer = new wxBoxSizer(wxVERTICAL); 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(top_sizer, wxSizerFlags().Expand().Border(wxALL & ~wxRIGHT));
horz_sizer->Add(opt_sizer, wxSizerFlags(1).Expand().Border(wxALL & ~wxLEFT)); horz_sizer->Add(opt_sizer, wxSizerFlags(1).Expand().Border(wxALL & ~wxLEFT));
wxSizer *main_sizer = new wxBoxSizer(wxVERTICAL); wxSizer *main_sizer = new wxBoxSizer(wxVERTICAL);
main_sizer->Add(horz_sizer, wxSizerFlags(1).Expand()); main_sizer->Add(horz_sizer, wxSizerFlags(1).Expand());
main_sizer->Add(btn_sizer, wxSizerFlags().Expand().Border(wxALL & ~wxTOP)); main_sizer->Add(btn_sizer, wxSizerFlags().Expand().Border(wxALL & ~wxTOP));
SetSizerAndFit(main_sizer); d.SetSizerAndFit(main_sizer);
RefreshOptions(); RefreshOptions();
CenterOnParent(); d.CenterOnParent();
} }
DialogExport::~DialogExport() { DialogExport::~DialogExport() {
@ -182,9 +184,9 @@ DialogExport::~DialogExport() {
} }
void DialogExport::OnProcess(wxCommandEvent &) { 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; if (filename.empty()) return;
for (size_t i = 0; i < filter_list->GetCount(); ++i) { for (size_t i = 0; i < filter_list->GetCount(); ++i) {
@ -195,27 +197,27 @@ void DialogExport::OnProcess(wxCommandEvent &) {
try { try {
wxBusyCursor busy; wxBusyCursor busy;
c->ass->Properties.export_encoding = from_wx(charset_list->GetStringSelection()); 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 (agi::UserCancelException const&) {
} }
catch (const char *error) { 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) { 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) { 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) { 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 (...) { 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 &) { void DialogExport::OnChange(wxCommandEvent &) {
@ -238,8 +240,8 @@ void DialogExport::RefreshOptions() {
if (wxSizer *sizer = exporter.GetSettingsSizer(from_wx(filter_list->GetString(i)))) if (wxSizer *sizer = exporter.GetSettingsSizer(from_wx(filter_list->GetString(i))))
opt_sizer->Show(sizer, filter_list->IsChecked(i), true); opt_sizer->Show(sizer, filter_list->IsChecked(i), true);
} }
Layout(); d.Layout();
GetSizer()->Fit(this); d.GetSizer()->Fit(&d);
} }
} }

View File

@ -33,6 +33,7 @@
#include <wx/checkbox.h> #include <wx/checkbox.h>
#include <wx/combobox.h> #include <wx/combobox.h>
#include <wx/dialog.h>
#include <wx/msgdlg.h> #include <wx/msgdlg.h>
#include <wx/radiobox.h> #include <wx/radiobox.h>
#include <wx/sizer.h> #include <wx/sizer.h>
@ -92,11 +93,12 @@ namespace {
TimecodeValidator(EbuTimecode *target) : value(target) { assert(target); } TimecodeValidator(EbuTimecode *target) : value(target) { assert(target); }
TimecodeValidator(TimecodeValidator const& other) : wxValidator(other), value(other.value) { } TimecodeValidator(TimecodeValidator const& other) : wxValidator(other), value(other.value) { }
}; };
} // namespace { } // namespace {
EbuExportConfigurationDialog::EbuExportConfigurationDialog(wxWindow *owner, EbuExportSettings &s) int ShowEbuExportConfigurationDialog(wxWindow *owner, EbuExportSettings &s) {
: wxDialog(owner, -1, _("Export to EBU STL format")) wxDialog d(owner, -1, _("Export to EBU STL format"));
{
wxString tv_standards[] = { wxString tv_standards[] = {
_("23.976 fps (non-standard, STL24.01)"), _("23.976 fps (non-standard, STL24.01)"),
_("24 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)"), _("29.97 fps (dropframe, STL30.01)"),
_("30 fps (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"); wxTextCtrl *timecode_offset_entry = new wxTextCtrl(&d, -1, "00:00:00:00");
wxCheckBox *inclusive_end_times_check = new wxCheckBox(this, -1, _("Out-times are inclusive")); wxCheckBox *inclusive_end_times_check = new wxCheckBox(&d, -1, _("Out-times are inclusive"));
wxString text_encodings[] = { wxString text_encodings[] = {
_("ISO 6937-2 (Latin/Western Europe)"), _("ISO 6937-2 (Latin/Western Europe)"),
@ -118,7 +120,7 @@ EbuExportConfigurationDialog::EbuExportConfigurationDialog(wxWindow *owner, EbuE
_("ISO 8859-8 (Hebrew)"), _("ISO 8859-8 (Hebrew)"),
_("UTF-8 Unicode (non-standard)") _("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[] = { wxString wrap_modes[] = {
_("Automatically wrap long lines (ASS)"), _("Automatically wrap long lines (ASS)"),
@ -127,9 +129,9 @@ EbuExportConfigurationDialog::EbuExportConfigurationDialog(wxWindow *owner, EbuE
_("Skip lines that are too long") _("Skip lines that are too long")
}; };
wxSpinCtrl *max_line_length_ctrl = new wxSpinCtrl(this, -1, wxString(), wxDefaultPosition, wxSize(65, -1)); wxSpinCtrl *max_line_length_ctrl = new wxSpinCtrl(&d, -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); 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(this, -1, _("Translate alignments")); wxCheckBox *translate_alignments_check = new wxCheckBox(&d, -1, _("Translate alignments"));
max_line_length_ctrl->SetRange(10, 99); max_line_length_ctrl->SetRange(10, 99);
@ -139,26 +141,26 @@ EbuExportConfigurationDialog::EbuExportConfigurationDialog(wxWindow *owner, EbuE
_("Level-2 teletext") _("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); 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); max_line_length_labelled->Add(max_line_length_ctrl, 0, 0, 0);
wxSizer *timecode_offset_labelled = new wxBoxSizer(wxHORIZONTAL); 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); 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(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(wrap_mode_ctrl, 0, wxEXPAND | (wxALL & ~wxTOP), 6);
text_formatting_sizer->Add(translate_alignments_check, 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(timecode_offset_labelled, 0, wxEXPAND | (wxALL & ~wxTOP), 6);
timecode_control_sizer->Add(inclusive_end_times_check, 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); display_standard_sizer->Add(display_standard_ctrl, 0, wxEXPAND | (wxALL & ~wxTOP), 6);
wxSizer *left_column = new wxBoxSizer(wxVERTICAL); wxSizer *left_column = new wxBoxSizer(wxVERTICAL);
@ -175,18 +177,18 @@ EbuExportConfigurationDialog::EbuExportConfigurationDialog(wxWindow *owner, EbuE
vertical_split_sizer->Add(right_column, 0, 0, 0); vertical_split_sizer->Add(right_column, 0, 0, 0);
wxSizer *buttons_sizer = new wxBoxSizer(wxHORIZONTAL); wxSizer *buttons_sizer = new wxBoxSizer(wxHORIZONTAL);
// Developers are requested to leave this message in! Intentionally not translatable. // Developers are requested to leave &d message in! Intentionally not translatable.
wxStaticText *sponsor_label = new wxStaticText(this, -1, "EBU STL format writing sponsored by Bandai"); wxStaticText *sponsor_label = new wxStaticText(&d, -1, "EBU STL format writing sponsored by Bandai");
sponsor_label->Enable(false); sponsor_label->Enable(false);
buttons_sizer->Add(sponsor_label, 1, wxALIGN_BOTTOM, 0); 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); wxSizer *main_sizer = new wxBoxSizer(wxVERTICAL);
main_sizer->Add(vertical_split_sizer, 0, wxEXPAND|wxALL, 12); main_sizer->Add(vertical_split_sizer, 0, wxEXPAND|wxALL, 12);
main_sizer->Add(buttons_sizer, 0, wxEXPAND | (wxALL & ~wxTOP), 12); main_sizer->Add(buttons_sizer, 0, wxEXPAND | (wxALL & ~wxTOP), 12);
SetSizerAndFit(main_sizer); d.SetSizerAndFit(main_sizer);
CenterOnParent(); d.CenterOnParent();
// set up validators to move data in and out // set up validators to move data in and out
tv_standard_box->SetValidator(wxGenericValidator((int*)&s.tv_standard)); 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)); inclusive_end_times_check->SetValidator(wxGenericValidator(&s.inclusive_end_times));
timecode_offset_entry->SetValidator(TimecodeValidator(&s.timecode_offset)); timecode_offset_entry->SetValidator(TimecodeValidator(&s.timecode_offset));
display_standard_ctrl->SetValidator(wxGenericValidator((int*)&s.display_standard)); display_standard_ctrl->SetValidator(wxGenericValidator((int*)&s.display_standard));
return d.ShowModal();
} }
agi::vfr::Framerate EbuExportSettings::GetFramerate() const { agi::vfr::Framerate EbuExportSettings::GetFramerate() const {

View File

@ -22,7 +22,6 @@
#include <libaegisub/vfr.h> #include <libaegisub/vfr.h>
#include <memory> #include <memory>
#include <wx/dialog.h>
namespace agi { namespace charset { class IconvWrapper; } } namespace agi { namespace charset { class IconvWrapper; } }
@ -111,11 +110,7 @@ public:
void Save() const; void Save() const;
}; };
/// Dialog box for getting an export configuration for EBU Tech 3264-1991 /// Show a dialog box for getting an export configuration for EBU Tech 3264-1991
class EbuExportConfigurationDialog final : public wxDialog { /// @param owner Parent window of the dialog
public: /// @param s Struct with initial values and to fill with the chosen settings
/// Constructor int ShowEbuExportConfigurationDialog(wxWindow *owner, EbuExportSettings &s);
/// @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);
};

View File

@ -43,7 +43,8 @@
#include <wx/textctrl.h> #include <wx/textctrl.h>
namespace { namespace {
class DialogJumpTo final : public wxDialog { struct DialogJumpTo {
wxDialog d;
agi::Context *c; ///< Project context agi::Context *c; ///< Project context
long jumpframe; ///< Target frame to jump to long jumpframe; ///< Target frame to jump to
TimeEdit *JumpTime; ///< Target time edit control TimeEdit *JumpTime; ///< Target time edit control
@ -58,23 +59,22 @@ class DialogJumpTo final : public wxDialog {
/// Dialog initializer to set default focus and selection /// Dialog initializer to set default focus and selection
void OnInitDialog(wxInitDialogEvent&); void OnInitDialog(wxInitDialogEvent&);
public:
DialogJumpTo(agi::Context *c); DialogJumpTo(agi::Context *c);
}; };
DialogJumpTo::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) , c(c)
, jumpframe(c->videoController->GetFrameN()) , jumpframe(c->videoController->GetFrameN())
{ {
SetIcon(GETICON(jumpto_button_16)); d.SetIcon(GETICON(jumpto_button_16));
auto LabelFrame = new wxStaticText(this, -1, _("Frame: ")); auto LabelFrame = new wxStaticText(&d, -1, _("Frame: "));
auto LabelTime = new wxStaticText(this, -1, _("Time: ")); 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()); 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); 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(LabelTime, 1, wxALIGN_CENTER_VERTICAL);
TimesSizer->Add(JumpTime, wxEXPAND); TimesSizer->Add(JumpTime, wxEXPAND);
auto ButtonSizer = CreateStdDialogButtonSizer(wxOK | wxCANCEL); auto ButtonSizer = d.CreateStdDialogButtonSizer(wxOK | wxCANCEL);
// General layout // General layout
auto MainSizer = new wxBoxSizer(wxVERTICAL); auto MainSizer = new wxBoxSizer(wxVERTICAL);
MainSizer->Add(TimesSizer, 0, wxALL | wxALIGN_CENTER, 5); MainSizer->Add(TimesSizer, 0, wxALL | wxALIGN_CENTER, 5);
MainSizer->Add(ButtonSizer, 0, wxEXPAND | wxLEFT | wxBOTTOM | wxRIGHT, 5); MainSizer->Add(ButtonSizer, 0, wxEXPAND | wxLEFT | wxBOTTOM | wxRIGHT, 5);
SetSizerAndFit(MainSizer); d.SetSizerAndFit(MainSizer);
CenterOnParent(); d.CenterOnParent();
Bind(wxEVT_INIT_DIALOG, &DialogJumpTo::OnInitDialog, this); d.Bind(wxEVT_INIT_DIALOG, &DialogJumpTo::OnInitDialog, this);
Bind(wxEVT_TEXT_ENTER, &DialogJumpTo::OnOK, this); d.Bind(wxEVT_TEXT_ENTER, &DialogJumpTo::OnOK, this);
Bind(wxEVT_BUTTON, &DialogJumpTo::OnOK, this, wxID_OK); d.Bind(wxEVT_BUTTON, &DialogJumpTo::OnOK, this, wxID_OK);
JumpTime->Bind(wxEVT_TEXT, &DialogJumpTo::OnEditTime, this); JumpTime->Bind(wxEVT_TEXT, &DialogJumpTo::OnEditTime, this);
JumpFrame->Bind(wxEVT_TEXT, &DialogJumpTo::OnEditFrame, this); JumpFrame->Bind(wxEVT_TEXT, &DialogJumpTo::OnEditFrame, this);
} }
void DialogJumpTo::OnInitDialog(wxInitDialogEvent&) { void DialogJumpTo::OnInitDialog(wxInitDialogEvent&) {
TransferDataToWindow(); d.TransferDataToWindow();
UpdateWindowUI(wxUPDATE_UI_RECURSE); d.UpdateWindowUI(wxUPDATE_UI_RECURSE);
// This can't simply be done in the constructor as the value hasn't been set yet // This can't simply be done in the constructor as the value hasn't been set yet
JumpFrame->SetFocus(); JumpFrame->SetFocus();
@ -110,7 +110,7 @@ void DialogJumpTo::OnInitDialog(wxInitDialogEvent&) {
} }
void DialogJumpTo::OnOK(wxCommandEvent &) { void DialogJumpTo::OnOK(wxCommandEvent &) {
EndModal(0); d.EndModal(0);
c->videoController->JumpToFrame(jumpframe); c->videoController->JumpToFrame(jumpframe);
} }
@ -129,5 +129,5 @@ void DialogJumpTo::OnEditFrame (wxCommandEvent &event) {
} }
void ShowJumpToDialog(agi::Context *c) { void ShowJumpToDialog(agi::Context *c) {
DialogJumpTo(c).ShowModal(); DialogJumpTo(c).d.ShowModal();
} }

View File

@ -38,7 +38,8 @@
#include <wx/stattext.h> #include <wx/stattext.h>
namespace { namespace {
class DialogPasteOver final : public wxDialog { struct DialogPasteOver {
wxDialog d;
wxCheckListBox *ListBox; wxCheckListBox *ListBox;
void CheckAll(bool check); void CheckAll(bool check);
@ -47,16 +48,15 @@ class DialogPasteOver final : public wxDialog {
void OnTimes(wxCommandEvent &); void OnTimes(wxCommandEvent &);
void OnText(wxCommandEvent &); void OnText(wxCommandEvent &);
public:
DialogPasteOver(wxWindow *parent); DialogPasteOver(wxWindow *parent);
}; };
DialogPasteOver::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 // Label and list sizer
wxSizer *ListSizer = new wxStaticBoxSizer(wxVERTICAL, this, _("Fields")); wxSizer *ListSizer = new wxStaticBoxSizer(wxVERTICAL, &d, _("Fields"));
ListSizer->Add(new wxStaticText(this, -1, _("Please select the fields that you want to paste over:")), wxSizerFlags()); ListSizer->Add(new wxStaticText(&d, -1, _("Please select the fields that you want to paste over:")), wxSizerFlags());
// List box // List box
wxArrayString choices; wxArrayString choices;
@ -71,7 +71,7 @@ DialogPasteOver::DialogPasteOver(wxWindow *parent)
choices.Add(_("Margin Vertical")); choices.Add(_("Margin Vertical"));
choices.Add(_("Effect")); choices.Add(_("Effect"));
choices.Add(_("Text")); 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)); ListSizer->Add(ListBox, wxSizerFlags(0).Expand().Border(wxTOP));
std::vector<bool> options = OPT_GET("Tool/Paste Lines Over/Fields")->GetListBool(); std::vector<bool> options = OPT_GET("Tool/Paste Lines Over/Fields")->GetListBool();
@ -85,27 +85,27 @@ DialogPasteOver::DialogPasteOver(wxWindow *parent)
wxButton *btn; wxButton *btn;
wxSizer *TopButtonSizer = new wxBoxSizer(wxHORIZONTAL); 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)); 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)); 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); 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); btn->Bind(wxEVT_BUTTON, &DialogPasteOver::OnText, this);
// Buttons // Buttons
wxStdDialogButtonSizer *ButtonSizer = CreateStdDialogButtonSizer(wxOK | wxCANCEL | wxHELP); auto ButtonSizer = d.CreateStdDialogButtonSizer(wxOK | wxCANCEL | wxHELP);
Bind(wxEVT_BUTTON, &DialogPasteOver::OnOK, this, wxID_OK); d.Bind(wxEVT_BUTTON, &DialogPasteOver::OnOK, this, wxID_OK);
Bind(wxEVT_BUTTON, std::bind(&HelpButton::OpenPage, "Paste Over"), wxID_HELP); d.Bind(wxEVT_BUTTON, std::bind(&HelpButton::OpenPage, "Paste Over"), wxID_HELP);
// Main sizer // Main sizer
wxSizer *MainSizer = new wxBoxSizer(wxVERTICAL); wxSizer *MainSizer = new wxBoxSizer(wxVERTICAL);
MainSizer->Add(ListSizer,0,wxEXPAND | wxLEFT | wxRIGHT,5); MainSizer->Add(ListSizer,0,wxEXPAND | wxLEFT | wxRIGHT,5);
MainSizer->Add(TopButtonSizer,0,wxLEFT | wxRIGHT | wxEXPAND,5); MainSizer->Add(TopButtonSizer,0,wxLEFT | wxRIGHT | wxEXPAND,5);
MainSizer->Add(ButtonSizer,0,wxALL | wxEXPAND,5); MainSizer->Add(ButtonSizer,0,wxALL | wxEXPAND,5);
SetSizerAndFit(MainSizer); d.SetSizerAndFit(MainSizer);
CenterOnParent(); d.CenterOnParent();
} }
void DialogPasteOver::OnOK(wxCommandEvent &) { void DialogPasteOver::OnOK(wxCommandEvent &) {
@ -114,7 +114,7 @@ void DialogPasteOver::OnOK(wxCommandEvent &) {
options.push_back(ListBox->IsChecked(i)); options.push_back(ListBox->IsChecked(i));
OPT_SET("Tool/Paste Lines Over/Fields")->SetListBool(std::move(options)); OPT_SET("Tool/Paste Lines Over/Fields")->SetListBool(std::move(options));
EndModal(wxID_OK); d.EndModal(wxID_OK);
} }
void DialogPasteOver::OnText(wxCommandEvent &) { void DialogPasteOver::OnText(wxCommandEvent &) {
@ -135,5 +135,5 @@ void DialogPasteOver::CheckAll(bool check) {
} }
bool ShowPasteOverDialog(wxWindow *parent) { bool ShowPasteOverDialog(wxWindow *parent) {
return DialogPasteOver(parent).ShowModal() == wxID_OK; return DialogPasteOver(parent).d.ShowModal() == wxID_OK;
} }

View File

@ -48,7 +48,8 @@
#include <wx/textctrl.h> #include <wx/textctrl.h>
namespace { namespace {
class DialogProperties final : public wxDialog { class DialogProperties {
wxDialog d;
agi::Context *c; ///< Project this dialog is adjusting the properties of agi::Context *c; ///< Project this dialog is adjusting the properties of
/// Pairs of a script property and a text control for that property /// Pairs of a script property and a text control for that property
@ -81,16 +82,17 @@ public:
/// Constructor /// Constructor
/// @param c Project context /// @param c Project context
DialogProperties(agi::Context *c); DialogProperties(agi::Context *c);
void ShowModal() { d.ShowModal(); }
}; };
DialogProperties::DialogProperties(agi::Context *c) DialogProperties::DialogProperties(agi::Context *c)
: wxDialog(c->parent, -1, _("Script Properties")) : d(c->parent, -1, _("Script Properties"))
, c(c) , c(c)
{ {
SetIcon(GETICON(properties_toolbutton_16)); d.SetIcon(GETICON(properties_toolbutton_16));
// Script details crap // 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); auto TopSizerGrid = new wxFlexGridSizer(0,2,5,5);
AddProperty(TopSizerGrid, _("Title:"), "Title"); AddProperty(TopSizerGrid, _("Title:"), "Title");
@ -106,10 +108,10 @@ DialogProperties::DialogProperties(agi::Context *c)
TopSizer->Add(TopSizerGrid,1,wxALL | wxEXPAND,0); TopSizer->Add(TopSizerGrid,1,wxALL | wxEXPAND,0);
// Resolution box // Resolution box
ResX = new wxTextCtrl(this,-1,"",wxDefaultPosition,wxSize(50,20),0,IntValidator(c->ass->GetScriptInfoAsInt("PlayResX"))); ResX = new wxTextCtrl(&d,-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"))); 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()) if (!c->project->VideoProvider())
FromVideo->Enable(false); FromVideo->Enable(false);
else else
@ -117,23 +119,23 @@ DialogProperties::DialogProperties(agi::Context *c)
auto res_sizer = new wxBoxSizer(wxHORIZONTAL); auto res_sizer = new wxBoxSizer(wxHORIZONTAL);
res_sizer->Add(ResX, 1, wxRIGHT | wxALIGN_CENTER_VERTICAL, 5); 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(ResY, 1, wxRIGHT | wxALIGN_CENTER_VERTICAL, 5);
res_sizer->Add(FromVideo, 1, 0, 0); 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); wxDefaultPosition, wxDefaultSize, to_wx(MatrixNames()), wxCB_READONLY);
auto matrix_sizer = new wxBoxSizer(wxHORIZONTAL); 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)); 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(res_sizer, wxSizerFlags().Expand());
res_box->Add(matrix_sizer, wxSizerFlags().Border(wxTOP).Expand()); res_box->Add(matrix_sizer, wxSizerFlags().Border(wxTOP).Expand());
// Options // Options
wxSizer *optionsBox = new wxStaticBoxSizer(wxHORIZONTAL,this,_("Options")); wxSizer *optionsBox = new wxStaticBoxSizer(wxHORIZONTAL,&d,_("Options"));
auto optionsGrid = new wxFlexGridSizer(3,2,5,5); auto optionsGrid = new wxFlexGridSizer(3,2,5,5);
wxString wrap_opts[] = { wxString wrap_opts[] = {
_("0: Smart wrapping, top line is wider"), _("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"), _("2: No word wrapping, both \\n and \\N break"),
_("3: Smart wrapping, bottom line is wider") _("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")); 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); 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->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")); ScaleBorder->SetValue(boost::iequals(c->ass->GetScriptInfo("ScaledBorderAndShadow"), "yes"));
optionsGrid->AddSpacer(0); optionsGrid->AddSpacer(0);
@ -155,9 +157,9 @@ DialogProperties::DialogProperties(agi::Context *c)
optionsBox->Add(optionsGrid,1,wxEXPAND,0); optionsBox->Add(optionsGrid,1,wxEXPAND,0);
// Button sizer // Button sizer
wxStdDialogButtonSizer *ButtonSizer = CreateStdDialogButtonSizer(wxOK | wxCANCEL | wxHELP); auto ButtonSizer = d.CreateStdDialogButtonSizer(wxOK | wxCANCEL | wxHELP);
Bind(wxEVT_BUTTON, &DialogProperties::OnOK, this, wxID_OK); d.Bind(wxEVT_BUTTON, &DialogProperties::OnOK, this, wxID_OK);
Bind(wxEVT_BUTTON, std::bind(&HelpButton::OpenPage, "Properties"), wxID_HELP); d.Bind(wxEVT_BUTTON, std::bind(&HelpButton::OpenPage, "Properties"), wxID_HELP);
// MainSizer // MainSizer
wxSizer *MainSizer = new wxBoxSizer(wxVERTICAL); 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(optionsBox,0,wxLEFT | wxRIGHT | wxBOTTOM | wxEXPAND,5);
MainSizer->Add(ButtonSizer,0,wxLEFT | wxRIGHT | wxBOTTOM | wxEXPAND,5); MainSizer->Add(ButtonSizer,0,wxLEFT | wxRIGHT | wxBOTTOM | wxEXPAND,5);
SetSizerAndFit(MainSizer); d.SetSizerAndFit(MainSizer);
CenterOnParent(); d.CenterOnParent();
} }
void DialogProperties::AddProperty(wxSizer *sizer, wxString const& label, std::string const& property) { 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)); wxTextCtrl *ctrl = new wxTextCtrl(&d, -1, to_wx(c->ass->GetScriptInfo(property)), wxDefaultPosition, wxSize(200, 20));
sizer->Add(new wxStaticText(this, -1, label), wxSizerFlags().Center().Left()); sizer->Add(new wxStaticText(&d, -1, label), wxSizerFlags().Center().Left());
sizer->Add(ctrl, wxSizerFlags(1).Expand()); sizer->Add(ctrl, wxSizerFlags(1).Expand());
properties.push_back({property, ctrl}); properties.push_back({property, ctrl});
} }
@ -190,7 +192,7 @@ void DialogProperties::OnOK(wxCommandEvent &) {
if (count) c->ass->Commit(_("property changes"), AssFile::COMMIT_SCRIPTINFO); 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) { int DialogProperties::SetInfoIfDifferent(std::string const& key, std::string const&value) {

View File

@ -39,7 +39,8 @@ namespace {
/// @brief Configuration dialog for resolution resampling /// @brief Configuration dialog for resolution resampling
/// ///
/// Populate a ResampleSettings structure with data from the user /// Populate a ResampleSettings structure with data from the user
class DialogResample final : public wxDialog { struct DialogResample {
wxDialog d;
agi::Context *c; ///< Project context agi::Context *c; ///< Project context
int script_w; int script_w;
@ -86,10 +87,10 @@ enum {
}; };
DialogResample::DialogResample(agi::Context *c, ResampleSettings &settings) DialogResample::DialogResample(agi::Context *c, ResampleSettings &settings)
: wxDialog(c->parent, -1, _("Resample Resolution")) : d(c->parent, -1, _("Resample Resolution"))
, c(c) , c(c)
{ {
SetIcon(GETICON(resample_toolbutton_16)); d.SetIcon(GETICON(resample_toolbutton_16));
memset(&settings, 0, sizeof(settings)); memset(&settings, 0, sizeof(settings));
c->ass->GetResolution(script_w, script_h); c->ass->GetResolution(script_w, script_h);
@ -111,23 +112,23 @@ DialogResample::DialogResample(agi::Context *c, ResampleSettings &settings)
// Create all controls and set validators // Create all controls and set validators
for (size_t i = 0; i < 4; ++i) { 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])); margin_ctrl[i]->SetValidator(wxGenericValidator(&settings.margin[i]));
} }
symmetrical = new wxCheckBox(this, -1, _("&Symmetrical")); symmetrical = new wxCheckBox(&d, -1, _("&Symmetrical"));
symmetrical->SetValue(true); symmetrical->SetValue(true);
margin_ctrl[RIGHT]->Enable(false); margin_ctrl[RIGHT]->Enable(false);
margin_ctrl[BOTTOM]->Enable(false); margin_ctrl[BOTTOM]->Enable(false);
source_x = new wxSpinCtrl(this, -1, "", wxDefaultPosition, wxSize(50, -1), wxSP_ARROW_KEYS, 1, INT_MAX); source_x = new wxSpinCtrl(&d, -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_y = new wxSpinCtrl(&d, -1, "", wxDefaultPosition, wxSize(50, -1), wxSP_ARROW_KEYS, 1, INT_MAX);
source_matrix = new wxComboBox(this, -1, "", wxDefaultPosition, source_matrix = new wxComboBox(&d, -1, "", wxDefaultPosition,
wxDefaultSize, to_wx(MatrixNames()), wxCB_READONLY); wxDefaultSize, to_wx(MatrixNames()), wxCB_READONLY);
dest_x = new wxSpinCtrl(this, -1, "", wxDefaultPosition, wxSize(50, -1), wxSP_ARROW_KEYS, 1, INT_MAX); dest_x = new wxSpinCtrl(&d, -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_y = new wxSpinCtrl(&d, -1, "", wxDefaultPosition, wxSize(50, -1), wxSP_ARROW_KEYS, 1, INT_MAX);
dest_matrix = new wxComboBox(this, -1, "", wxDefaultPosition, wxDefaultSize, dest_matrix = new wxComboBox(&d, -1, "", wxDefaultPosition, wxDefaultSize,
to_wx(MatrixNames()), wxCB_READONLY); to_wx(MatrixNames()), wxCB_READONLY);
source_x->SetValidator(wxGenericValidator(&settings.source_x)); 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_y->SetValidator(wxGenericValidator(&settings.dest_y));
dest_matrix->SetValidator(MakeEnumBinder(&settings.dest_matrix)); 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_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); from_script->Enable(false);
wxString ar_modes[] = {_("Stretch"), _("Add borders"), _("Remove borders"), _("Manual")}; 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)); wxDefaultSize, boost::size(ar_modes), ar_modes, 1, 4, MakeEnumBinder(&settings.ar_mode));
// Position the controls // 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->Add(margin_ctrl[BOTTOM], wxSizerFlags(1).Expand());
margin_sizer->AddSpacer(1); 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)); margin_box->Add(margin_sizer, wxSizerFlags(1).Expand().Border(wxBOTTOM));
auto source_res_sizer = new wxBoxSizer(wxHORIZONTAL); 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(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(source_y, wxSizerFlags(1).Border(wxRIGHT).Align(wxALIGN_CENTER_VERTICAL));
source_res_sizer->Add(from_script, wxSizerFlags(1)); source_res_sizer->Add(from_script, wxSizerFlags(1));
auto source_matrix_sizer = new wxBoxSizer(wxHORIZONTAL); 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()); 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_res_sizer, wxSizerFlags(1).Expand().Border(wxBOTTOM));
source_res_box->Add(source_matrix_sizer, wxSizerFlags(1).Expand()); source_res_box->Add(source_matrix_sizer, wxSizerFlags(1).Expand());
auto dest_res_sizer = new wxBoxSizer(wxHORIZONTAL); 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(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(dest_y, wxSizerFlags(1).Border(wxRIGHT).Align(wxALIGN_CENTER_VERTICAL));
dest_res_sizer->Add(from_video, wxSizerFlags(1)); dest_res_sizer->Add(from_video, wxSizerFlags(1));
auto dest_matrix_sizer = new wxBoxSizer(wxHORIZONTAL); 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()); 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_res_sizer, wxSizerFlags(1).Expand().Border(wxBOTTOM));
dest_res_box->Add(dest_matrix_sizer, wxSizerFlags(1).Expand()); 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(dest_res_box, wxSizerFlags().Expand().Border());
main_sizer->Add(ar_mode, wxSizerFlags().Expand().Border()); main_sizer->Add(ar_mode, wxSizerFlags().Expand().Border());
main_sizer->Add(margin_box, wxSizerFlags(1).Expand().Border()); main_sizer->Add(margin_box, wxSizerFlags(1).Expand().Border());
main_sizer->Add(CreateStdDialogButtonSizer(wxOK | wxCANCEL | wxHELP), wxSizerFlags().Expand().Border(wxALL & ~wxTOP)); main_sizer->Add(d.CreateStdDialogButtonSizer(wxOK | wxCANCEL | wxHELP), wxSizerFlags().Expand().Border(wxALL & ~wxTOP));
SetSizerAndFit(main_sizer); d.SetSizerAndFit(main_sizer);
CenterOnParent(); d.CenterOnParent();
TransferDataToWindow(); d.TransferDataToWindow();
UpdateButtons(); UpdateButtons();
// Bind events // Bind events
using std::bind; using std::bind;
Bind(wxEVT_BUTTON, bind(&HelpButton::OpenPage, "Resample resolution"), wxID_HELP); d.Bind(wxEVT_BUTTON, bind(&HelpButton::OpenPage, "Resample resolution"), wxID_HELP);
Bind(wxEVT_SPINCTRL, [=](wxCommandEvent&) { UpdateButtons(); }); d.Bind(wxEVT_SPINCTRL, [=](wxCommandEvent&) { UpdateButtons(); });
Bind(wxEVT_RADIOBOX, [=](wxCommandEvent&) { UpdateButtons(); }); d.Bind(wxEVT_RADIOBOX, [=](wxCommandEvent&) { UpdateButtons(); });
from_video->Bind(wxEVT_BUTTON, &DialogResample::SetDestFromVideo, this); from_video->Bind(wxEVT_BUTTON, &DialogResample::SetDestFromVideo, this);
from_script->Bind(wxEVT_BUTTON, &DialogResample::SetSourceFromScript, this); from_script->Bind(wxEVT_BUTTON, &DialogResample::SetSourceFromScript, this);
symmetrical->Bind(wxEVT_CHECKBOX, &DialogResample::OnSymmetrical, 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) { bool PromptForResampleSettings(agi::Context *c, ResampleSettings &settings) {
return DialogResample(c, settings).ShowModal() == wxID_OK; return DialogResample(c, settings).d.ShowModal() == wxID_OK;
} }

View File

@ -20,42 +20,27 @@
#include <wx/listbox.h> #include <wx/listbox.h>
#include <wx/sizer.h> #include <wx/sizer.h>
namespace { int GetSelectedChoices(wxWindow *parent, wxArrayInt& selections, wxString const& message, wxString const& caption, wxArrayString const& choices) {
/// @class SelectedChoicesDialog wxMultiChoiceDialog dialog(parent, message, caption, choices);
/// @brief wxMultiChoiceDialog with Select All and Select None
class SelectedChoicesDialog final : public wxMultiChoiceDialog {
void SelectAll(wxCommandEvent&);
public: auto selAll = new wxButton(&dialog, -1, _("Select &All"));
SelectedChoicesDialog(wxWindow *parent, wxString const& message, wxString const& caption, wxArrayString const& choices); 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) { auto selNone = new wxButton(&dialog, -1, _("Select &None"));
Create(parent, message, caption, choices); selNone->Bind(wxEVT_BUTTON, [&](wxCommandEvent&) { dialog.SetSelections(wxArrayInt()); });
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 buttonSizer = new wxBoxSizer(wxHORIZONTAL); auto buttonSizer = new wxBoxSizer(wxHORIZONTAL);
buttonSizer->Add(selAll, wxSizerFlags(0).Left()); buttonSizer->Add(selAll, wxSizerFlags(0).Left());
buttonSizer->Add(selNone, wxSizerFlags(0).Right()); buttonSizer->Add(selNone, wxSizerFlags(0).Right());
wxSizer *sizer = GetSizer(); auto sizer = dialog.GetSizer();
sizer->Insert(2, buttonSizer, wxSizerFlags(0).Center()); 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); dialog.SetSelections(selections);
if (dialog.ShowModal() != wxID_OK) return -1; if (dialog.ShowModal() != wxID_OK) return -1;

View File

@ -37,55 +37,41 @@
#include <wx/textctrl.h> #include <wx/textctrl.h>
#include <wx/valgen.h> #include <wx/valgen.h>
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 /// A simple dialog to let the user select the format of a plain text file
/// being imported into Aegisub /// being imported into Aegisub
class DialogTextImport final : public wxDialog { bool ShowPlainTextImportDialog() {
std::string seperator; auto seperator = OPT_GET("Tool/Import/Text/Actor Separator")->GetString();
std::string comment; auto comment = OPT_GET("Tool/Import/Text/Comment Starter")->GetString();
bool include_blank; auto include_blank = OPT_GET("Tool/Import/Text/Include Blank")->GetBool();
public: wxDialog d(nullptr, -1, _("Text import options"));
DialogTextImport();
};
DialogTextImport::DialogTextImport() auto make_text_ctrl = [&](std::string *var) {
: wxDialog(nullptr , -1, _("Text import options")) return new wxTextCtrl(&d, -1, "", wxDefaultPosition, wxDefaultSize, 0, StringBinder(var));
, 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 fg = new wxFlexGridSizer(2, 5, 5); 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(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); fg->Add(make_text_ctrl(&comment), 0, wxEXPAND);
auto main_sizer = new wxBoxSizer(wxVERTICAL); auto main_sizer = new wxBoxSizer(wxVERTICAL);
main_sizer->Add(fg, 1, wxALL|wxEXPAND, 5); 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(new wxCheckBox(&d, -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); main_sizer->Add(d.CreateSeparatedButtonSizer(wxOK|wxCANCEL), 0, wxALL|wxEXPAND, 5);
SetSizerAndFit(main_sizer); d.SetSizerAndFit(main_sizer);
Bind(wxEVT_BUTTON, [=](wxCommandEvent&) { d.Bind(wxEVT_BUTTON, [&](wxCommandEvent&) {
TransferDataFromWindow(); d.TransferDataFromWindow();
OPT_SET("Tool/Import/Text/Actor Separator")->SetString(seperator); OPT_SET("Tool/Import/Text/Actor Separator")->SetString(seperator);
OPT_SET("Tool/Import/Text/Comment Starter")->SetString(comment); OPT_SET("Tool/Import/Text/Comment Starter")->SetString(comment);
OPT_SET("Tool/Import/Text/Include Blank")->SetBool(include_blank); OPT_SET("Tool/Import/Text/Include Blank")->SetBool(include_blank);
EndModal(wxID_OK); d.EndModal(wxID_OK);
}, wxID_OK); }, wxID_OK);
}
}
bool ShowPlainTextImportDialog() {
return DialogTextImport().ShowModal() == wxID_OK; return d.ShowModal() == wxID_OK;
} }

View File

@ -66,7 +66,8 @@ using namespace boost::adaptors;
namespace { namespace {
/// @class DialogTimingProcessor /// @class DialogTimingProcessor
/// @brief Automatic postprocessor for correcting common timing issues /// @brief Automatic postprocessor for correcting common timing issues
class DialogTimingProcessor final : public wxDialog { struct DialogTimingProcessor {
wxDialog d;
agi::Context *c; ///< Project context agi::Context *c; ///< Project context
int leadIn; ///< Lead-in to add in milliseconds 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 /// Get a list of dialogue lines in the file sorted by start time
std::vector<AssDialogue*> SortDialogues(); std::vector<AssDialogue*> SortDialogues();
public:
DialogTimingProcessor(agi::Context *c); DialogTimingProcessor(agi::Context *c);
}; };
@ -136,12 +136,12 @@ wxCheckBox *make_check(wxStaticBoxSizer *sizer, wxString const& desc, const char
} }
DialogTimingProcessor::DialogTimingProcessor(agi::Context *c) DialogTimingProcessor::DialogTimingProcessor(agi::Context *c)
: wxDialog(c->parent, -1, _("Timing Post-Processor")) : d(c->parent, -1, _("Timing Post-Processor"))
, c(c) , c(c)
{ {
using std::bind; using std::bind;
SetIcon(GETICON(timing_processor_toolbutton_16)); d.SetIcon(GETICON(timing_processor_toolbutton_16));
// Read options // Read options
leadIn = OPT_GET("Audio/Lead/IN")->GetInt(); 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(); adjOverlap = OPT_GET("Tool/Timing Post Processor/Threshold/Adjacent Overlap")->GetInt();
// Styles box // Styles box
auto LeftSizer = new wxStaticBoxSizer(wxVERTICAL,this,_("Apply to styles")); auto LeftSizer = new wxStaticBoxSizer(wxVERTICAL,&d,_("Apply to styles"));
StyleList = new wxCheckListBox(this, -1, wxDefaultPosition, wxSize(150,150), to_wx(c->ass->GetStyles())); 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.")); 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")); all->SetToolTip(_("Select all styles"));
auto none = new wxButton(this,-1,_("&None")); auto none = new wxButton(&d,-1,_("&None"));
none->SetToolTip(_("Deselect all styles")); none->SetToolTip(_("Deselect all styles"));
// Options box // Options box
auto optionsSizer = new wxStaticBoxSizer(wxHORIZONTAL,this,_("Options")); auto optionsSizer = new wxStaticBoxSizer(wxHORIZONTAL,&d,_("Options"));
onlySelection = new wxCheckBox(this,-1,_("Affect &selection only")); onlySelection = new wxCheckBox(&d,-1,_("Affect &selection only"));
onlySelection->SetValue(OPT_GET("Tool/Timing Post Processor/Only Selection")->GetBool()); onlySelection->SetValue(OPT_GET("Tool/Timing Post Processor/Only Selection")->GetBool());
optionsSizer->Add(onlySelection,1,wxALL,0); optionsSizer->Add(onlySelection,1,wxALL,0);
// Lead-in/out box // 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:"), hasLeadIn = make_check(LeadSizer, _("Add lead &in:"),
"Tool/Timing Post Processor/Enable/Lead/IN", "Tool/Timing Post Processor/Enable/Lead/IN",
@ -186,24 +186,24 @@ DialogTimingProcessor::DialogTimingProcessor(agi::Context *c)
LeadSizer->AddStretchSpacer(1); LeadSizer->AddStretchSpacer(1);
// Adjacent subs sizer // 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"), adjsEnable = make_check(AdjacentSizer, _("&Enable"),
"Tool/Timing Post Processor/Enable/Adjacent", "Tool/Timing Post Processor/Enable/Adjacent",
_("Enable snapping of subtitles together if they are within a certain distance of each other")); _("Enable snapping of subtitles together if they are within a certain distance of each other"));
auto adjBoxes = new wxBoxSizer(wxHORIZONTAL); 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")); _("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")); _("Maximum overlap between the end and start time for two subtitles to be made continuous, in milliseconds"));
adjacentBias = new wxSlider(this, -1, mid<int>(0, OPT_GET("Tool/Timing Post Processor/Adjacent Bias")->GetDouble() * 100, 100), 0, 100, wxDefaultPosition, wxSize(-1,20)); adjacentBias = new wxSlider(&d, -1, mid<int>(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.")); 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); 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(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); auto adjRightSizer = new wxBoxSizer(wxVERTICAL);
adjRightSizer->Add(adjBoxes, wxSizerFlags().Expand()); adjRightSizer->Add(adjBoxes, wxSizerFlags().Expand());
@ -211,10 +211,10 @@ DialogTimingProcessor::DialogTimingProcessor(agi::Context *c)
AdjacentSizer->Add(adjRightSizer); AdjacentSizer->Add(adjRightSizer);
// Keyframes sizer // 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); 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->SetToolTip(_("Enable snapping of subtitles to nearest keyframe, if distance is within threshold"));
keysEnable->SetValue(OPT_GET("Tool/Timing Post Processor/Enable/Keyframe")->GetBool()); keysEnable->SetValue(OPT_GET("Tool/Timing Post Processor/Enable/Keyframe")->GetBool());
KeyframesFlexSizer->Add(keysEnable,0,wxRIGHT|wxEXPAND,10); KeyframesFlexSizer->Add(keysEnable,0,wxRIGHT|wxEXPAND,10);
@ -226,25 +226,25 @@ DialogTimingProcessor::DialogTimingProcessor(agi::Context *c)
keysEnable->Enable(false); 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")); _("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")); _("Threshold for 'after start' distance, that is, how many milliseconds a subtitle must start after a keyframe to snap to it"));
KeyframesFlexSizer->AddStretchSpacer(1); 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")); _("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")); _("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->Add(KeyframesFlexSizer,0,wxEXPAND);
KeyframesSizer->AddStretchSpacer(1); KeyframesSizer->AddStretchSpacer(1);
// Button sizer // Button sizer
auto ButtonSizer = CreateStdDialogButtonSizer(wxOK | wxCANCEL | wxHELP); auto ButtonSizer = d.CreateStdDialogButtonSizer(wxOK | wxCANCEL | wxHELP);
ApplyButton = ButtonSizer->GetAffirmativeButton(); ApplyButton = ButtonSizer->GetAffirmativeButton();
ButtonSizer->GetHelpButton()->Bind(wxEVT_BUTTON, bind(&HelpButton::OpenPage, "Timing Processor")); ButtonSizer->GetHelpButton()->Bind(wxEVT_BUTTON, bind(&HelpButton::OpenPage, "Timing Processor"));
@ -274,12 +274,12 @@ DialogTimingProcessor::DialogTimingProcessor(agi::Context *c)
// Main Sizer // Main Sizer
auto MainSizer = new wxBoxSizer(wxVERTICAL); auto MainSizer = new wxBoxSizer(wxVERTICAL);
MainSizer->Add(TopSizer,1,wxALL|wxEXPAND,5); MainSizer->Add(TopSizer,1,wxALL|wxEXPAND,5);
SetSizerAndFit(MainSizer); d.SetSizerAndFit(MainSizer);
CenterOnParent(); d.CenterOnParent();
Bind(wxEVT_CHECKBOX, bind(&DialogTimingProcessor::UpdateControls, this)); d.Bind(wxEVT_CHECKBOX, bind(&DialogTimingProcessor::UpdateControls, this));
Bind(wxEVT_CHECKLISTBOX, bind(&DialogTimingProcessor::UpdateControls, this)); d.Bind(wxEVT_CHECKLISTBOX, bind(&DialogTimingProcessor::UpdateControls, this));
Bind(wxEVT_BUTTON, &DialogTimingProcessor::OnApply, this, wxID_OK); d.Bind(wxEVT_BUTTON, &DialogTimingProcessor::OnApply, this, wxID_OK);
all->Bind(wxEVT_BUTTON, bind(&DialogTimingProcessor::CheckAll, this, true)); all->Bind(wxEVT_BUTTON, bind(&DialogTimingProcessor::CheckAll, this, true));
none->Bind(wxEVT_BUTTON, bind(&DialogTimingProcessor::CheckAll, this, false)); none->Bind(wxEVT_BUTTON, bind(&DialogTimingProcessor::CheckAll, this, false));
@ -303,7 +303,7 @@ void DialogTimingProcessor::UpdateControls() {
} }
void DialogTimingProcessor::OnApply(wxCommandEvent &) { void DialogTimingProcessor::OnApply(wxCommandEvent &) {
TransferDataFromWindow(); d.TransferDataFromWindow();
// Save settings // Save settings
OPT_SET("Audio/Lead/IN")->SetInt(leadIn); OPT_SET("Audio/Lead/IN")->SetInt(leadIn);
OPT_SET("Audio/Lead/OUT")->SetInt(leadOut); 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()); OPT_SET("Tool/Timing Post Processor/Only Selection")->SetBool(onlySelection->IsChecked());
Process(); Process();
EndModal(0); d.EndModal(0);
} }
std::vector<AssDialogue*> DialogTimingProcessor::SortDialogues() { std::vector<AssDialogue*> DialogTimingProcessor::SortDialogues() {
@ -447,5 +447,5 @@ void DialogTimingProcessor::Process() {
} }
void ShowTimingProcessorDialog(agi::Context *c) { void ShowTimingProcessorDialog(agi::Context *c) {
DialogTimingProcessor(c).ShowModal(); DialogTimingProcessor(c).d.ShowModal();
} }

View File

@ -40,16 +40,9 @@
#include <wx/stattext.h> #include <wx/stattext.h>
#include <wx/textctrl.h> #include <wx/textctrl.h>
namespace { void ShowVideoDetailsDialog(agi::Context *c) {
/// @class DialogVideoDetails wxDialog d(c->parent, -1, _("Video Details"));
/// @brief Display information about the video in a dialog
struct DialogVideoDetails final : wxDialog {
DialogVideoDetails(agi::Context *c);
};
DialogVideoDetails::DialogVideoDetails(agi::Context *c)
: wxDialog(c->parent , -1, _("Video Details"))
{
auto provider = c->project->VideoProvider(); auto provider = c->project->VideoProvider();
auto width = provider->GetWidth(); auto width = provider->GetWidth();
auto height = provider->GetHeight(); auto height = provider->GetHeight();
@ -59,8 +52,8 @@ DialogVideoDetails::DialogVideoDetails(agi::Context *c)
auto fg = new wxFlexGridSizer(2, 5, 10); auto fg = new wxFlexGridSizer(2, 5, 10);
auto make_field = [&](wxString const& name, wxString const& value) { auto make_field = [&](wxString const& name, wxString const& value) {
fg->Add(new wxStaticText(this, -1, name), 0, wxALIGN_CENTRE_VERTICAL); fg->Add(new wxStaticText(&d, -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 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(_("File name:"), c->project->VideoName().wstring());
make_field(_("FPS:"), fmt_wx("%.3f", fps.FPS())); 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))); framecount, AssTime(fps.TimeAtFrame(framecount - 1)).GetAssFormated(true)));
make_field(_("Decoder:"), to_wx(provider->GetDecoderName())); 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); video_sizer->Add(fg);
auto main_sizer = new wxBoxSizer(wxVERTICAL); auto main_sizer = new wxBoxSizer(wxVERTICAL);
main_sizer->Add(video_sizer, 1, wxALL|wxEXPAND, 5); main_sizer->Add(video_sizer, 1, wxALL|wxEXPAND, 5);
main_sizer->Add(CreateSeparatedButtonSizer(wxOK), 0, wxALL|wxEXPAND, 5); main_sizer->Add(d.CreateSeparatedButtonSizer(wxOK), 0, wxALL|wxEXPAND, 5);
SetSizerAndFit(main_sizer); d.SetSizerAndFit(main_sizer);
CenterOnParent(); d.CenterOnParent();
} d.ShowModal();
}
void ShowVideoDetailsDialog(agi::Context *c) {
DialogVideoDetails(c).ShowModal();
} }

View File

@ -39,46 +39,46 @@ enum {
FIX_RESAMPLE FIX_RESAMPLE
}; };
class Prompt : public wxDialog { int prompt(wxWindow *parent, bool ar_changed, int sx, int sy, int vx, int vy) {
public: wxDialog d(parent, -1, _("Resolution mismatch"));
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);
auto sizer = new wxBoxSizer(wxVERTICAL); 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);
sizer->Add(new wxStaticText(this, -1, label_text), wxSizerFlags().Border());
wxRadioBox *rb; auto sizer = new wxBoxSizer(wxVERTICAL);
if (ar_changed) { sizer->Add(new wxStaticText(&d, -1, label_text), wxSizerFlags().Border());
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());
unsigned int sel = OPT_GET("Video/Last Script Resolution Mismatch Choice")->GetInt(); wxRadioBox *rb;
rb->SetSelection(std::min(sel - 1, rb->GetCount())); if (ar_changed) {
wxString choices[] = {
SetSizerAndFit(sizer); _("Set to video resolution"),
CenterOnParent(); _("Resample script (stretch to new aspect ratio)"),
_("Resample script (add borders)"),
Bind(wxEVT_BUTTON, [=](wxCommandEvent&) { EndModal(rb->GetSelection() + 1); }, wxID_OK); _("Resample script (remove borders)")
Bind(wxEVT_BUTTON, [=](wxCommandEvent&) { EndModal(0); }, wxID_CANCEL); };
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 update_video_properties(AssFile *file, const AsyncVideoProvider *new_provider, wxWindow *parent) {
bool commit_subs = false; bool commit_subs = false;
@ -141,7 +141,7 @@ bool update_video_properties(AssFile *file, const AsyncVideoProvider *new_provid
} }
case MISMATCH_PROMPT: 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; if (res == FIX_IGNORE) return commit_subs;
OPT_SET("Video/Last Script Resolution Mismatch Choice")->SetInt(res); OPT_SET("Video/Last Script Resolution Mismatch Choice")->SetInt(res);

View File

@ -611,7 +611,7 @@ namespace
// Disable the busy cursor set by the exporter while the dialog is visible // Disable the busy cursor set by the exporter while the dialog is visible
wxEndBusyCursor(); wxEndBusyCursor();
int res = EbuExportConfigurationDialog(parent, s).ShowModal(); int res = ShowEbuExportConfigurationDialog(parent, s);
wxBeginBusyCursor(); wxBeginBusyCursor();
if (res != wxID_OK) if (res != wxID_OK)