From 717a2538f47963858fccb955d831a841e0fbc2b7 Mon Sep 17 00:00:00 2001 From: jp9000 Date: Sat, 4 Jan 2014 18:53:02 -0700 Subject: [PATCH] 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. --- obs/window-basic-main.cpp | 16 +++++++++++++--- obs/window-basic-main.hpp | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/obs/window-basic-main.cpp b/obs/window-basic-main.cpp index 09da6049a..216a6ecec 100644 --- a/obs/window-basic-main.cpp +++ b/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) diff --git a/obs/window-basic-main.hpp b/obs/window-basic-main.hpp index ca30694f1..495cac282 100644 --- a/obs/window-basic-main.hpp +++ b/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();