Explorar o código

added name dialog code, moved 'using namespace std;' out of headers and into source files

jp9000 %!s(int64=11) %!d(string=hai) anos
pai
achega
e5ef03954e

+ 1 - 0
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

+ 1 - 0
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 \

+ 1 - 0
obs/platform-osx.mm

@@ -17,6 +17,7 @@
 
 #include <sstream>
 #include "platform.hpp"
+using namespace std;
 
 #include <unistd.h>
 

+ 1 - 0
obs/platform-windows.cpp

@@ -17,6 +17,7 @@
 
 #include <sstream>
 #include "platform.hpp"
+using namespace std;
 
 #include <util/platform.h>
 

+ 1 - 0
obs/platform-x11.cpp

@@ -17,6 +17,7 @@
 
 #include <sstream>
 #include "platform.hpp"
+using namespace std;
 
 bool GetDataFilePath(const char *data, string &output)
 {

+ 2 - 3
obs/platform.hpp

@@ -21,7 +21,6 @@
 
 #include <string>
 #include <vector>
-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<MonitorInfo> &monitors);
+bool GetDataFilePath(const char *data, std::string &path);
+void GetMonitors(std::vector<MonitorInfo> &monitors);

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

+ 0 - 3
obs/window-basic-main.hpp

@@ -21,9 +21,6 @@
 
 #include <obs.hpp>
 
-#include <vector>
-using namespace std;
-
 class OBSBasic : public OBSBasicBase {
 	void SceneAdded(obs_source_t scene);
 	void SceneRemoved(obs_source_t scene);

+ 1 - 0
obs/window-basic-settings.cpp

@@ -17,6 +17,7 @@
 
 #include <wx/msgdlg.h>
 #include "window-basic-settings.hpp"
+using namespace std;
 
 OBSBasicSettings::OBSBasicSettings(wxWindow *parent)
 	: OBSBasicSettingsBase(parent)

+ 1 - 2
obs/window-basic-settings.hpp

@@ -21,11 +21,10 @@
 #include "settings-basic.hpp"
 
 #include <memory>
-using namespace std;
 
 class OBSBasicSettings : public OBSBasicSettingsBase {
 protected:
-	unique_ptr<BasicSettingsData> settings;
+	std::unique_ptr<BasicSettingsData> settings;
 
 	virtual void PageChanged(wxListbookEvent &event);
 	virtual void PageChanging(wxListbookEvent &event);

+ 48 - 0
obs/window-namedialog.cpp

@@ -0,0 +1,48 @@
+/******************************************************************************
+    Copyright (C) 2013 by Hugh Bailey <[email protected]>
+
+    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/>.
+******************************************************************************/
+
+#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;
+}

+ 38 - 0
obs/window-namedialog.hpp

@@ -0,0 +1,38 @@
+/******************************************************************************
+    Copyright (C) 2013 by Hugh Bailey <[email protected]>
+
+    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/>.
+******************************************************************************/
+
+#pragma once
+
+#include "forms/OBSWindows.h"
+
+#include <vector>
+
+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);
+};

+ 1 - 14
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)) {

+ 2 - 0
vs/2013/OBS/OBS.vcxproj

@@ -179,6 +179,7 @@
     <ClCompile Include="..\..\..\obs\settings-basic.cpp" />
     <ClCompile Include="..\..\..\obs\window-basic-main.cpp" />
     <ClCompile Include="..\..\..\obs\window-basic-settings.cpp" />
+    <ClCompile Include="..\..\..\obs\window-namedialog.cpp" />
     <ClCompile Include="..\..\..\obs\wx-subclass.cpp" />
     <ClCompile Include="..\..\..\obs\wx-wrappers.cpp" />
   </ItemGroup>
@@ -190,6 +191,7 @@
     <ClInclude Include="..\..\..\obs\settings.hpp" />
     <ClInclude Include="..\..\..\obs\window-basic-main.hpp" />
     <ClInclude Include="..\..\..\obs\window-basic-settings.hpp" />
+    <ClInclude Include="..\..\..\obs\window-namedialog.hpp" />
     <ClInclude Include="..\..\..\obs\wx-subclass.hpp" />
     <ClInclude Include="..\..\..\obs\wx-wrappers.hpp" />
   </ItemGroup>

+ 6 - 0
vs/2013/OBS/OBS.vcxproj.filters

@@ -48,6 +48,9 @@
     <ClCompile Include="..\..\..\obs\window-basic-settings.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\..\obs\window-namedialog.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\..\obs\obs-app.hpp">
@@ -77,5 +80,8 @@
     <ClInclude Include="..\..\..\obs\window-basic-settings.hpp">
       <Filter>Header Files</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\..\obs\window-namedialog.hpp">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
 </Project>