From e5ef03954edde71e283597b820f0dd7371e91ddc Mon Sep 17 00:00:00 2001 From: jp9000 Date: Sun, 29 Dec 2013 04:40:53 -0700 Subject: [PATCH] added name dialog code, moved 'using namespace std;' out of headers and into source files --- obs/CMakeLists.txt | 1 + obs/makefile.am | 1 + obs/platform-osx.mm | 1 + obs/platform-windows.cpp | 1 + obs/platform-x11.cpp | 1 + obs/platform.hpp | 5 ++-- obs/settings-basic-general.cpp | 1 + obs/window-basic-main.hpp | 3 --- obs/window-basic-settings.cpp | 1 + obs/window-basic-settings.hpp | 3 +-- obs/window-namedialog.cpp | 48 +++++++++++++++++++++++++++++++++ obs/window-namedialog.hpp | 38 ++++++++++++++++++++++++++ test/win/test.cpp | 15 +---------- vs/2013/OBS/OBS.vcxproj | 2 ++ vs/2013/OBS/OBS.vcxproj.filters | 6 +++++ 15 files changed, 105 insertions(+), 22 deletions(-) create mode 100644 obs/window-namedialog.cpp create mode 100644 obs/window-namedialog.hpp diff --git a/obs/CMakeLists.txt b/obs/CMakeLists.txt index e0039f93d..28c49858f 100644 --- a/obs/CMakeLists.txt +++ b/obs/CMakeLists.txt @@ -43,6 +43,7 @@ endif() add_executable(obs window-basic-main.cpp window-basic-settings.cpp + window-namedialog.cpp settings-basic.cpp settings-basic-general.cpp settings-basic-video.cpp diff --git a/obs/makefile.am b/obs/makefile.am index dbbc2c1ad..a18ab6c5f 100644 --- a/obs/makefile.am +++ b/obs/makefile.am @@ -15,6 +15,7 @@ obs_PROGRAMS = obs obs_LDADD = $(top_srcdir)/libobs/libobs.la obs_SOURCES = window-basic-main.cpp \ window-basic-settings.cpp \ + window-namedialog.cpp \ settings-basic.cpp \ settings-basic-general.cpp \ settings-basic-video.cpp \ diff --git a/obs/platform-osx.mm b/obs/platform-osx.mm index deb8f5f85..f634b49fe 100644 --- a/obs/platform-osx.mm +++ b/obs/platform-osx.mm @@ -17,6 +17,7 @@ #include #include "platform.hpp" +using namespace std; #include diff --git a/obs/platform-windows.cpp b/obs/platform-windows.cpp index 9e1dfc122..d4d17bd88 100644 --- a/obs/platform-windows.cpp +++ b/obs/platform-windows.cpp @@ -17,6 +17,7 @@ #include #include "platform.hpp" +using namespace std; #include diff --git a/obs/platform-x11.cpp b/obs/platform-x11.cpp index 20bbc94e4..e7312b41d 100644 --- a/obs/platform-x11.cpp +++ b/obs/platform-x11.cpp @@ -17,6 +17,7 @@ #include #include "platform.hpp" +using namespace std; bool GetDataFilePath(const char *data, string &output) { diff --git a/obs/platform.hpp b/obs/platform.hpp index 0ccec0b26..f479b5272 100644 --- a/obs/platform.hpp +++ b/obs/platform.hpp @@ -21,7 +21,6 @@ #include #include -using namespace std; struct MonitorInfo { int32_t x, y; @@ -32,5 +31,5 @@ struct MonitorInfo { }; /* Gets the path of obs-studio specific data files (such as locale) */ -bool GetDataFilePath(const char *data, string &path); -void GetMonitors(vector &monitors); +bool GetDataFilePath(const char *data, std::string &path); +void GetMonitors(std::vector &monitors); diff --git a/obs/settings-basic-general.cpp b/obs/settings-basic-general.cpp index 8dbcb024a..0fade9bc2 100644 --- a/obs/settings-basic-general.cpp +++ b/obs/settings-basic-general.cpp @@ -22,6 +22,7 @@ #include "window-basic-settings.hpp" #include "wx-wrappers.hpp" #include "platform.hpp" +using namespace std; class BasicGenData : public BasicSettingsData { ConfigFile localeIni; diff --git a/obs/window-basic-main.hpp b/obs/window-basic-main.hpp index 155f3c58b..d0d7a20ef 100644 --- a/obs/window-basic-main.hpp +++ b/obs/window-basic-main.hpp @@ -21,9 +21,6 @@ #include -#include -using namespace std; - class OBSBasic : public OBSBasicBase { void SceneAdded(obs_source_t scene); void SceneRemoved(obs_source_t scene); diff --git a/obs/window-basic-settings.cpp b/obs/window-basic-settings.cpp index f3dc5953c..053327d22 100644 --- a/obs/window-basic-settings.cpp +++ b/obs/window-basic-settings.cpp @@ -17,6 +17,7 @@ #include #include "window-basic-settings.hpp" +using namespace std; OBSBasicSettings::OBSBasicSettings(wxWindow *parent) : OBSBasicSettingsBase(parent) diff --git a/obs/window-basic-settings.hpp b/obs/window-basic-settings.hpp index d523473d5..9fcca8b29 100644 --- a/obs/window-basic-settings.hpp +++ b/obs/window-basic-settings.hpp @@ -21,11 +21,10 @@ #include "settings-basic.hpp" #include -using namespace std; class OBSBasicSettings : public OBSBasicSettingsBase { protected: - unique_ptr settings; + std::unique_ptr settings; virtual void PageChanged(wxListbookEvent &event); virtual void PageChanging(wxListbookEvent &event); diff --git a/obs/window-namedialog.cpp b/obs/window-namedialog.cpp new file mode 100644 index 000000000..8a47d700f --- /dev/null +++ b/obs/window-namedialog.cpp @@ -0,0 +1,48 @@ +/****************************************************************************** + Copyright (C) 2013 by Hugh Bailey + + 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 . +******************************************************************************/ + +#pragma once + +#include "window-namedialog.hpp" +using namespace std; + +void NameDialog::OnClose(wxCommandEvent &event) +{ + EndModal(wxID_CANCEL); +} + +void NameDialog::OKPressed(wxCommandEvent &event) +{ + EndModal(wxID_OK); +} + +void NameDialog::CancelPressed(wxCommandEvent &event) +{ + EndModal(wxID_CANCEL); +} + +int NameDialog::AskForName(wxWindow *parent, const char *title, + const char *text, string &str) +{ + NameDialog *dialog = new NameDialog(parent); + dialog->SetTitle(wxString(title, wxConvUTF8)); + dialog->questionText->SetLabel(wxString(text, wxConvUTF8)); + + int ret = dialog->ShowModal(); + str = dialog->nameEdit->GetValue().ToUTF8().data(); + return ret; +} diff --git a/obs/window-namedialog.hpp b/obs/window-namedialog.hpp new file mode 100644 index 000000000..335ea59c0 --- /dev/null +++ b/obs/window-namedialog.hpp @@ -0,0 +1,38 @@ +/****************************************************************************** + Copyright (C) 2013 by Hugh Bailey + + 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 . +******************************************************************************/ + +#pragma once + +#include "forms/OBSWindows.h" + +#include + +class NameDialog : public NameDialogBase { +protected: + virtual void OnClose(wxCommandEvent &event); + virtual void OKPressed(wxCommandEvent &event); + virtual void CancelPressed(wxCommandEvent &event); + +public: + inline NameDialog(wxWindow *parent) + : NameDialogBase(parent) + { + } + + static int AskForName(wxWindow *parent, const char *title, + const char *text, std::string &str); +}; diff --git a/test/win/test.cpp b/test/win/test.cpp index a263002ae..cdc6a2fdc 100644 --- a/test/win/test.cpp +++ b/test/win/test.cpp @@ -92,21 +92,8 @@ static void CreateOBS(HWND hwnd) static void AddTestItems(obs_scene_t scene, obs_source_t source) { obs_sceneitem_t item = NULL; - struct vec2 v2; item = obs_scene_add(scene, source); - vec2_set(&v2, 100.0f, 200.0f); - obs_sceneitem_setpos(item, &v2); - obs_sceneitem_setrot(item, 10.0f); - vec2_set(&v2, 20.0f, 2.0f); - obs_sceneitem_setscale(item, &v2); - - item = obs_scene_add(scene, source); - vec2_set(&v2, 200.0f, 100.0f); - obs_sceneitem_setpos(item, &v2); - obs_sceneitem_setrot(item, -45.0f); - vec2_set(&v2, 5.0f, 7.0f); - obs_sceneitem_setscale(item, &v2); } static HWND CreateTestWindow(HINSTANCE instance) @@ -175,7 +162,7 @@ int WINAPI WinMain(HINSTANCE instance, HINSTANCE prevInstance, LPSTR cmdLine, /* ------------------------------------------------------ */ /* set the scene as the primary draw source and go */ - obs_set_output_source(0, obs_scene_getsource(scene)); + obs_set_output_source(0, source); MSG msg; while (GetMessage(&msg, NULL, 0, 0)) { diff --git a/vs/2013/OBS/OBS.vcxproj b/vs/2013/OBS/OBS.vcxproj index bfde48b20..80c0219e0 100644 --- a/vs/2013/OBS/OBS.vcxproj +++ b/vs/2013/OBS/OBS.vcxproj @@ -179,6 +179,7 @@ + @@ -190,6 +191,7 @@ + diff --git a/vs/2013/OBS/OBS.vcxproj.filters b/vs/2013/OBS/OBS.vcxproj.filters index 4a7e83f2e..970e90843 100644 --- a/vs/2013/OBS/OBS.vcxproj.filters +++ b/vs/2013/OBS/OBS.vcxproj.filters @@ -48,6 +48,9 @@ Source Files + + Source Files + @@ -77,5 +80,8 @@ Header Files + + Header Files + \ No newline at end of file