Sfoglia il codice sorgente

change obs_scene_destroy to obs_scene_release, add ability to add scenes, fix name dialog sizing

jp9000 12 anni fa
parent
commit
c4af3e2a75

+ 3 - 0
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"

+ 1 - 1
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);

+ 1 - 1
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);

+ 3 - 3
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 );

+ 5 - 5
obs/forms/OBSWindows.fbp

@@ -7342,7 +7342,7 @@
             <property name="pos"></property>
             <property name="size">445,159</property>
             <property name="style">wxDEFAULT_DIALOG_STYLE</property>
-            <property name="subclass"></property>
+            <property name="subclass">DialogSubclass; ../wx-subclass.hpp</property>
             <property name="title">ProjectChooser</property>
             <property name="tooltip"></property>
             <property name="window_extra_style"></property>
@@ -7767,9 +7767,9 @@
             <property name="minimum_size"></property>
             <property name="name">NameDialogBase</property>
             <property name="pos"></property>
-            <property name="size">498,117</property>
+            <property name="size">540,132</property>
             <property name="style">wxDEFAULT_DIALOG_STYLE</property>
-            <property name="subclass"></property>
+            <property name="subclass">DialogSubclass; ../wx-subclass.hpp</property>
             <property name="title">MaximumText</property>
             <property name="tooltip"></property>
             <property name="window_extra_style"></property>
@@ -7817,8 +7817,8 @@
                 <property name="orient">wxVERTICAL</property>
                 <property name="permission">none</property>
                 <object class="sizeritem" expanded="0">
-                    <property name="border">5</property>
-                    <property name="flag">wxALL</property>
+                    <property name="border">10</property>
+                    <property name="flag">wxTOP|wxRIGHT|wxLEFT</property>
                     <property name="proportion">0</property>
                     <object class="wxStaticText" expanded="0">
                         <property name="BottomDockable">1</property>

+ 3 - 3
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();
 	
 };

+ 13 - 0
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)

+ 1 - 1
obs/window-namedialog.hpp

@@ -19,7 +19,7 @@
 
 #include "forms/OBSWindows.h"
 
-#include <vector>
+#include <string>
 
 class NameDialog : public NameDialogBase {
 protected:

+ 1 - 1
test/osx/test.mm

@@ -32,7 +32,7 @@ using SourceContext = OBSUniqueHandle<obs_source,
       DECLARE_DELETER(obs_source_release)>;
 
 using SceneContext = OBSUniqueHandle<obs_scene,
-      DECLARE_DELETER(obs_scene_destroy)>;
+      DECLARE_DELETER(obs_scene_release)>;
 
 #undef DECLARE_DELETER
 

+ 1 - 1
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;}
 };