mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-09-19 20:32:15 +02:00
add move constructor to wx connector class, add simple connector list class, add initial video settings class, update build files
This commit is contained in:
parent
02c32f9c5e
commit
7ba497fe61
@ -25,6 +25,7 @@ Settings="Settings"
|
||||
|
||||
Settings.General="General"
|
||||
Settings.General.Language="Language:"
|
||||
Settings.General.LanguageChanged="The program must be restarted in order to change the language"
|
||||
|
||||
Settings.Outputs="Outputs"
|
||||
|
||||
|
@ -44,6 +44,7 @@ add_executable(obs
|
||||
window-main-basic.cpp
|
||||
window-settings-basic.cpp
|
||||
settings-basic-general.cpp
|
||||
settings-basic-video.cpp
|
||||
wx-subclass.cpp
|
||||
wx-wrappers.cpp
|
||||
obs-app.cpp
|
||||
|
@ -15,6 +15,7 @@ obs_LDADD = $(top_srcdir)/libobs/libobs.la
|
||||
obs_SOURCES = window-main-basic.cpp \
|
||||
window-settings-basic.cpp \
|
||||
settings-basic-general.cpp \
|
||||
settings-basic-video.cpp \
|
||||
obs-app.cpp \
|
||||
wx-subclass.cpp \
|
||||
wx-wrappers.cpp \
|
||||
|
@ -54,3 +54,4 @@ wxDECLARE_APP(OBSApp);
|
||||
inline config_t GetGlobalConfig() {return wxGetApp().GlobalConfig();}
|
||||
|
||||
#define Str(lookupVal) wxGetApp().GetString(lookupVal)
|
||||
#define WXStr(lookupVal) wxString(Str(lookupVal), wxConvUTF8)
|
||||
|
@ -15,15 +15,13 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
******************************************************************************/
|
||||
|
||||
#include <wx/event.h>
|
||||
|
||||
#include "obs-app.hpp"
|
||||
#include "settings-basic.hpp"
|
||||
#include "window-settings-basic.hpp"
|
||||
#include "wx-wrappers.hpp"
|
||||
#include "platform.hpp"
|
||||
|
||||
class GeneralSettings : public BasicSettingsData {
|
||||
class BasicGenData : public BasicSettingsData {
|
||||
ConfigFile localeIni;
|
||||
WXConnector languageBoxConnector;
|
||||
|
||||
@ -33,7 +31,7 @@ class GeneralSettings : public BasicSettingsData {
|
||||
void FillLanguageList(const char *currentLang);
|
||||
|
||||
public:
|
||||
GeneralSettings(OBSBasicSettings *window);
|
||||
BasicGenData(OBSBasicSettings *window);
|
||||
|
||||
virtual void Apply();
|
||||
};
|
||||
@ -55,14 +53,14 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
int GeneralSettings::AddLanguage(const char *tag)
|
||||
int BasicGenData::AddLanguage(const char *tag)
|
||||
{
|
||||
LanguageInfo *info = new LanguageInfo(localeIni, tag);
|
||||
return window->languageList->Append(wxString(info->name, wxConvUTF8),
|
||||
info);
|
||||
}
|
||||
|
||||
void GeneralSettings::FillLanguageList(const char *currentLang)
|
||||
void BasicGenData::FillLanguageList(const char *currentLang)
|
||||
{
|
||||
size_t numSections = config_num_sections(localeIni);
|
||||
for (size_t i = 0; i < numSections; i++) {
|
||||
@ -74,7 +72,7 @@ void GeneralSettings::FillLanguageList(const char *currentLang)
|
||||
}
|
||||
}
|
||||
|
||||
GeneralSettings::GeneralSettings(OBSBasicSettings *window)
|
||||
BasicGenData::BasicGenData(OBSBasicSettings *window)
|
||||
: BasicSettingsData (window)
|
||||
{
|
||||
string path;
|
||||
@ -90,18 +88,31 @@ GeneralSettings::GeneralSettings(OBSBasicSettings *window)
|
||||
languageBoxConnector.Connect(
|
||||
window->languageList,
|
||||
wxEVT_COMBOBOX,
|
||||
wxCommandEventHandler(GeneralSettings::LanguageChanged),
|
||||
wxCommandEventHandler(BasicGenData::LanguageChanged),
|
||||
NULL,
|
||||
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)
|
||||
@ -109,7 +120,7 @@ BasicSettingsData *CreateBasicGeneralSettings(OBSBasicSettings *window)
|
||||
BasicSettingsData *data = NULL;
|
||||
|
||||
try {
|
||||
data = new GeneralSettings(window);
|
||||
data = new BasicGenData(window);
|
||||
} catch (const char *error) {
|
||||
blog(LOG_ERROR, "CreateBasicGeneralSettings failed: %s", error);
|
||||
}
|
||||
|
46
obs/settings-basic-video.cpp
Normal file
46
obs/settings-basic-video.cpp
Normal file
@ -0,0 +1,46 @@
|
||||
/******************************************************************************
|
||||
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:
|
||||
};
|
||||
|
||||
BasicSettingsData *CreateBasicGeneralSettings(OBSBasicSettings *window);
|
||||
BasicSettingsData *CreateBasicVideoSettings(OBSBasicSettings *window);
|
||||
|
@ -31,3 +31,8 @@ void OBSBasicSettings::PageChanged(wxListbookEvent &event)
|
||||
void OBSBasicSettings::PageChanging(wxListbookEvent &event)
|
||||
{
|
||||
}
|
||||
|
||||
void OBSBasicSettings::OnClose(wxCloseEvent &event)
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ protected:
|
||||
|
||||
virtual void PageChanged(wxListbookEvent &event);
|
||||
virtual void PageChanging(wxListbookEvent &event);
|
||||
virtual void OnClose(wxCloseEvent &event);
|
||||
|
||||
public:
|
||||
OBSBasicSettings(wxWindow *parent);
|
||||
|
@ -20,6 +20,8 @@
|
||||
#include <wx/window.h>
|
||||
#include <wx/event.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
struct gs_window;
|
||||
|
||||
gs_window WxToGSWindow(const wxWindow *window);
|
||||
@ -61,6 +63,16 @@ public:
|
||||
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()
|
||||
{
|
||||
Disconnect();
|
||||
@ -83,8 +95,22 @@ public:
|
||||
|
||||
inline void Disconnect()
|
||||
{
|
||||
if (obj)
|
||||
if (obj) {
|
||||
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 @@
|
||||
<ClCompile Include="..\..\..\obs\obs-app.cpp" />
|
||||
<ClCompile Include="..\..\..\obs\platform-windows.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-settings-basic.cpp" />
|
||||
<ClCompile Include="..\..\..\obs\wx-subclass.cpp" />
|
||||
|
@ -42,6 +42,9 @@
|
||||
<ClCompile Include="..\..\..\obs\settings-basic-general.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\obs\settings-basic-video.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\..\obs\obs-app.hpp">
|
||||
|
Loading…
Reference in New Issue
Block a user