forked from mia/Aegisub
Make OPT_GET return a const OptionValue* and add OPT_SUB/OPT_UNSUB for subscribing to option changes
Originally committed to SVN as r4834.
This commit is contained in:
parent
469bd3e165
commit
6affce0581
9 changed files with 53 additions and 46 deletions
|
@ -107,23 +107,23 @@ BaseGrid::BaseGrid(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wx
|
||||||
UpdateStyle();
|
UpdateStyle();
|
||||||
|
|
||||||
agi::OptionValue::ChangeListener UpdateStyle(std::tr1::bind(&BaseGrid::UpdateStyle, this));
|
agi::OptionValue::ChangeListener UpdateStyle(std::tr1::bind(&BaseGrid::UpdateStyle, this));
|
||||||
OPT_GET("Subtitle/Grid/Font Face")->Subscribe(this, UpdateStyle);
|
OPT_SUB("Subtitle/Grid/Font Face", this, UpdateStyle);
|
||||||
OPT_GET("Subtitle/Grid/Font Size")->Subscribe(this, UpdateStyle);
|
OPT_SUB("Subtitle/Grid/Font Size", this, UpdateStyle);
|
||||||
|
|
||||||
agi::OptionValue::ChangeListener Refresh(std::tr1::bind(&BaseGrid::Refresh, this, false, (wxRect*)NULL));
|
agi::OptionValue::ChangeListener Refresh(std::tr1::bind(&BaseGrid::Refresh, this, false, (wxRect*)NULL));
|
||||||
OPT_GET("Colour/Subtitle Grid/Active Border")->Subscribe(this, Refresh);
|
OPT_SUB("Colour/Subtitle Grid/Active Border", this, Refresh);
|
||||||
OPT_GET("Colour/Subtitle Grid/Background/Background")->Subscribe(this, Refresh);
|
OPT_SUB("Colour/Subtitle Grid/Background/Background", this, Refresh);
|
||||||
OPT_GET("Colour/Subtitle Grid/Background/Comment")->Subscribe(this, Refresh);
|
OPT_SUB("Colour/Subtitle Grid/Background/Comment", this, Refresh);
|
||||||
OPT_GET("Colour/Subtitle Grid/Background/Inframe")->Subscribe(this, Refresh);
|
OPT_SUB("Colour/Subtitle Grid/Background/Inframe", this, Refresh);
|
||||||
OPT_GET("Colour/Subtitle Grid/Background/Selected Comment")->Subscribe(this, Refresh);
|
OPT_SUB("Colour/Subtitle Grid/Background/Selected Comment", this, Refresh);
|
||||||
OPT_GET("Colour/Subtitle Grid/Background/Selection")->Subscribe(this, Refresh);
|
OPT_SUB("Colour/Subtitle Grid/Background/Selection", this, Refresh);
|
||||||
OPT_GET("Colour/Subtitle Grid/Collision")->Subscribe(this, Refresh);
|
OPT_SUB("Colour/Subtitle Grid/Collision", this, Refresh);
|
||||||
OPT_GET("Colour/Subtitle Grid/Header")->Subscribe(this, Refresh);
|
OPT_SUB("Colour/Subtitle Grid/Header", this, Refresh);
|
||||||
OPT_GET("Colour/Subtitle Grid/Left Column")->Subscribe(this, Refresh);
|
OPT_SUB("Colour/Subtitle Grid/Left Column", this, Refresh);
|
||||||
OPT_GET("Colour/Subtitle Grid/Lines")->Subscribe(this, Refresh);
|
OPT_SUB("Colour/Subtitle Grid/Lines", this, Refresh);
|
||||||
OPT_GET("Colour/Subtitle Grid/Selection")->Subscribe(this, Refresh);
|
OPT_SUB("Colour/Subtitle Grid/Selection", this, Refresh);
|
||||||
OPT_GET("Colour/Subtitle Grid/Standard")->Subscribe(this, Refresh);
|
OPT_SUB("Colour/Subtitle Grid/Standard", this, Refresh);
|
||||||
OPT_GET("Subtitle/Grid/Highlight Subtitles in Frame")->Subscribe(this, Refresh);
|
OPT_SUB("Subtitle/Grid/Highlight Subtitles in Frame", this, Refresh);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -167,7 +167,7 @@ FrameMain::FrameMain (wxArrayString args)
|
||||||
if (time > 0) {
|
if (time > 0) {
|
||||||
AutoSave.Start(time*1000);
|
AutoSave.Start(time*1000);
|
||||||
}
|
}
|
||||||
OPT_GET("App/Auto/Save Every Seconds")->Subscribe(this, std::tr1::bind(autosave_timer_changed, std::tr1::ref(AutoSave), std::tr1::placeholders::_1));
|
OPT_SUB("App/Auto/Save Every Seconds", this, std::tr1::bind(autosave_timer_changed, std::tr1::ref(AutoSave), std::tr1::placeholders::_1));
|
||||||
|
|
||||||
// Set accelerator keys
|
// Set accelerator keys
|
||||||
StartupLog(_T("Install hotkeys"));
|
StartupLog(_T("Install hotkeys"));
|
||||||
|
|
|
@ -69,11 +69,18 @@ namespace config {
|
||||||
namespace Automation4 { class AutoloadScriptManager; }
|
namespace Automation4 { class AutoloadScriptManager; }
|
||||||
|
|
||||||
/// Macro to get OptionValue object.
|
/// Macro to get OptionValue object.
|
||||||
#define OPT_GET(x) config::opt->Get(x)
|
#define OPT_GET(x) const_cast<const agi::OptionValue *>(config::opt->Get(x))
|
||||||
|
|
||||||
/// Macro to set OptionValue object.
|
/// Macro to set OptionValue object.
|
||||||
#define OPT_SET(x) config::opt->Get(x)
|
#define OPT_SET(x) config::opt->Get(x)
|
||||||
|
|
||||||
|
/// Macro to subscribe to OptionValue changes
|
||||||
|
#define OPT_SUB(x, ...) config::opt->Get(x)->Subscribe(__VA_ARGS__)
|
||||||
|
|
||||||
|
/// Macro to unsubscribe to OptionValue changes
|
||||||
|
#define OPT_UNSUB(x, ...) config::opt->Get(x)->Unsubscribe(__VA_ARGS__)
|
||||||
|
|
||||||
|
|
||||||
/// DOCME
|
/// DOCME
|
||||||
/// @class AegisubApp
|
/// @class AegisubApp
|
||||||
/// @brief DOCME
|
/// @brief DOCME
|
||||||
|
|
|
@ -108,7 +108,7 @@ void OptionPage::CellSkip(wxFlexGridSizer *&flex) {
|
||||||
|
|
||||||
void OptionPage::OptionAdd(wxFlexGridSizer *&flex, const wxString &name, const char *opt_name, double min, double max, double inc) {
|
void OptionPage::OptionAdd(wxFlexGridSizer *&flex, const wxString &name, const char *opt_name, double min, double max, double inc) {
|
||||||
|
|
||||||
agi::OptionValue *opt = OPT_GET(opt_name);
|
const agi::OptionValue *opt = OPT_GET(opt_name);
|
||||||
|
|
||||||
int type = opt->GetType();
|
int type = opt->GetType();
|
||||||
|
|
||||||
|
@ -162,7 +162,7 @@ void OptionPage::OptionAdd(wxFlexGridSizer *&flex, const wxString &name, const c
|
||||||
|
|
||||||
|
|
||||||
void OptionPage::OptionChoice(wxFlexGridSizer *&flex, const wxString &name, const wxArrayString &choices, const char *opt_name) {
|
void OptionPage::OptionChoice(wxFlexGridSizer *&flex, const wxString &name, const wxArrayString &choices, const char *opt_name) {
|
||||||
agi::OptionValue *opt = OPT_GET(opt_name);
|
const agi::OptionValue *opt = OPT_GET(opt_name);
|
||||||
|
|
||||||
flex->Add(new wxStaticText(this, wxID_ANY, name), 1, wxALIGN_CENTRE_VERTICAL);
|
flex->Add(new wxStaticText(this, wxID_ANY, name), 1, wxALIGN_CENTRE_VERTICAL);
|
||||||
wxComboBox *cb = new wxComboBox(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, choices, wxCB_READONLY | wxCB_DROPDOWN);
|
wxComboBox *cb = new wxComboBox(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, choices, wxCB_READONLY | wxCB_DROPDOWN);
|
||||||
|
@ -197,7 +197,7 @@ wxFlexGridSizer* OptionPage::PageSizer(wxString name) {
|
||||||
|
|
||||||
|
|
||||||
void OptionPage::OptionBrowse(wxFlexGridSizer *&flex, const wxString &name, BrowseType browse_type, const char *opt_name) {
|
void OptionPage::OptionBrowse(wxFlexGridSizer *&flex, const wxString &name, BrowseType browse_type, const char *opt_name) {
|
||||||
agi::OptionValue *opt = OPT_GET(opt_name);
|
const agi::OptionValue *opt = OPT_GET(opt_name);
|
||||||
|
|
||||||
if (opt->GetType() != agi::OptionValue::Type_String)
|
if (opt->GetType() != agi::OptionValue::Type_String)
|
||||||
throw PreferenceIncorrectType("Option must be agi::OptionValue::Type_String for BrowseButton.");
|
throw PreferenceIncorrectType("Option must be agi::OptionValue::Type_String for BrowseButton.");
|
||||||
|
|
|
@ -183,21 +183,21 @@ SubsTextEditCtrl::SubsTextEditCtrl(wxWindow* parent, wxSize wsize, long style, S
|
||||||
|
|
||||||
agi::OptionValue::ChangeListener SetStyles = bind(&SubsTextEditCtrl::SetStyles, this);
|
agi::OptionValue::ChangeListener SetStyles = bind(&SubsTextEditCtrl::SetStyles, this);
|
||||||
|
|
||||||
OPT_GET("Subtitle/Edit Box/Font Face")->Subscribe(this, SetStyles);
|
OPT_SUB("Subtitle/Edit Box/Font Face", this, SetStyles);
|
||||||
OPT_GET("Subtitle/Edit Box/Font Size")->Subscribe(this, SetStyles);
|
OPT_SUB("Subtitle/Edit Box/Font Size", this, SetStyles);
|
||||||
OPT_GET("Colour/Subtitle/Syntax/Normal")->Subscribe(this, SetStyles);
|
OPT_SUB("Colour/Subtitle/Syntax/Normal", this, SetStyles);
|
||||||
OPT_GET("Colour/Subtitle/Syntax/Brackets")->Subscribe(this, SetStyles);
|
OPT_SUB("Colour/Subtitle/Syntax/Brackets", this, SetStyles);
|
||||||
OPT_GET("Colour/Subtitle/Syntax/Slashes")->Subscribe(this, SetStyles);
|
OPT_SUB("Colour/Subtitle/Syntax/Slashes", this, SetStyles);
|
||||||
OPT_GET("Colour/Subtitle/Syntax/Highlight Tags")->Subscribe(this, SetStyles);
|
OPT_SUB("Colour/Subtitle/Syntax/Highlight Tags", this, SetStyles);
|
||||||
OPT_GET("Colour/Subtitle/Syntax/Error")->Subscribe(this, SetStyles);
|
OPT_SUB("Colour/Subtitle/Syntax/Error", this, SetStyles);
|
||||||
OPT_GET("Colour/Subtitle/Syntax/Background/Error")->Subscribe(this, SetStyles);
|
OPT_SUB("Colour/Subtitle/Syntax/Background/Error", this, SetStyles);
|
||||||
OPT_GET("Colour/Subtitle/Syntax/Parameters")->Subscribe(this, SetStyles);
|
OPT_SUB("Colour/Subtitle/Syntax/Parameters", this, SetStyles);
|
||||||
OPT_GET("Colour/Subtitle/Syntax/Line Break")->Subscribe(this, SetStyles);
|
OPT_SUB("Colour/Subtitle/Syntax/Line Break", this, SetStyles);
|
||||||
OPT_GET("Colour/Subtitle/Syntax/Karaoke Template")->Subscribe(this, SetStyles);
|
OPT_SUB("Colour/Subtitle/Syntax/Karaoke Template", this, SetStyles);
|
||||||
|
|
||||||
OPT_GET("Subtitle/Highlight/Syntax")->Subscribe(this, bind(&SubsTextEditCtrl::UpdateStyle, this, 0, -1));
|
OPT_SUB("Subtitle/Highlight/Syntax", this, bind(&SubsTextEditCtrl::UpdateStyle, this, 0, -1));
|
||||||
static wxStyledTextEvent evt;
|
static wxStyledTextEvent evt;
|
||||||
OPT_GET("App/Call Tips")->Subscribe(this, bind(&SubsTextEditCtrl::UpdateCallTip, this, ref(evt)));
|
OPT_SUB("App/Call Tips", this, bind(&SubsTextEditCtrl::UpdateCallTip, this, ref(evt)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -110,15 +110,15 @@ VideoContext::VideoContext()
|
||||||
Bind(EVT_SUBTITLES_ERROR, &VideoContext::OnSubtitlesError, this);
|
Bind(EVT_SUBTITLES_ERROR, &VideoContext::OnSubtitlesError, this);
|
||||||
|
|
||||||
agi::OptionValue::ChangeListener providerChanged(std::tr1::bind(&VideoContext::Reload, this));
|
agi::OptionValue::ChangeListener providerChanged(std::tr1::bind(&VideoContext::Reload, this));
|
||||||
OPT_GET("Subtitle/Provider")->Subscribe(this, providerChanged);
|
OPT_SUB("Subtitle/Provider", this, providerChanged);
|
||||||
OPT_GET("Video/Provider")->Subscribe(this, providerChanged);
|
OPT_SUB("Video/Provider", this, providerChanged);
|
||||||
|
|
||||||
// It would be nice to find a way to move these to the individual providers
|
// It would be nice to find a way to move these to the individual providers
|
||||||
OPT_GET("Provider/Avisynth/Allow Ancient")->Subscribe(this, providerChanged);
|
OPT_SUB("Provider/Avisynth/Allow Ancient", this, providerChanged);
|
||||||
OPT_GET("Provider/Avisynth/Memory Max")->Subscribe(this, providerChanged);
|
OPT_SUB("Provider/Avisynth/Memory Max", this, providerChanged);
|
||||||
|
|
||||||
OPT_GET("Provider/Video/FFmpegSource/Decoding Threads")->Subscribe(this, providerChanged);
|
OPT_SUB("Provider/Video/FFmpegSource/Decoding Threads", this, providerChanged);
|
||||||
OPT_GET("Provider/Video/FFmpegSource/Unsafe Seeking")->Subscribe(this, providerChanged);
|
OPT_SUB("Provider/Video/FFmpegSource/Unsafe Seeking", this, providerChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
VideoContext::~VideoContext () {
|
VideoContext::~VideoContext () {
|
||||||
|
@ -259,7 +259,7 @@ void VideoContext::UpdateDisplays(bool full, bool seek) {
|
||||||
|
|
||||||
// Update audio display
|
// Update audio display
|
||||||
if (audio && audio->loaded && audio->IsShownOnScreen()) {
|
if (audio && audio->loaded && audio->IsShownOnScreen()) {
|
||||||
static agi::OptionValue* opt = OPT_GET("Audio/Display/Draw/Video Position");
|
static const agi::OptionValue* opt = OPT_GET("Audio/Display/Draw/Video Position");
|
||||||
if (opt->GetBool()) {
|
if (opt->GetBool()) {
|
||||||
audio->UpdateImage(false);
|
audio->UpdateImage(false);
|
||||||
}
|
}
|
||||||
|
@ -283,7 +283,7 @@ void VideoContext::JumpToFrame(int n) {
|
||||||
|
|
||||||
UpdateDisplays(false, true);
|
UpdateDisplays(false, true);
|
||||||
|
|
||||||
static agi::OptionValue* highlight = OPT_GET("Subtitle/Grid/Highlight Subtitles in Frame");
|
static const agi::OptionValue* highlight = OPT_GET("Subtitle/Grid/Highlight Subtitles in Frame");
|
||||||
if (!isPlaying && highlight->GetBool()) grid->Refresh(false);
|
if (!isPlaying && highlight->GetBool()) grid->Refresh(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -308,7 +308,7 @@ int VideoContext::GetHeight() const {
|
||||||
|
|
||||||
void VideoContext::SaveSnapshot(bool raw) {
|
void VideoContext::SaveSnapshot(bool raw) {
|
||||||
// Get folder
|
// Get folder
|
||||||
static agi::OptionValue* ssPath = OPT_GET("Path/Screenshot");
|
static const agi::OptionValue* ssPath = OPT_GET("Path/Screenshot");
|
||||||
wxString option = lagi_wxString(ssPath->GetString());
|
wxString option = lagi_wxString(ssPath->GetString());
|
||||||
wxFileName videoFile(videoName);
|
wxFileName videoFile(videoName);
|
||||||
wxString basepath;
|
wxString basepath;
|
||||||
|
|
|
@ -138,7 +138,7 @@ private:
|
||||||
|
|
||||||
wxString ovrTimecodeFile;
|
wxString ovrTimecodeFile;
|
||||||
|
|
||||||
agi::OptionValue* playAudioOnStep;
|
const agi::OptionValue* playAudioOnStep;
|
||||||
|
|
||||||
void OnPlayTimer(wxTimerEvent &event);
|
void OnPlayTimer(wxTimerEvent &event);
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ struct VideoState {
|
||||||
/// @class VideoDisplay
|
/// @class VideoDisplay
|
||||||
/// @brief DOCME
|
/// @brief DOCME
|
||||||
class VideoDisplay : public wxGLCanvas {
|
class VideoDisplay : public wxGLCanvas {
|
||||||
agi::OptionValue* alwaysShowTools;
|
const agi::OptionValue* alwaysShowTools;
|
||||||
/// The unscaled size of the displayed video
|
/// The unscaled size of the displayed video
|
||||||
wxSize origSize;
|
wxSize origSize;
|
||||||
|
|
||||||
|
|
|
@ -73,11 +73,11 @@ VideoSlider::VideoSlider (wxWindow* parent, wxWindowID id)
|
||||||
SetMinSize(wxSize(20, 25));
|
SetMinSize(wxSize(20, 25));
|
||||||
locked = false;
|
locked = false;
|
||||||
SetRange(0,1);
|
SetRange(0,1);
|
||||||
OPT_GET("Video/Slider/Show Keyframes")->Subscribe(this, std::tr1::bind(&wxWindow::Refresh, this, false, (wxRect*)NULL));
|
OPT_SUB("Video/Slider/Show Keyframes", this, std::tr1::bind(&wxWindow::Refresh, this, false, (wxRect*)NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
VideoSlider::~VideoSlider() {
|
VideoSlider::~VideoSlider() {
|
||||||
OPT_GET("Video/Slider/Show Keyframes")->Unsubscribe(this);
|
OPT_UNSUB("Video/Slider/Show Keyframes", this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Set value
|
/// @brief Set value
|
||||||
|
|
Loading…
Reference in a new issue