MCPcopy Create free account
hub / github.com/TypesettingTools/Aegisub / OptionAdd

Method OptionAdd

src/preferences_base.cpp:112–156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110}
111
112wxControl *OptionPage::OptionAdd(wxFlexGridSizer *flex, const wxString &name, const char *opt_name, double min, double max, double inc) {
113 parent->AddChangeableOption(opt_name);
114 const auto opt = OPT_GET(opt_name);
115
116 switch (opt->GetType()) {
117 case agi::OptionType::Bool: {
118 auto cb = new wxCheckBox(this, -1, name);
119 flex->Add(cb, 1, wxEXPAND, 0);
120 cb->SetValue(opt->GetBool());
121 cb->Bind(wxEVT_CHECKBOX, BoolUpdater(opt_name, parent));
122 return cb;
123 }
124
125 case agi::OptionType::Int: {
126 auto sc = new wxSpinCtrl(this, -1, std::to_wstring((int)opt->GetInt()), wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, min, max, opt->GetInt());
127 sc->Bind(wxEVT_SPINCTRL, IntUpdater(opt_name, parent));
128 Add(flex, name, sc);
129 return sc;
130 }
131
132 case agi::OptionType::Double: {
133 auto scd = new wxSpinCtrlDouble(this, -1, std::to_wstring(opt->GetDouble()), wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, min, max, opt->GetDouble(), inc);
134 scd->Bind(wxEVT_SPINCTRLDOUBLE, DoubleUpdater(opt_name, parent));
135 Add(flex, name, scd);
136 return scd;
137 }
138
139 case agi::OptionType::String: {
140 auto text = new wxTextCtrl(this, -1 , to_wx(opt->GetString()));
141 text->Bind(wxEVT_TEXT, StringUpdater(opt_name, parent));
142 Add(flex, name, text);
143 return text;
144 }
145
146 case agi::OptionType::Color: {
147 auto cb = new ColourButton(this, wxSize(40,10), false, opt->GetColor());
148 cb->Bind(EVT_COLOR, ColourUpdater(opt_name, parent));
149 Add(flex, name, cb);
150 return cb;
151 }
152
153 default:
154 throw agi::InternalError("Unsupported type");
155 }
156}
157
158void OptionPage::OptionChoice(wxFlexGridSizer *flex, const wxString &name, const wxArrayString &choices, const char *opt_name) {
159 parent->AddChangeableOption(opt_name);

Callers 9

GeneralFunction · 0.80
AudioFunction · 0.80
VideoFunction · 0.80
InterfaceFunction · 0.80
Interface_ColoursFunction · 0.80
BackupFunction · 0.80
AutomationFunction · 0.80
Advanced_AudioFunction · 0.80
Advanced_VideoFunction · 0.80

Calls 7

AddChangeableOptionMethod · 0.80
BindMethod · 0.80
GetColorMethod · 0.80
to_wxFunction · 0.70
GetTypeMethod · 0.45
AddMethod · 0.45
SetValueMethod · 0.45

Tested by

no test coverage detected