Browse Source

Implement source removal via GUI

 - When the remove source tool icon is clicked, it will now remove the
   source from the scene.

 - Fixed a bug where the scene item removal callback would add the scene
   item to the list instead of removing it.

 - Changed AddSourcePopup to AddSourcePopupMenu.  Name actually confused
   me once despite being the writer, so it was clearly a bad name.
jp9000 12 years ago
parent
commit
717a2538f4
2 changed files with 14 additions and 4 deletions
  1. 13 3
      obs/window-basic-main.cpp
  2. 1 1
      obs/window-basic-main.hpp

+ 13 - 3
obs/window-basic-main.cpp

@@ -131,7 +131,7 @@ void OBSBasic::SceneItemRemoved(void *data, calldata_t params)
 	obs_sceneitem_t item = (obs_sceneitem_t)calldata_ptr(params, "item");
 
 	if (window->GetCurrentScene() == scene)
-		window->AddSceneItem(item);
+		window->RemoveSceneItem(item);
 }
 
 void OBSBasic::SourceAdded(void *data, calldata_t params)
@@ -408,7 +408,7 @@ void OBSBasic::AddSource(obs_scene_t scene, const char *id)
 	}
 }
 
-void OBSBasic::AddSourcePopup()
+void OBSBasic::AddSourcePopupMenu()
 {
 	int sceneSel = scenes->GetSelection();
 	size_t idx = 0;
@@ -443,11 +443,21 @@ void OBSBasic::AddSourcePopup()
 
 void OBSBasic::sourceAddClicked(wxCommandEvent &event)
 {
-	AddSourcePopup();
+	AddSourcePopupMenu();
 }
 
 void OBSBasic::sourceRemoveClicked(wxCommandEvent &event)
 {
+	int sel = sources->GetSelection();
+	if (sel == wxNOT_FOUND)
+		return;
+
+	obs_sceneitem_t item = (obs_sceneitem_t)sources->GetClientData(sel);
+	obs_source_t source = obs_sceneitem_getsource(item);
+	int ref = obs_sceneitem_destroy(item);
+
+	if (ref == 1)
+		obs_source_remove(source);
 }
 
 void OBSBasic::sourcePropertiesClicked(wxCommandEvent &event)

+ 1 - 1
obs/window-basic-main.hpp

@@ -40,7 +40,7 @@ class OBSBasic : public OBSBasicBase {
 	void ResizePreview(uint32_t cx, uint32_t cy);
 
 	void AddSource(obs_scene_t scene, const char *id);
-	void AddSourcePopup();
+	void AddSourcePopupMenu();
 
 	bool InitGraphics();