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