提交 7ba497fe 编写于 作者: J jp9000

add move constructor to wx connector class, add simple connector list class,...

add move constructor to wx connector class, add simple connector list class, add initial video settings class, update build files
上级 02c32f9c
...@@ -25,6 +25,7 @@ Settings="Settings" ...@@ -25,6 +25,7 @@ Settings="Settings"
Settings.General="General" Settings.General="General"
Settings.General.Language="Language:" Settings.General.Language="Language:"
Settings.General.LanguageChanged="The program must be restarted in order to change the language"
Settings.Outputs="Outputs" Settings.Outputs="Outputs"
......
...@@ -44,6 +44,7 @@ add_executable(obs ...@@ -44,6 +44,7 @@ add_executable(obs
window-main-basic.cpp window-main-basic.cpp
window-settings-basic.cpp window-settings-basic.cpp
settings-basic-general.cpp settings-basic-general.cpp
settings-basic-video.cpp
wx-subclass.cpp wx-subclass.cpp
wx-wrappers.cpp wx-wrappers.cpp
obs-app.cpp obs-app.cpp
......
...@@ -15,6 +15,7 @@ obs_LDADD = $(top_srcdir)/libobs/libobs.la ...@@ -15,6 +15,7 @@ obs_LDADD = $(top_srcdir)/libobs/libobs.la
obs_SOURCES = window-main-basic.cpp \ obs_SOURCES = window-main-basic.cpp \
window-settings-basic.cpp \ window-settings-basic.cpp \
settings-basic-general.cpp \ settings-basic-general.cpp \
settings-basic-video.cpp \
obs-app.cpp \ obs-app.cpp \
wx-subclass.cpp \ wx-subclass.cpp \
wx-wrappers.cpp \ wx-wrappers.cpp \
......
...@@ -54,3 +54,4 @@ wxDECLARE_APP(OBSApp); ...@@ -54,3 +54,4 @@ wxDECLARE_APP(OBSApp);
inline config_t GetGlobalConfig() {return wxGetApp().GlobalConfig();} inline config_t GetGlobalConfig() {return wxGetApp().GlobalConfig();}
#define Str(lookupVal) wxGetApp().GetString(lookupVal) #define Str(lookupVal) wxGetApp().GetString(lookupVal)
#define WXStr(lookupVal) wxString(Str(lookupVal), wxConvUTF8)
...@@ -15,15 +15,13 @@ ...@@ -15,15 +15,13 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/ ******************************************************************************/
#include <wx/event.h>
#include "obs-app.hpp" #include "obs-app.hpp"
#include "settings-basic.hpp" #include "settings-basic.hpp"
#include "window-settings-basic.hpp" #include "window-settings-basic.hpp"
#include "wx-wrappers.hpp" #include "wx-wrappers.hpp"
#include "platform.hpp" #include "platform.hpp"
class GeneralSettings : public BasicSettingsData { class BasicGenData : public BasicSettingsData {
ConfigFile localeIni; ConfigFile localeIni;
WXConnector languageBoxConnector; WXConnector languageBoxConnector;
...@@ -33,7 +31,7 @@ class GeneralSettings : public BasicSettingsData { ...@@ -33,7 +31,7 @@ class GeneralSettings : public BasicSettingsData {
void FillLanguageList(const char *currentLang); void FillLanguageList(const char *currentLang);
public: public:
GeneralSettings(OBSBasicSettings *window); BasicGenData(OBSBasicSettings *window);
virtual void Apply(); virtual void Apply();
}; };
...@@ -55,14 +53,14 @@ public: ...@@ -55,14 +53,14 @@ public:
} }
}; };
int GeneralSettings::AddLanguage(const char *tag) int BasicGenData::AddLanguage(const char *tag)
{ {
LanguageInfo *info = new LanguageInfo(localeIni, tag); LanguageInfo *info = new LanguageInfo(localeIni, tag);
return window->languageList->Append(wxString(info->name, wxConvUTF8), return window->languageList->Append(wxString(info->name, wxConvUTF8),
info); info);
} }
void GeneralSettings::FillLanguageList(const char *currentLang) void BasicGenData::FillLanguageList(const char *currentLang)
{ {
size_t numSections = config_num_sections(localeIni); size_t numSections = config_num_sections(localeIni);
for (size_t i = 0; i < numSections; i++) { for (size_t i = 0; i < numSections; i++) {
...@@ -74,7 +72,7 @@ void GeneralSettings::FillLanguageList(const char *currentLang) ...@@ -74,7 +72,7 @@ void GeneralSettings::FillLanguageList(const char *currentLang)
} }
} }
GeneralSettings::GeneralSettings(OBSBasicSettings *window) BasicGenData::BasicGenData(OBSBasicSettings *window)
: BasicSettingsData (window) : BasicSettingsData (window)
{ {
string path; string path;
...@@ -90,18 +88,31 @@ GeneralSettings::GeneralSettings(OBSBasicSettings *window) ...@@ -90,18 +88,31 @@ GeneralSettings::GeneralSettings(OBSBasicSettings *window)
languageBoxConnector.Connect( languageBoxConnector.Connect(
window->languageList, window->languageList,
wxEVT_COMBOBOX, wxEVT_COMBOBOX,
wxCommandEventHandler(GeneralSettings::LanguageChanged), wxCommandEventHandler(BasicGenData::LanguageChanged),
NULL, NULL,
this); this);
window->generalText->Hide();
} }
void GeneralSettings::LanguageChanged(wxCommandEvent &event) void BasicGenData::LanguageChanged(wxCommandEvent &event)
{ {
dataChanged = true;
window->generalText->SetLabel(
WXStr("Settings.General.LanguageChanged"));
window->generalText->Show();
} }
void GeneralSettings::Apply() void BasicGenData::Apply()
{ {
int sel = window->languageList->GetSelection();
if (sel == wxNOT_FOUND)
return;
LanguageInfo *info = static_cast<LanguageInfo*>(
window->languageList->GetClientData(sel));
config_set_string(GetGlobalConfig(), "General", "Language", info->tag);
} }
BasicSettingsData *CreateBasicGeneralSettings(OBSBasicSettings *window) BasicSettingsData *CreateBasicGeneralSettings(OBSBasicSettings *window)
...@@ -109,7 +120,7 @@ BasicSettingsData *CreateBasicGeneralSettings(OBSBasicSettings *window) ...@@ -109,7 +120,7 @@ BasicSettingsData *CreateBasicGeneralSettings(OBSBasicSettings *window)
BasicSettingsData *data = NULL; BasicSettingsData *data = NULL;
try { try {
data = new GeneralSettings(window); data = new BasicGenData(window);
} catch (const char *error) { } catch (const char *error) {
blog(LOG_ERROR, "CreateBasicGeneralSettings failed: %s", error); blog(LOG_ERROR, "CreateBasicGeneralSettings failed: %s", error);
} }
......
/******************************************************************************
Copyright (C) 2013 by Hugh Bailey <obs.jim@gmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
#include "obs-app.hpp"
#include "settings-basic.hpp"
#include "window-settings-basic.hpp"
#include "wx-wrappers.hpp"
#include <vector>
using namespace std;
class BasicVideoData : public BasicSettingsData {
ConnectorList connections;
void BaseResListChanged(wxCommandEvent &event);
public:
BasicVideoData(OBSBasicSettings *window);
};
BasicVideoData::BasicVideoData(OBSBasicSettings *window)
: BasicSettingsData(window)
{
connections.Add(window->baseResList, wxEVT_COMBOBOX,
wxCommandEventHandler(
BasicVideoData::BaseResListChanged),
NULL, this);
}
void BasicVideoData::BaseResListChanged(wxCommandEvent &event)
{
}
...@@ -30,3 +30,4 @@ public: ...@@ -30,3 +30,4 @@ public:
}; };
BasicSettingsData *CreateBasicGeneralSettings(OBSBasicSettings *window); BasicSettingsData *CreateBasicGeneralSettings(OBSBasicSettings *window);
BasicSettingsData *CreateBasicVideoSettings(OBSBasicSettings *window);
...@@ -31,3 +31,8 @@ void OBSBasicSettings::PageChanged(wxListbookEvent &event) ...@@ -31,3 +31,8 @@ void OBSBasicSettings::PageChanged(wxListbookEvent &event)
void OBSBasicSettings::PageChanging(wxListbookEvent &event) void OBSBasicSettings::PageChanging(wxListbookEvent &event)
{ {
} }
void OBSBasicSettings::OnClose(wxCloseEvent &event)
{
Destroy();
}
...@@ -29,6 +29,7 @@ protected: ...@@ -29,6 +29,7 @@ protected:
virtual void PageChanged(wxListbookEvent &event); virtual void PageChanged(wxListbookEvent &event);
virtual void PageChanging(wxListbookEvent &event); virtual void PageChanging(wxListbookEvent &event);
virtual void OnClose(wxCloseEvent &event);
public: public:
OBSBasicSettings(wxWindow *parent); OBSBasicSettings(wxWindow *parent);
......
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
#include <wx/window.h> #include <wx/window.h>
#include <wx/event.h> #include <wx/event.h>
#include <vector>
struct gs_window; struct gs_window;
gs_window WxToGSWindow(const wxWindow *window); gs_window WxToGSWindow(const wxWindow *window);
...@@ -61,6 +63,16 @@ public: ...@@ -61,6 +63,16 @@ public:
obj->Connect(eventType, func, userData, eventSink); obj->Connect(eventType, func, userData, eventSink);
} }
inline WXConnector(WXConnector &&c)
: obj (c.obj),
eventType (c.eventType),
func (c.func),
userData (c.userData),
eventSink (c.eventSink)
{
c.obj = NULL;
}
inline ~WXConnector() inline ~WXConnector()
{ {
Disconnect(); Disconnect();
...@@ -83,8 +95,22 @@ public: ...@@ -83,8 +95,22 @@ public:
inline void Disconnect() inline void Disconnect()
{ {
if (obj) if (obj) {
obj->Disconnect(eventType, func, userData, eventSink); obj->Disconnect(eventType, func, userData, eventSink);
obj = NULL; obj = NULL;
} }
}
};
class ConnectorList {
std::vector<WXConnector> connectors;
public:
inline void Add(wxEvtHandler *obj, wxEventType type,
wxObjectEventFunction func, wxObject *userData,
wxEvtHandler *eventSink)
{
WXConnector connector(obj, type, func, userData, eventSink);
connectors.push_back(std::move(connector));
}
}; };
...@@ -171,6 +171,7 @@ ...@@ -171,6 +171,7 @@
<ClCompile Include="..\..\..\obs\obs-app.cpp" /> <ClCompile Include="..\..\..\obs\obs-app.cpp" />
<ClCompile Include="..\..\..\obs\platform-windows.cpp" /> <ClCompile Include="..\..\..\obs\platform-windows.cpp" />
<ClCompile Include="..\..\..\obs\settings-basic-general.cpp" /> <ClCompile Include="..\..\..\obs\settings-basic-general.cpp" />
<ClCompile Include="..\..\..\obs\settings-basic-video.cpp" />
<ClCompile Include="..\..\..\obs\window-main-basic.cpp" /> <ClCompile Include="..\..\..\obs\window-main-basic.cpp" />
<ClCompile Include="..\..\..\obs\window-settings-basic.cpp" /> <ClCompile Include="..\..\..\obs\window-settings-basic.cpp" />
<ClCompile Include="..\..\..\obs\wx-subclass.cpp" /> <ClCompile Include="..\..\..\obs\wx-subclass.cpp" />
......
...@@ -42,6 +42,9 @@ ...@@ -42,6 +42,9 @@
<ClCompile Include="..\..\..\obs\settings-basic-general.cpp"> <ClCompile Include="..\..\..\obs\settings-basic-general.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\obs\settings-basic-video.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\..\..\obs\obs-app.hpp"> <ClInclude Include="..\..\..\obs\obs-app.hpp">
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册