forked from mia/Aegisub
vapoursynth: Add buttons to set default scripts to default
This commit is contained in:
parent
3d278547fe
commit
d06a31968d
4 changed files with 35 additions and 6 deletions
|
@ -84,6 +84,12 @@ public:
|
|||
Color const& GetColor() const;
|
||||
bool const& GetBool() const;
|
||||
|
||||
std::string const& GetDefaultString() const;
|
||||
int64_t const& GetDefaultInt() const;
|
||||
double const& GetDefaultDouble() const;
|
||||
Color const& GetDefaultColor() const;
|
||||
bool const& GetDefaultBool() const;
|
||||
|
||||
void SetString(const std::string);
|
||||
void SetInt(const int64_t);
|
||||
void SetDouble(const double);
|
||||
|
@ -96,6 +102,12 @@ public:
|
|||
std::vector<Color> const& GetListColor() const;
|
||||
std::vector<bool> const& GetListBool() const;
|
||||
|
||||
std::vector<std::string> const& GetDefaultListString() const;
|
||||
std::vector<int64_t> const& GetDefaultListInt() const;
|
||||
std::vector<double> const& GetDefaultListDouble() const;
|
||||
std::vector<Color> const& GetDefaultListColor() const;
|
||||
std::vector<bool> const& GetDefaultListBool() const;
|
||||
|
||||
void SetListString(std::vector<std::string>);
|
||||
void SetListInt(std::vector<int64_t>);
|
||||
void SetListDouble(std::vector<double>);
|
||||
|
@ -117,6 +129,7 @@ public:
|
|||
: OptionValue(std::move(member_name)) \
|
||||
, value(member_value), value_default(member_value) { } \
|
||||
type const& GetValue() const { return value; } \
|
||||
type const& GetDefault() const { return value_default; } \
|
||||
void SetValue(type new_val) { value = std::move(new_val); NotifyChanged(); } \
|
||||
OptionType GetType() const { return OptionType::type_name; } \
|
||||
void Reset() { value = value_default; NotifyChanged(); } \
|
||||
|
@ -141,6 +154,7 @@ CONFIG_OPTIONVALUE(Bool, bool)
|
|||
: OptionValue(std::move(name)) \
|
||||
, array(value), array_default(value) { } \
|
||||
std::vector<type> const& GetValue() const { return array; } \
|
||||
std::vector<type> const& GetDefault() const { return array_default; } \
|
||||
void SetValue(std::vector<type> val) { array = std::move(val); NotifyChanged(); } \
|
||||
OptionType GetType() const { return OptionType::List##type_name; } \
|
||||
void Reset() { array = array_default; NotifyChanged(); } \
|
||||
|
@ -156,6 +170,7 @@ CONFIG_OPTIONVALUE_LIST(Bool, bool)
|
|||
|
||||
#define CONFIG_OPTIONVALUE_ACCESSORS(ReturnType, Type) \
|
||||
inline ReturnType const& OptionValue::Get##Type() const { return As<OptionValue##Type>(OptionType::Type)->GetValue(); } \
|
||||
inline ReturnType const& OptionValue::GetDefault##Type() const { return As<OptionValue##Type>(OptionType::Type)->GetDefault(); } \
|
||||
inline void OptionValue::Set##Type(ReturnType v) { As<OptionValue##Type>(OptionType::Type)->SetValue(std::move(v)); }
|
||||
|
||||
CONFIG_OPTIONVALUE_ACCESSORS(std::string, String)
|
||||
|
|
|
@ -480,22 +480,36 @@ void VapourSynth(wxTreebook *book, Preferences *parent) {
|
|||
|
||||
auto video = p->PageSizer(_("Default Video Script"));
|
||||
|
||||
auto make_default_button = [=](std::string optname, wxTextCtrl *ctrl) {
|
||||
auto showdefault = new wxButton(p, -1, _("Set to Default"));
|
||||
showdefault->Bind(wxEVT_BUTTON, [=](auto e) {
|
||||
ctrl->SetValue(OPT_GET(optname)->GetDefaultString());
|
||||
});
|
||||
return showdefault;
|
||||
};
|
||||
|
||||
auto vhint = new wxStaticText(p, wxID_ANY, _("This script will be executed to load video files that aren't\nVapourSynth scripts (i.e. end in .py or .vpy).\nThe filename variable stores the path to the file."));
|
||||
p->sizer->Fit(p);
|
||||
vhint->Wrap(400);
|
||||
video->Add(vhint, 0, wxALL, 5);
|
||||
video->AddSpacer(16);
|
||||
p->CellSkip(video);
|
||||
|
||||
p->OptionAddMultiline(video, "Provider/Video/VapourSynth/Default Script");
|
||||
auto vdef = p->OptionAddMultiline(video, "Provider/Video/VapourSynth/Default Script");
|
||||
p->CellSkip(video);
|
||||
|
||||
video->Add(make_default_button("Provider/Video/VapourSynth/Default Script", vdef), wxSizerFlags().Right());
|
||||
|
||||
auto audio = p->PageSizer(_("Default Audio Script"));
|
||||
auto ahint = new wxStaticText(p, wxID_ANY, _("This script will be executed to load audio files that aren't\nVapourSynth scripts (i.e. end in .py or .vpy).\nThe filename variable stores the path to the file."));
|
||||
p->sizer->Fit(p);
|
||||
ahint->Wrap(400);
|
||||
audio->Add(ahint, 0, wxALL, 5);
|
||||
audio->AddSpacer(16);
|
||||
p->CellSkip(audio);
|
||||
|
||||
p->OptionAddMultiline(audio, "Provider/Audio/VapourSynth/Default Script");
|
||||
auto adef = p->OptionAddMultiline(audio, "Provider/Audio/VapourSynth/Default Script");
|
||||
p->CellSkip(audio);
|
||||
|
||||
audio->Add(make_default_button("Provider/Audio/VapourSynth/Default Script", adef), wxSizerFlags().Right());
|
||||
|
||||
p->SetSizerAndFit(p->sizer);
|
||||
#endif
|
||||
|
|
|
@ -156,7 +156,7 @@ wxControl *OptionPage::OptionAdd(wxFlexGridSizer *flex, const wxString &name, co
|
|||
}
|
||||
}
|
||||
|
||||
wxControl *OptionPage::OptionAddMultiline(wxSizer *sizer, const char *opt_name) {
|
||||
wxTextCtrl *OptionPage::OptionAddMultiline(wxSizer *sizer, const char *opt_name) {
|
||||
parent->AddChangeableOption(opt_name);
|
||||
const auto opt = OPT_GET(opt_name);
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ public:
|
|||
|
||||
void CellSkip(wxFlexGridSizer *flex);
|
||||
wxControl *OptionAdd(wxFlexGridSizer *flex, const wxString &name, const char *opt_name, double min=0, double max=INT_MAX, double inc=1);
|
||||
wxControl *OptionAddMultiline(wxSizer *flex, const char *opt_name);
|
||||
wxTextCtrl *OptionAddMultiline(wxSizer *flex, const char *opt_name);
|
||||
void OptionChoice(wxFlexGridSizer *flex, const wxString &name, const wxArrayString &choices, const char *opt_name);
|
||||
void OptionBrowse(wxFlexGridSizer *flex, const wxString &name, const char *opt_name, wxControl *enabler = nullptr, bool do_enable = false);
|
||||
void OptionFont(wxSizer *sizer, std::string opt_prefix);
|
||||
|
|
Loading…
Reference in a new issue