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/textctrl.h>
namespace {
struct AboutScreen : wxDialog {
AboutScreen(wxWindow *parent)
: wxDialog(parent, -1, _("About Aegisub"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX, _("About Aegisub"))
{
// Generate library string
wxString libString = "Aegisub includes portions from the following other projects:\n";
libString += " wxWidgets - Copyright (c) Julian Smart, Robert Roebling et al;\n";
libString += " wxStyledTextCtrl - Copyright (c) Robin Dunn, Neil Hodgson;\n";
libString += " Scintilla - Copyright (c) Neil Hodgson;\n";
libString += " Boost - Copyright (c) Beman Dawes, David Abrahams et al;\n";
libString += " UniversalCharDet - Copyright (c) Netscape Communications Corp.;\n";
libString += " ICU - Copyright (c) International Business Machines Corp.;\n";
libString += " Lua - Copyright (c) Lua.org, PUC-Rio;\n";
libString += " LuaJIT - Copyright (c) Mike Pall;\n";
libString += " luabins - Copyright (c) Alexander Gladysh;\n";
void ShowAboutDialog(wxWindow *parent) {
wxDialog d(parent, -1, _("About Aegisub"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX);
wxString translatorCredit = _("Translated into LANGUAGE by PERSON\n");
if (translatorCredit == "Translated into LANGUAGE by PERSON\n")
translatorCredit.clear();
// Generate about string
wxString aboutString = wxString("Aegisub ") + GetAegisubShortVersionString() + ".\n"
"Copyright (c) 2005-2014 Rodrigo Braz Monteiro, Niels Martin Hansen, Thomas Goyne et al.\n\n"
"Programmers:\n"
" Alysson Souza e Silva\n"
" Amar Takhar\n"
" Dan Donovan\n"
" Daniel Moscoviter\n"
" David Conrad\n"
" David Lamparter\n"
" Eric Batalitzky\n"
" Evgeniy Stepanov\n"
" Fredrik Mellbin\n"
" Grigori Goronzy\n"
" Karl Blomster\n"
" Mike Matsnev\n"
" Moritz Brunner\n"
" Muhammad Lukman Nasaruddin\n"
" Niels Martin Hansen\n"
" Patryk Pomykalski\n"
" Ravi Pinjala\n"
" Rodrigo Braz Monteiro\n"
" Simone Cociancich\n"
" Thomas Goyne\n"
"User manual written by:\n"
" Karl Blomster\n"
" Niels Martin Hansen\n"
" Rodrigo Braz Monteiro\n"
"Icons by:\n"
" Philip Cash\n"
"Additional thanks to:\n"
" Mentar\n"
" Sigurd Tao Lyngse\n"
" Everyone in the Aegisub IRC channel\n"
" Everyone who ever reported a bug\n"
+ translatorCredit + "\n"
"Aegisub includes portions from the following other projects:\n"
" wxWidgets - Copyright (c) Julian Smart, Robert Roebling et al;\n"
" wxStyledTextCtrl - Copyright (c) Robin Dunn, Neil Hodgson;\n"
" Scintilla - Copyright (c) Neil Hodgson;\n"
" Boost - Copyright (c) Beman Dawes, David Abrahams et al;\n"
" UniversalCharDet - Copyright (c) Netscape Communications Corp.;\n"
" ICU - Copyright (c) International Business Machines Corp.;\n"
" Lua - Copyright (c) Lua.org, PUC-Rio;\n"
" LuaJIT - Copyright (c) Mike Pall;\n"
" luabins - Copyright (c) Alexander Gladysh;\n"
#ifdef WITH_HUNSPELL
libString += " Hunspell - Copyright (c) Kevin Hendricks;\n";
" Hunspell - Copyright (c) Kevin Hendricks;\n"
#endif
#ifdef WITH_PORTAUDIO
libString += " PortAudio - Copyright (c) Ross Bencina, Phil Burk;\n";
" PortAudio - Copyright (c) Ross Bencina, Phil Burk;\n"
#endif
#ifdef WITH_FFMS2
libString += " FFmpeg - Copyright (c) Fabrice Bellard;\n";
libString += " FFMS2 - Copyright (c) Fredrik Mellbin;\n";
" FFmpeg - Copyright (c) Fabrice Bellard;\n"
" FFMS2 - Copyright (c) Fredrik Mellbin;\n"
#endif
#ifdef WITH_AVISYNTH
libString += " Avisynth 2.5 - Copyright (c) Ben Rudiak-Gould et al;\n";
" Avisynth 2.5 - Copyright (c) Ben Rudiak-Gould et al;\n"
#endif
#ifdef WITH_CSRI
libString += " csri - Copyright (c) David Lamparter;\n";
" csri - Copyright (c) David Lamparter;\n"
# ifdef __WINDOWS__
libString += " vsfilter - Copyright (c) Gabest et al;\n";
" vsfilter - Copyright (c) Gabest et al;\n"
# endif
#endif
libString += " libass - Copyright (c) Evgeniy Stepanov, Grigori Goronzy;\n";
#ifdef __WINDOWS__
libString += " Matroska Parser - Copyright (c) Mike Matsnev;\n";
#endif
libString += " Freetype - Copyright (c) David Turner, Robert Wilhelm, Werner Lemberg;\n";
libString += " Fontconfig - Copyright (c) Keith Packard et al;\n";
" libass - Copyright (c) Evgeniy Stepanov, Grigori Goronzy;\n"
" Matroska Parser - Copyright (c) Mike Matsnev;\n"
" Freetype - Copyright (c) David Turner, Robert Wilhelm, Werner Lemberg;\n"
" Fontconfig - Copyright (c) Keith Packard et al;\n"
#ifdef WITH_FFTW3
libString += " FFTW - Copyright (c) Matteo Frigo, Massachusetts Institute of Technology;\n";
" FFTW - Copyright (c) Matteo Frigo, Massachusetts Institute of Technology;\n"
#endif
+ _("\nSee the help file for full credits.\n")
+ fmt_tl("Built by %s on %s.", GetAegisubBuildCredit(), GetAegisubBuildTime());
wxString translatorCredit = _("Translated into LANGUAGE by PERSON\n");
if (translatorCredit == "Translated into LANGUAGE by PERSON\n") translatorCredit.Clear();
// Replace copyright symbol
wxChar copySymbol = 0xA9;
aboutString.Replace("(c)", wxString(copySymbol));
// Generate about string
wxString aboutString;
aboutString += wxString("Aegisub ") + GetAegisubShortVersionString() + ".\n";
aboutString += "Copyright (c) 2005-2014 Rodrigo Braz Monteiro, Niels Martin Hansen, Thomas Goyne et al.\n\n";
aboutString += "Programmers:\n";
aboutString += " Alysson Souza e Silva\n";
aboutString += " Amar Takhar\n";
aboutString += " Dan Donovan\n";
aboutString += " Daniel Moscoviter\n";
aboutString += " David Conrad\n";
aboutString += " David Lamparter\n";
aboutString += " Eric Batalitzky\n";
aboutString += " Evgeniy Stepanov\n";
aboutString += " Fredrik Mellbin\n";
aboutString += " Grigori Goronzy\n";
aboutString += " Karl Blomster\n";
aboutString += " Mike Matsnev\n";
aboutString += " Moritz Brunner\n";
aboutString += " Muhammad Lukman Nasaruddin\n";
aboutString += " Niels Martin Hansen\n";
aboutString += " Patryk Pomykalski\n";
aboutString += " Ravi Pinjala\n";
aboutString += " Rodrigo Braz Monteiro\n";
aboutString += " Simone Cociancich\n";
aboutString += " Thomas Goyne\n";
aboutString += "User manual written by:\n";
aboutString += " Karl Blomster\n";
aboutString += " Niels Martin Hansen\n";
aboutString += " Rodrigo Braz Monteiro\n";
aboutString += "Icons by:\n";
aboutString += " Philip Cash\n";
aboutString += "Additional thanks to:\n";
aboutString += " Mentar\n";
aboutString += " Sigurd Tao Lyngse\n";
aboutString += " Everyone in the Aegisub IRC channel\n";
aboutString += " Everyone who ever reported a bug\n";
aboutString += translatorCredit;
aboutString += "\n" + libString;
aboutString += _("\nSee the help file for full credits.\n");
aboutString += fmt_tl("Built by %s on %s.", GetAegisubBuildCredit(), GetAegisubBuildTime());
wxTextCtrl *textctrl = new wxTextCtrl(&d, -1, aboutString, wxDefaultPosition, wxSize(-1, 200), wxTE_MULTILINE | wxTE_READONLY | wxBORDER_NONE);
// Replace copyright symbol
wxChar copySymbol = 0xA9;
aboutString.Replace("(c)", wxString(copySymbol));
wxSizer *MainSizer = new wxBoxSizer(wxVERTICAL);
MainSizer->Add(new wxStaticBitmap(&d, -1, GETIMAGE(splash)), 0, wxCENTER, 0);
MainSizer->Add(new wxStaticLine(&d, wxID_ANY), 0, wxEXPAND | wxALL, 0);
MainSizer->Add(textctrl, 0, wxEXPAND | wxALL, 0);
MainSizer->Add(new wxStaticLine(&d, wxID_ANY), 0, wxEXPAND | wxALL, 0);
MainSizer->Add(d.CreateButtonSizer(wxOK), 0, wxEXPAND | wxALL, 6);
wxTextCtrl *textctrl = new wxTextCtrl(this, -1, aboutString, wxDefaultPosition, wxSize(-1, 200), wxTE_MULTILINE | wxTE_READONLY | wxBORDER_NONE);
wxSizer *MainSizer = new wxBoxSizer(wxVERTICAL);
MainSizer->Add(new wxStaticBitmap(this, -1, GETIMAGE(splash)), 0, wxCENTER, 0);
MainSizer->Add(new wxStaticLine(this, wxID_ANY), 0, wxEXPAND | wxALL, 0);
MainSizer->Add(textctrl, 0, wxEXPAND | wxALL, 0);
MainSizer->Add(new wxStaticLine(this, wxID_ANY), 0, wxEXPAND | wxALL, 0);
MainSizer->Add(CreateButtonSizer(wxOK), 0, wxEXPAND | wxALL, 6);
SetSizerAndFit(MainSizer);
CentreOnParent();
}
};
}
void ShowAboutDialog(wxWindow *parent) {
AboutScreen(parent).ShowModal();
d.SetSizerAndFit(MainSizer);
d.CentreOnParent();
d.ShowModal();
}

View File

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

View File

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

View File

@ -37,7 +37,9 @@
#include <wx/valgen.h>
namespace {
struct DialogDummyVideo final : wxDialog {
struct DialogDummyVideo {
wxDialog d;
double fps = OPT_GET("Video/Dummy/FPS")->GetDouble();
int width = OPT_GET("Video/Dummy/Last/Width")->GetInt();
int height = OPT_GET("Video/Dummy/Last/Height")->GetInt();
@ -98,45 +100,45 @@ wxComboBox *resolution_shortcuts(wxWindow *parent, int width, int height) {
}
DialogDummyVideo::DialogDummyVideo(wxWindow *parent)
: wxDialog(parent, -1, _("Dummy video options"))
: d(parent, -1, _("Dummy video options"))
{
SetIcon(GETICON(use_dummy_video_menu_16));
d.SetIcon(GETICON(use_dummy_video_menu_16));
auto res_sizer = new wxBoxSizer(wxHORIZONTAL);
res_sizer->Add(spin_ctrl(this, 1, 10000, &width), wxSizerFlags(1).Expand());
res_sizer->Add(new wxStaticText(this, -1, " x "), wxSizerFlags().Center());
res_sizer->Add(spin_ctrl(this, 1, 10000, &height), wxSizerFlags(1).Expand());
res_sizer->Add(spin_ctrl(&d, 1, 10000, &width), wxSizerFlags(1).Expand());
res_sizer->Add(new wxStaticText(&d, -1, " x "), wxSizerFlags().Center());
res_sizer->Add(spin_ctrl(&d, 1, 10000, &height), wxSizerFlags(1).Expand());
auto color_sizer = new wxBoxSizer(wxHORIZONTAL);
auto color_btn = new ColourButton(this, wxSize(30, 17), false, color);
auto color_btn = new ColourButton(&d, wxSize(30, 17), false, color);
color_sizer->Add(color_btn, wxSizerFlags().DoubleBorder(wxRIGHT));
color_sizer->Add(new wxCheckBox(this, -1, _("Checkerboard &pattern"), wxDefaultPosition, wxDefaultSize, 0, wxGenericValidator(&pattern)), wxSizerFlags(1).Center());
color_sizer->Add(new wxCheckBox(&d, -1, _("Checkerboard &pattern"), wxDefaultPosition, wxDefaultSize, 0, wxGenericValidator(&pattern)), wxSizerFlags(1).Center());
sizer = new wxFlexGridSizer(2, 5, 5);
AddCtrl(_("Video resolution:"), resolution_shortcuts(this, width, height));
AddCtrl(_("Video resolution:"), resolution_shortcuts(&d, width, height));
AddCtrl("", res_sizer);
AddCtrl(_("Color:"), color_sizer);
AddCtrl(_("Frame rate (fps):"), spin_ctrl(this, .1, 1000.0, &fps));
AddCtrl(_("Duration (frames):"), spin_ctrl(this, 2, 36000000, &length)); // Ten hours of 1k FPS
AddCtrl("", length_display = new wxStaticText(this, -1, ""));
AddCtrl(_("Frame rate (fps):"), spin_ctrl(&d, .1, 1000.0, &fps));
AddCtrl(_("Duration (frames):"), spin_ctrl(&d, 2, 36000000, &length)); // Ten hours of 1k FPS
AddCtrl("", length_display = new wxStaticText(&d, -1, ""));
wxStdDialogButtonSizer *btn_sizer = CreateStdDialogButtonSizer(wxOK | wxCANCEL | wxHELP);
auto btn_sizer = d.CreateStdDialogButtonSizer(wxOK | wxCANCEL | wxHELP);
btn_sizer->GetHelpButton()->Bind(wxEVT_BUTTON, std::bind(&HelpButton::OpenPage, "Dummy Video"));
auto main_sizer = new wxBoxSizer(wxVERTICAL);
main_sizer->Add(sizer, wxSizerFlags(1).Border().Expand());
main_sizer->Add(new wxStaticLine(this, wxHORIZONTAL), wxSizerFlags().HorzBorder().Expand());
main_sizer->Add(new wxStaticLine(&d, wxHORIZONTAL), wxSizerFlags().HorzBorder().Expand());
main_sizer->Add(btn_sizer, wxSizerFlags().Expand().Border());
UpdateLengthDisplay();
SetSizerAndFit(main_sizer);
CenterOnParent();
d.SetSizerAndFit(main_sizer);
d.CenterOnParent();
Bind(wxEVT_COMBOBOX, &DialogDummyVideo::OnResolutionShortcut, this);
d.Bind(wxEVT_COMBOBOX, &DialogDummyVideo::OnResolutionShortcut, this);
color_btn->Bind(EVT_COLOR, [=](wxThreadEvent& e) { color = color_btn->GetColor(); });
Bind(wxEVT_SPINCTRL, [=](wxCommandEvent&) {
TransferDataFromWindow();
d.Bind(wxEVT_SPINCTRL, [&](wxCommandEvent&) {
d.TransferDataFromWindow();
UpdateLengthDisplay();
});
}
@ -146,16 +148,16 @@ void DialogDummyVideo::AddCtrl(wxString const& label, T *ctrl) {
if (!label)
sizer->AddStretchSpacer();
else
sizer->Add(new wxStaticText(this, -1, label), wxSizerFlags().Center().Left());
sizer->Add(new wxStaticText(&d, -1, label), wxSizerFlags().Center().Left());
sizer->Add(ctrl, wxSizerFlags().Expand().Center().Left());
}
void DialogDummyVideo::OnResolutionShortcut(wxCommandEvent &e) {
TransferDataFromWindow();
d.TransferDataFromWindow();
int rs = e.GetSelection();
width = resolutions[rs].width;
height = resolutions[rs].height;
TransferDataToWindow();
d.TransferDataToWindow();
}
void DialogDummyVideo::UpdateLengthDisplay() {
@ -165,7 +167,7 @@ void DialogDummyVideo::UpdateLengthDisplay() {
std::string CreateDummyVideo(wxWindow *parent) {
DialogDummyVideo dlg(parent);
if (dlg.ShowModal() != wxID_OK)
if (dlg.d.ShowModal() != wxID_OK)
return "";
OPT_SET("Video/Dummy/FPS")->SetDouble(dlg.fps);

View File

@ -51,7 +51,8 @@
#include <wx/textctrl.h>
namespace {
class DialogExport final : public wxDialog {
class DialogExport {
wxDialog d;
agi::Context *c;
/// The export transform engine
@ -79,6 +80,7 @@ class DialogExport final : public wxDialog {
public:
DialogExport(agi::Context *c);
~DialogExport();
void ShowModal() { d.ShowModal(); }
};
// Swap the items at idx and idx + 1
@ -97,15 +99,15 @@ void swap(wxCheckListBox *list, int idx, int sel_dir) {
}
DialogExport::DialogExport(agi::Context *c)
: wxDialog(c->parent, -1, _("Export"), wxDefaultPosition, wxSize(200, 100), wxCAPTION | wxCLOSE_BOX)
: d(c->parent, -1, _("Export"), wxDefaultPosition, wxSize(200, 100), wxCAPTION | wxCLOSE_BOX)
, c(c)
, exporter(c)
{
SetIcon(GETICON(export_menu_16));
SetExtraStyle(wxWS_EX_VALIDATE_RECURSIVELY);
d.SetIcon(GETICON(export_menu_16));
d.SetExtraStyle(wxWS_EX_VALIDATE_RECURSIVELY);
std::vector<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_LISTBOX, &DialogExport::OnChange, this);
@ -118,10 +120,10 @@ DialogExport::DialogExport(agi::Context *c)
filter_list->Check(distance(begin(filters), it));
}
wxButton *btn_up = new wxButton(this, -1, _("Move &Up"), wxDefaultPosition, wxSize(90, -1));
wxButton *btn_down = new wxButton(this, -1, _("Move &Down"), wxDefaultPosition, wxSize(90, -1));
wxButton *btn_all = new wxButton(this, -1, _("Select &All"), wxDefaultPosition, wxSize(80, -1));
wxButton *btn_none = new wxButton(this, -1, _("Select &None"), wxDefaultPosition, wxSize(80, -1));
wxButton *btn_up = new wxButton(&d, -1, _("Move &Up"), wxDefaultPosition, wxSize(90, -1));
wxButton *btn_down = new wxButton(&d, -1, _("Move &Down"), wxDefaultPosition, wxSize(90, -1));
wxButton *btn_all = new wxButton(&d, -1, _("Select &All"), wxDefaultPosition, wxSize(80, -1));
wxButton *btn_none = new wxButton(&d, -1, _("Select &None"), wxDefaultPosition, wxSize(80, -1));
btn_up->Bind(wxEVT_BUTTON, [=](wxCommandEvent&) { swap(filter_list, filter_list->GetSelection() - 1, 0); });
btn_down->Bind(wxEVT_BUTTON, [=](wxCommandEvent&) { swap(filter_list, filter_list->GetSelection() - 1, 0); });
@ -134,40 +136,40 @@ DialogExport::DialogExport(agi::Context *c)
top_buttons->Add(btn_all, wxSizerFlags(1).Expand());
top_buttons->Add(btn_none, wxSizerFlags(1).Expand());
filter_description = new wxTextCtrl(this, -1, "", wxDefaultPosition, wxSize(200, 60), wxTE_MULTILINE | wxTE_READONLY);
filter_description = new wxTextCtrl(&d, -1, "", wxDefaultPosition, wxSize(200, 60), wxTE_MULTILINE | wxTE_READONLY);
// Charset dropdown list
wxStaticText *charset_list_label = new wxStaticText(this, -1, _("Text encoding:"));
charset_list = new wxChoice(this, -1, wxDefaultPosition, wxDefaultSize, agi::charset::GetEncodingsList<wxArrayString>());
wxStaticText *charset_list_label = new wxStaticText(&d, -1, _("Text encoding:"));
charset_list = new wxChoice(&d, -1, wxDefaultPosition, wxDefaultSize, agi::charset::GetEncodingsList<wxArrayString>());
wxSizer *charset_list_sizer = new wxBoxSizer(wxHORIZONTAL);
charset_list_sizer->Add(charset_list_label, wxSizerFlags().Center().Border(wxRIGHT));
charset_list_sizer->Add(charset_list, wxSizerFlags(1).Expand());
if (!charset_list->SetStringSelection(to_wx(c->ass->Properties.export_encoding)))
charset_list->SetStringSelection("Unicode (UTF-8)");
wxSizer *top_sizer = new wxStaticBoxSizer(wxVERTICAL, this, _("Filters"));
wxSizer *top_sizer = new wxStaticBoxSizer(wxVERTICAL, &d, _("Filters"));
top_sizer->Add(filter_list, wxSizerFlags(1).Expand());
top_sizer->Add(top_buttons, wxSizerFlags(0).Expand());
top_sizer->Add(filter_description, wxSizerFlags(0).Expand().Border(wxTOP));
top_sizer->Add(charset_list_sizer, wxSizerFlags(0).Expand().Border(wxTOP));
wxStdDialogButtonSizer *btn_sizer = CreateStdDialogButtonSizer(wxOK | wxCANCEL | wxHELP);
auto btn_sizer = d.CreateStdDialogButtonSizer(wxOK | wxCANCEL | wxHELP);
btn_sizer->GetAffirmativeButton()->SetLabelText(_("Export..."));
Bind(wxEVT_BUTTON, &DialogExport::OnProcess, this, wxID_OK);
Bind(wxEVT_BUTTON, std::bind(&HelpButton::OpenPage, "Export"), wxID_HELP);
d.Bind(wxEVT_BUTTON, &DialogExport::OnProcess, this, wxID_OK);
d.Bind(wxEVT_BUTTON, std::bind(&HelpButton::OpenPage, "Export"), wxID_HELP);
wxSizer *horz_sizer = new wxBoxSizer(wxHORIZONTAL);
opt_sizer = new wxBoxSizer(wxVERTICAL);
exporter.DrawSettings(this, opt_sizer);
exporter.DrawSettings(&d, opt_sizer);
horz_sizer->Add(top_sizer, wxSizerFlags().Expand().Border(wxALL & ~wxRIGHT));
horz_sizer->Add(opt_sizer, wxSizerFlags(1).Expand().Border(wxALL & ~wxLEFT));
wxSizer *main_sizer = new wxBoxSizer(wxVERTICAL);
main_sizer->Add(horz_sizer, wxSizerFlags(1).Expand());
main_sizer->Add(btn_sizer, wxSizerFlags().Expand().Border(wxALL & ~wxTOP));
SetSizerAndFit(main_sizer);
d.SetSizerAndFit(main_sizer);
RefreshOptions();
CenterOnParent();
d.CenterOnParent();
}
DialogExport::~DialogExport() {
@ -182,9 +184,9 @@ DialogExport::~DialogExport() {
}
void DialogExport::OnProcess(wxCommandEvent &) {
if (!TransferDataFromWindow()) return;
if (!d.TransferDataFromWindow()) return;
auto filename = SaveFileSelector(_("Export subtitles file"), "", "", "", to_wx(SubtitleFormat::GetWildcards(1)), this);
auto filename = SaveFileSelector(_("Export subtitles file"), "", "", "", to_wx(SubtitleFormat::GetWildcards(1)), &d);
if (filename.empty()) return;
for (size_t i = 0; i < filter_list->GetCount(); ++i) {
@ -195,27 +197,27 @@ void DialogExport::OnProcess(wxCommandEvent &) {
try {
wxBusyCursor busy;
c->ass->Properties.export_encoding = from_wx(charset_list->GetStringSelection());
exporter.Export(filename, from_wx(charset_list->GetStringSelection()), this);
exporter.Export(filename, from_wx(charset_list->GetStringSelection()), &d);
}
catch (agi::UserCancelException const&) {
}
catch (const char *error) {
wxMessageBox(error, "Error exporting subtitles", wxOK | wxICON_ERROR | wxCENTER, this);
wxMessageBox(error, "Error exporting subtitles", wxOK | wxICON_ERROR | wxCENTER, &d);
}
catch (wxString const& error) {
wxMessageBox(error, "Error exporting subtitles", wxOK | wxICON_ERROR | wxCENTER, this);
wxMessageBox(error, "Error exporting subtitles", wxOK | wxICON_ERROR | wxCENTER, &d);
}
catch (agi::Exception const& err) {
wxMessageBox(to_wx(err.GetMessage()), "Error exporting subtitles", wxOK | wxICON_ERROR | wxCENTER, this);
wxMessageBox(to_wx(err.GetMessage()), "Error exporting subtitles", wxOK | wxICON_ERROR | wxCENTER, &d);
}
catch (std::exception const& err) {
wxMessageBox(to_wx(err.what()), "Error exporting subtitles", wxOK | wxICON_ERROR | wxCENTER, this);
wxMessageBox(to_wx(err.what()), "Error exporting subtitles", wxOK | wxICON_ERROR | wxCENTER, &d);
}
catch (...) {
wxMessageBox("Unknown error", "Error exporting subtitles", wxOK | wxICON_ERROR | wxCENTER, this);
wxMessageBox("Unknown error", "Error exporting subtitles", wxOK | wxICON_ERROR | wxCENTER, &d);
}
EndModal(0);
d.EndModal(0);
}
void DialogExport::OnChange(wxCommandEvent &) {
@ -238,8 +240,8 @@ void DialogExport::RefreshOptions() {
if (wxSizer *sizer = exporter.GetSettingsSizer(from_wx(filter_list->GetString(i))))
opt_sizer->Show(sizer, filter_list->IsChecked(i), true);
}
Layout();
GetSizer()->Fit(this);
d.Layout();
d.GetSizer()->Fit(&d);
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -39,7 +39,8 @@ namespace {
/// @brief Configuration dialog for resolution resampling
///
/// Populate a ResampleSettings structure with data from the user
class DialogResample final : public wxDialog {
struct DialogResample {
wxDialog d;
agi::Context *c; ///< Project context
int script_w;
@ -86,10 +87,10 @@ enum {
};
DialogResample::DialogResample(agi::Context *c, ResampleSettings &settings)
: wxDialog(c->parent, -1, _("Resample Resolution"))
: d(c->parent, -1, _("Resample Resolution"))
, c(c)
{
SetIcon(GETICON(resample_toolbutton_16));
d.SetIcon(GETICON(resample_toolbutton_16));
memset(&settings, 0, sizeof(settings));
c->ass->GetResolution(script_w, script_h);
@ -111,23 +112,23 @@ DialogResample::DialogResample(agi::Context *c, ResampleSettings &settings)
// Create all controls and set validators
for (size_t i = 0; i < 4; ++i) {
margin_ctrl[i] = new wxSpinCtrl(this, -1, "0", wxDefaultPosition, wxSize(50, -1), wxSP_ARROW_KEYS, -9999, 9999, 0);
margin_ctrl[i] = new wxSpinCtrl(&d, -1, "0", wxDefaultPosition, wxSize(50, -1), wxSP_ARROW_KEYS, -9999, 9999, 0);
margin_ctrl[i]->SetValidator(wxGenericValidator(&settings.margin[i]));
}
symmetrical = new wxCheckBox(this, -1, _("&Symmetrical"));
symmetrical = new wxCheckBox(&d, -1, _("&Symmetrical"));
symmetrical->SetValue(true);
margin_ctrl[RIGHT]->Enable(false);
margin_ctrl[BOTTOM]->Enable(false);
source_x = new wxSpinCtrl(this, -1, "", wxDefaultPosition, wxSize(50, -1), wxSP_ARROW_KEYS, 1, INT_MAX);
source_y = new wxSpinCtrl(this, -1, "", wxDefaultPosition, wxSize(50, -1), wxSP_ARROW_KEYS, 1, INT_MAX);
source_matrix = new wxComboBox(this, -1, "", wxDefaultPosition,
source_x = new wxSpinCtrl(&d, -1, "", wxDefaultPosition, wxSize(50, -1), wxSP_ARROW_KEYS, 1, INT_MAX);
source_y = new wxSpinCtrl(&d, -1, "", wxDefaultPosition, wxSize(50, -1), wxSP_ARROW_KEYS, 1, INT_MAX);
source_matrix = new wxComboBox(&d, -1, "", wxDefaultPosition,
wxDefaultSize, to_wx(MatrixNames()), wxCB_READONLY);
dest_x = new wxSpinCtrl(this, -1, "", wxDefaultPosition, wxSize(50, -1), wxSP_ARROW_KEYS, 1, INT_MAX);
dest_y = new wxSpinCtrl(this, -1, "", wxDefaultPosition, wxSize(50, -1), wxSP_ARROW_KEYS, 1, INT_MAX);
dest_matrix = new wxComboBox(this, -1, "", wxDefaultPosition, wxDefaultSize,
dest_x = new wxSpinCtrl(&d, -1, "", wxDefaultPosition, wxSize(50, -1), wxSP_ARROW_KEYS, 1, INT_MAX);
dest_y = new wxSpinCtrl(&d, -1, "", wxDefaultPosition, wxSize(50, -1), wxSP_ARROW_KEYS, 1, INT_MAX);
dest_matrix = new wxComboBox(&d, -1, "", wxDefaultPosition, wxDefaultSize,
to_wx(MatrixNames()), wxCB_READONLY);
source_x->SetValidator(wxGenericValidator(&settings.source_x));