From c4af3e2a7514e3501a9262914a5fa775c4d99544 Mon Sep 17 00:00:00 2001 From: jp9000 Date: Sun, 29 Dec 2013 08:54:06 -0700 Subject: [PATCH] change obs_scene_destroy to obs_scene_release, add ability to add scenes, fix name dialog sizing --- build/data/obs-studio/locale/en.txt | 3 +++ libobs/obs-scene.c | 2 +- libobs/obs.h | 2 +- obs/forms/OBSWindows.cpp | 6 +++--- obs/forms/OBSWindows.fbp | 10 +++++----- obs/forms/OBSWindows.h | 6 +++--- obs/window-basic-main.cpp | 13 +++++++++++++ obs/window-namedialog.hpp | 2 +- test/osx/test.mm | 2 +- test/win/test.cpp | 2 +- 10 files changed, 32 insertions(+), 16 deletions(-) diff --git a/build/data/obs-studio/locale/en.txt b/build/data/obs-studio/locale/en.txt index 3a55d754d..7d09194c5 100644 --- a/build/data/obs-studio/locale/en.txt +++ b/build/data/obs-studio/locale/en.txt @@ -9,6 +9,9 @@ MainMenu.File.New="New" MainMenu.File.Open="Open" MainMenu.FIle.Save="Save" +MainWindow.AddSceneDlg.Title="Add Scene" +MainWindow.AddSceneDlg.Text="Please enter the name of the scene" + MainWindow.Exit="Exit" MainWindow.Lock="Lock Preview" MainWindow.Preview="Enable Preview" diff --git a/libobs/obs-scene.c b/libobs/obs-scene.c index 7f0633f0c..b3b2b9e60 100644 --- a/libobs/obs-scene.c +++ b/libobs/obs-scene.c @@ -119,7 +119,7 @@ obs_scene_t obs_scene_create(const char *name) return scene; } -void obs_scene_destroy(obs_scene_t scene) +void obs_scene_release(obs_scene_t scene) { if (scene) obs_source_release(scene->source); diff --git a/libobs/obs.h b/libobs/obs.h index 92a3ab630..8262c36ab 100644 --- a/libobs/obs.h +++ b/libobs/obs.h @@ -445,7 +445,7 @@ EXPORT void obs_source_process_filter(obs_source_t filter, * display oriantations. Scenes can also be used like any other source. */ EXPORT obs_scene_t obs_scene_create(const char *name); -EXPORT void obs_scene_destroy(obs_scene_t scene); +EXPORT void obs_scene_release(obs_scene_t scene); /** Gets the scene's source context */ EXPORT obs_source_t obs_scene_getsource(obs_scene_t scene); diff --git a/obs/forms/OBSWindows.cpp b/obs/forms/OBSWindows.cpp index 360f53f3a..7b2f894b6 100644 --- a/obs/forms/OBSWindows.cpp +++ b/obs/forms/OBSWindows.cpp @@ -770,7 +770,7 @@ OBSBasicSettingsBase::~OBSBasicSettingsBase() } -ProjectChooserBase::ProjectChooserBase( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style ) +ProjectChooserBase::ProjectChooserBase( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DialogSubclass( parent, id, title, pos, size, style ) { this->SetSizeHints( wxDefaultSize, wxDefaultSize ); @@ -819,7 +819,7 @@ ProjectChooserBase::~ProjectChooserBase() } -NameDialogBase::NameDialogBase( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style ) +NameDialogBase::NameDialogBase( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DialogSubclass( parent, id, title, pos, size, style ) { this->SetSizeHints( wxDefaultSize, wxDefaultSize ); @@ -828,7 +828,7 @@ NameDialogBase::NameDialogBase( wxWindow* parent, wxWindowID id, const wxString& questionText = new wxStaticText( this, wxID_ANY, _("Please enter a name (or is it text you want to enter?):"), wxDefaultPosition, wxDefaultSize, 0 ); questionText->Wrap( -1 ); - bSizer44->Add( questionText, 0, wxALL, 5 ); + bSizer44->Add( questionText, 0, wxTOP|wxRIGHT|wxLEFT, 10 ); wxBoxSizer* bSizer46; bSizer46 = new wxBoxSizer( wxHORIZONTAL ); diff --git a/obs/forms/OBSWindows.fbp b/obs/forms/OBSWindows.fbp index 495552bfa..9a86aa4dd 100644 --- a/obs/forms/OBSWindows.fbp +++ b/obs/forms/OBSWindows.fbp @@ -7342,7 +7342,7 @@ 445,159 wxDEFAULT_DIALOG_STYLE - + DialogSubclass; ../wx-subclass.hpp ProjectChooser @@ -7767,9 +7767,9 @@ NameDialogBase - 498,117 + 540,132 wxDEFAULT_DIALOG_STYLE - + DialogSubclass; ../wx-subclass.hpp MaximumText @@ -7817,8 +7817,8 @@ wxVERTICAL none - 5 - wxALL + 10 + wxTOP|wxRIGHT|wxLEFT 0 1 diff --git a/obs/forms/OBSWindows.h b/obs/forms/OBSWindows.h index 5a925eaf6..3f254a71f 100644 --- a/obs/forms/OBSWindows.h +++ b/obs/forms/OBSWindows.h @@ -272,7 +272,7 @@ class OBSBasicSettingsBase : public DialogSubclass /////////////////////////////////////////////////////////////////////////////// /// Class ProjectChooserBase /////////////////////////////////////////////////////////////////////////////// -class ProjectChooserBase : public wxDialog +class ProjectChooserBase : public DialogSubclass { private: @@ -299,7 +299,7 @@ class ProjectChooserBase : public wxDialog /////////////////////////////////////////////////////////////////////////////// /// Class NameDialogBase /////////////////////////////////////////////////////////////////////////////// -class NameDialogBase : public wxDialog +class NameDialogBase : public DialogSubclass { private: @@ -317,7 +317,7 @@ class NameDialogBase : public wxDialog public: - NameDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("MaximumText"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 498,117 ), long style = wxDEFAULT_DIALOG_STYLE ); + NameDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("MaximumText"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 540,132 ), long style = wxDEFAULT_DIALOG_STYLE ); ~NameDialogBase(); }; diff --git a/obs/window-basic-main.cpp b/obs/window-basic-main.cpp index 5e6f7aec1..ff396b4e1 100644 --- a/obs/window-basic-main.cpp +++ b/obs/window-basic-main.cpp @@ -21,6 +21,8 @@ #include "wx-wrappers.hpp" #include "window-basic-settings.hpp" #include "window-basic-main.hpp" +#include "window-namedialog.hpp" +using namespace std; void OBSBasic::SceneAdded(obs_source_t source) { @@ -182,6 +184,17 @@ void OBSBasic::scenesRDown(wxMouseEvent &event) void OBSBasic::sceneAddClicked(wxCommandEvent &event) { + string name; + int ret = NameDialog::AskForName(this, + Str("MainWindow.AddSceneDlg.Title"), + Str("MainWindow.AddSceneDlg.Text"), + name); + + if (ret == wxID_OK) { + obs_scene_t scene = obs_scene_create(name.c_str()); + obs_add_source(obs_scene_getsource(scene)); + obs_scene_release(scene); + } } void OBSBasic::sceneRemoveClicked(wxCommandEvent &event) diff --git a/obs/window-namedialog.hpp b/obs/window-namedialog.hpp index 335ea59c0..03c953c1e 100644 --- a/obs/window-namedialog.hpp +++ b/obs/window-namedialog.hpp @@ -19,7 +19,7 @@ #include "forms/OBSWindows.h" -#include +#include class NameDialog : public NameDialogBase { protected: diff --git a/test/osx/test.mm b/test/osx/test.mm index a71e46194..7fe6bdad3 100644 --- a/test/osx/test.mm +++ b/test/osx/test.mm @@ -32,7 +32,7 @@ using SourceContext = OBSUniqueHandle; using SceneContext = OBSUniqueHandle; + DECLARE_DELETER(obs_scene_release)>; #undef DECLARE_DELETER diff --git a/test/win/test.cpp b/test/win/test.cpp index cdc6a2fdc..1daf76f47 100644 --- a/test/win/test.cpp +++ b/test/win/test.cpp @@ -29,7 +29,7 @@ class SceneContext { public: inline SceneContext(obs_scene_t scene) : scene(scene) {} - inline ~SceneContext() {obs_scene_destroy(scene);} + inline ~SceneContext() {obs_scene_release(scene);} inline operator obs_scene_t() {return scene;} };