mirror of https://github.com/odrling/Aegisub
Eliminate the use of wxAny as it's the only thing not supported by clang
Originally committed to SVN as r6153.
This commit is contained in:
parent
38b3379b3a
commit
309e7e75fd
|
@ -46,6 +46,7 @@ AC_CANONICAL_HOST
|
|||
###########################
|
||||
build_darwin="no"
|
||||
build_linux="no"
|
||||
build_bsd="no"
|
||||
build_default="no"
|
||||
|
||||
AS_CASE([$host],
|
||||
|
@ -57,11 +58,13 @@ AS_CASE([$host],
|
|||
AS_CASE([$host],
|
||||
[*-*-darwin*], [build_darwin="yes"; AC_SUBST(DARWIN_ARCH)],
|
||||
[*-*-linux*], [build_linux="yes"],
|
||||
[*-*-*bsd*], [build_bsd="yes"],
|
||||
[build_default="yes"])
|
||||
|
||||
# Used for universalchardet.
|
||||
AC_AGI_MDCPUCFG($host)
|
||||
|
||||
AC_SUBST(build_bsd)
|
||||
AC_SUBST(build_linux)
|
||||
AC_SUBST(build_darwin)
|
||||
AC_SUBST(build_default)
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
#ifndef AGI_PRE
|
||||
#include <iterator>
|
||||
|
||||
#include <wx/any.h>
|
||||
#include <wx/checkbox.h>
|
||||
#include <wx/combobox.h>
|
||||
#include <wx/event.h>
|
||||
|
@ -511,8 +510,11 @@ Advanced_Video::Advanced_Video(wxTreebook *book, Preferences *parent): OptionPag
|
|||
SetSizerAndFit(sizer);
|
||||
}
|
||||
|
||||
void Preferences::SetOption(std::string const& name, wxAny value) {
|
||||
pending_changes[name] = value;
|
||||
void Preferences::SetOption(agi::OptionValue *new_value) {
|
||||
std::string name = new_value->GetName();
|
||||
if (pending_changes.count(name))
|
||||
delete pending_changes[name];
|
||||
pending_changes[name] = new_value;
|
||||
if (IsEnabled())
|
||||
applyButton->Enable(true);
|
||||
}
|
||||
|
@ -529,27 +531,28 @@ void Preferences::OnOK(wxCommandEvent &event) {
|
|||
}
|
||||
|
||||
void Preferences::OnApply(wxCommandEvent &) {
|
||||
for (std::map<std::string, wxAny>::iterator cur = pending_changes.begin(); cur != pending_changes.end(); ++cur) {
|
||||
for (std::map<std::string, agi::OptionValue*>::iterator cur = pending_changes.begin(); cur != pending_changes.end(); ++cur) {
|
||||
agi::OptionValue *opt = OPT_SET(cur->first);
|
||||
switch (opt->GetType()) {
|
||||
case agi::OptionValue::Type_Bool:
|
||||
opt->SetBool(cur->second.As<bool>());
|
||||
opt->SetBool(cur->second->GetBool());
|
||||
break;
|
||||
case agi::OptionValue::Type_Colour:
|
||||
opt->SetColour(cur->second.As<agi::Colour>());
|
||||
opt->SetColour(cur->second->GetColour());
|
||||
break;
|
||||
case agi::OptionValue::Type_Double:
|
||||
opt->SetDouble(cur->second.As<double>());
|
||||
opt->SetDouble(cur->second->GetDouble());
|
||||
break;
|
||||
case agi::OptionValue::Type_Int:
|
||||
opt->SetInt(cur->second.As<int>());
|
||||
opt->SetInt(cur->second->GetInt());
|
||||
break;
|
||||
case agi::OptionValue::Type_String:
|
||||
opt->SetString(cur->second.As<std::string>());
|
||||
opt->SetString(cur->second->GetString());
|
||||
break;
|
||||
default:
|
||||
throw PreferenceNotSupported("Unsupported type");
|
||||
}
|
||||
delete cur->second;
|
||||
}
|
||||
pending_changes.clear();
|
||||
|
||||
|
@ -616,4 +619,7 @@ Preferences::Preferences(wxWindow *parent): wxDialog(parent, -1, _("Preferences"
|
|||
}
|
||||
|
||||
Preferences::~Preferences() {
|
||||
for (std::map<std::string, agi::OptionValue*>::iterator cur = pending_changes.begin(); cur != pending_changes.end(); ++cur) {
|
||||
delete cur->second;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,9 +29,9 @@
|
|||
|
||||
#include <libaegisub/exception.h>
|
||||
|
||||
class wxAny;
|
||||
class wxButton;
|
||||
class wxTreebook;
|
||||
namespace agi { class OptionValue; }
|
||||
|
||||
DEFINE_BASE_EXCEPTION_NOINNER(PreferencesError, agi::Exception)
|
||||
DEFINE_SIMPLE_EXCEPTION_NOINNER(PreferenceIncorrectType, PreferencesError, "preferences/incorrect_type")
|
||||
|
@ -44,7 +44,7 @@ private:
|
|||
wxTreebook *book;
|
||||
wxButton *applyButton;
|
||||
|
||||
std::map<std::string, wxAny> pending_changes;
|
||||
std::map<std::string, agi::OptionValue*> pending_changes;
|
||||
std::deque<Thunk> pending_callbacks;
|
||||
|
||||
void OnOK(wxCommandEvent &event);
|
||||
|
@ -55,6 +55,6 @@ public:
|
|||
Preferences(wxWindow *parent);
|
||||
~Preferences();
|
||||
|
||||
void SetOption(std::string const& name, wxAny value);
|
||||
void SetOption(agi::OptionValue *new_value);
|
||||
void AddPendingChange(Thunk const& callback);
|
||||
};
|
||||
|
|
|
@ -48,20 +48,20 @@
|
|||
#include "standard_paths.h"
|
||||
#include "video_provider_manager.h"
|
||||
|
||||
#define OPTION_UPDATER(type, evttype, body) \
|
||||
#define OPTION_UPDATER(type, evttype, opt, body) \
|
||||
class type { \
|
||||
std::string name; \
|
||||
Preferences *parent; \
|
||||
public: \
|
||||
type(std::string const& n, Preferences *p) : name(n),parent(p) {} \
|
||||
void operator()(evttype& evt) { parent->SetOption(name, body); } \
|
||||
type(std::string const& n, Preferences *p) : name(n), parent(p) {} \
|
||||
void operator()(evttype& evt) { parent->SetOption(new agi::opt(name, body)); } \
|
||||
}
|
||||
|
||||
OPTION_UPDATER(StringUpdater, wxCommandEvent, STD_STR(evt.GetString()));
|
||||
OPTION_UPDATER(IntUpdater, wxSpinEvent, evt.GetInt());
|
||||
OPTION_UPDATER(IntCBUpdater, wxCommandEvent, evt.GetInt());
|
||||
OPTION_UPDATER(DoubleUpdater, wxSpinEvent, evt.GetInt());
|
||||
OPTION_UPDATER(BoolUpdater, wxCommandEvent, !!evt.GetInt());
|
||||
OPTION_UPDATER(StringUpdater, wxCommandEvent, OptionValueString, STD_STR(evt.GetString()));
|
||||
OPTION_UPDATER(IntUpdater, wxSpinEvent, OptionValueInt, evt.GetInt());
|
||||
OPTION_UPDATER(IntCBUpdater, wxCommandEvent, OptionValueInt, evt.GetInt());
|
||||
OPTION_UPDATER(DoubleUpdater, wxSpinEvent, OptionValueDouble, evt.GetInt());
|
||||
OPTION_UPDATER(BoolUpdater, wxCommandEvent, OptionValueBool, !!evt.GetInt());
|
||||
class ColourUpdater {
|
||||
const char *name;
|
||||
Preferences *parent;
|
||||
|
@ -70,7 +70,7 @@ public:
|
|||
void operator()(wxCommandEvent& evt) {
|
||||
ColourButton *btn = static_cast<ColourButton*>(evt.GetClientData());
|
||||
if (btn) {
|
||||
parent->SetOption(name, STD_STR(btn->GetColour().GetAsString(wxC2S_CSS_SYNTAX)));
|
||||
parent->SetOption(new agi::OptionValueColour(name, STD_STR(btn->GetColour().GetAsString(wxC2S_CSS_SYNTAX))));
|
||||
}
|
||||
else {
|
||||
evt.Skip();
|
||||
|
|
Loading…
Reference in New Issue