From d87a7e896bbe980023b79dee8b4486cdfc91ef51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Lepin?= Date: Fri, 27 Nov 2020 16:46:33 +0100 Subject: [PATCH 1/7] events(SceneCollectionChanged): add new scene collection name --- src/WSEvents.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/WSEvents.cpp b/src/WSEvents.cpp index 56d24c8a..c2e9d0bc 100644 --- a/src/WSEvents.cpp +++ b/src/WSEvents.cpp @@ -479,13 +479,17 @@ void WSEvents::OnSceneListChange() { /** * Triggered when switching to another scene collection or when renaming the current scene collection. * + * @return {String} `sceneCollection` Name of the new current scene collection. + * * @api events * @name SceneCollectionChanged * @category scenes * @since 4.0.0 */ void WSEvents::OnSceneCollectionChange() { - broadcastUpdate("SceneCollectionChanged"); + OBSDataAutoRelease fields = obs_data_create(); + obs_data_set_string(fields, "sceneCollection", obs_frontend_get_current_scene_collection()); + broadcastUpdate("SceneCollectionChanged", fields); OnTransitionListChange(); OnTransitionChange(); From fe52cd8db15cfa95c1a67999b505480822b46b99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Lepin?= Date: Fri, 27 Nov 2020 16:47:10 +0100 Subject: [PATCH 2/7] events(ProfileChanged): add new profile name --- src/WSEvents.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/WSEvents.cpp b/src/WSEvents.cpp index c2e9d0bc..d04b2880 100644 --- a/src/WSEvents.cpp +++ b/src/WSEvents.cpp @@ -546,13 +546,17 @@ void WSEvents::OnTransitionListChange() { /** * Triggered when switching to another profile or when renaming the current profile. * + * @return {String} `profile` Name of the new current profile. + * * @api events * @name ProfileChanged * @category profiles * @since 4.0.0 */ void WSEvents::OnProfileChange() { - broadcastUpdate("ProfileChanged"); + OBSDataAutoRelease fields = obs_data_create(); + obs_data_set_string(fields, "profile", obs_frontend_get_current_profile()); + broadcastUpdate("ProfileChanged", fields); } /** From 0dc8e070ff07b691d8d0b0fa45d57901bae85bfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Lepin?= Date: Fri, 27 Nov 2020 16:57:47 +0100 Subject: [PATCH 3/7] events(SceneCollectionListChanged): add scene collections list property --- src/WSEvents.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/WSEvents.cpp b/src/WSEvents.cpp index d04b2880..705a3184 100644 --- a/src/WSEvents.cpp +++ b/src/WSEvents.cpp @@ -501,13 +501,23 @@ void WSEvents::OnSceneCollectionChange() { /** * Triggered when a scene collection is created, added, renamed, or removed. * + * @return {Array} `sceneCollections` Scene collections list. + * @return {String} `sceneCollections.*.name` Scene collection name. + * * @api events * @name SceneCollectionListChanged * @category scenes * @since 4.0.0 */ void WSEvents::OnSceneCollectionListChange() { - broadcastUpdate("SceneCollectionListChanged"); + char** sceneCollections = obs_frontend_get_scene_collections(); + OBSDataArrayAutoRelease sceneCollectionsList = + Utils::StringListToArray(sceneCollections, "name"); + bfree(sceneCollections); + + OBSDataAutoRelease fields = obs_data_create(); + obs_data_set_array(fields, "sceneCollections", sceneCollectionsList); + broadcastUpdate("SceneCollectionListChanged", fields); } /** @@ -568,7 +578,9 @@ void WSEvents::OnProfileChange() { * @since 4.0.0 */ void WSEvents::OnProfileListChange() { - broadcastUpdate("ProfileListChanged"); + OBSDataAutoRelease fields = obs_data_create(); + // TODO provide new profile list + broadcastUpdate("ProfileListChanged", fields); } /** From 542761e411871e6f86e69ea42d21234f71a1b5e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Lepin?= Date: Fri, 27 Nov 2020 16:58:34 +0100 Subject: [PATCH 4/7] events(ProfileListChanged): add profile list property --- src/WSEvents.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/WSEvents.cpp b/src/WSEvents.cpp index 705a3184..351b30ad 100644 --- a/src/WSEvents.cpp +++ b/src/WSEvents.cpp @@ -572,14 +572,21 @@ void WSEvents::OnProfileChange() { /** * Triggered when a profile is created, added, renamed, or removed. * + * @return {Array} `profiles` Profiles list. + * @return {String} `profiles.*.name` Profile name. + * * @api events * @name ProfileListChanged * @category profiles * @since 4.0.0 */ void WSEvents::OnProfileListChange() { + char** profiles = obs_frontend_get_profiles(); + OBSDataArrayAutoRelease profilesList = Utils::StringListToArray(profiles, "name"); + bfree(profiles); + OBSDataAutoRelease fields = obs_data_create(); - // TODO provide new profile list + obs_data_set_array(fields, "profiles", profilesList); broadcastUpdate("ProfileListChanged", fields); } From 0cdea68567d11bb07506a5b966a96823013f665a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Lepin?= Date: Fri, 27 Nov 2020 17:07:28 +0100 Subject: [PATCH 5/7] events(ScenesChanged): provide scenes list property --- src/WSEvents.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/WSEvents.cpp b/src/WSEvents.cpp index 351b30ad..ad765e26 100644 --- a/src/WSEvents.cpp +++ b/src/WSEvents.cpp @@ -467,13 +467,19 @@ void WSEvents::OnSceneChange() { * * Note: This event is not fired when the scenes are reordered. * + * @return {Array} `scenes` Scenes list. + * * @api events * @name ScenesChanged * @category scenes * @since 0.3 */ void WSEvents::OnSceneListChange() { - broadcastUpdate("ScenesChanged"); + OBSDataArrayAutoRelease scenes = Utils::GetScenes(); + + OBSDataAutoRelease fields = obs_data_create(); + obs_data_set_array(fields, "scenes", scenes); + broadcastUpdate("ScenesChanged", fields); } /** From 14409dec4f933748d4aa9177110c6fd979df8777 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Lepin?= Date: Fri, 27 Nov 2020 17:09:07 +0100 Subject: [PATCH 6/7] events(TransitionListChanged): provide transitions list property --- src/WSEvents.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/WSEvents.cpp b/src/WSEvents.cpp index ad765e26..af94214e 100644 --- a/src/WSEvents.cpp +++ b/src/WSEvents.cpp @@ -550,13 +550,30 @@ void WSEvents::OnTransitionChange() { * The list of available transitions has been modified. * Transitions have been added, removed, or renamed. * + * @return {Array} `transitions` Transitions list. + * * @api events * @name TransitionListChanged * @category transitions * @since 4.0.0 */ void WSEvents::OnTransitionListChange() { - broadcastUpdate("TransitionListChanged"); + obs_frontend_source_list transitionList = {}; + obs_frontend_get_transitions(&transitionList); + + OBSDataArrayAutoRelease transitions = obs_data_array_create(); + for (size_t i = 0; i < transitionList.sources.num; i++) { + OBSSource transition = transitionList.sources.array[i]; + + OBSDataAutoRelease obj = obs_data_create(); + obs_data_set_string(obj, "name", obs_source_get_name(transition)); + obs_data_array_push_back(transitions, obj); + } + obs_frontend_source_list_free(&transitionList); + + OBSDataAutoRelease fields = obs_data_create(); + obs_data_set_array(fields, "transitions", transitions); + broadcastUpdate("TransitionListChanged", fields); } /** From ae9ea8510c8439f3188e8f90f51a34e4876ecb57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Lepin?= Date: Fri, 27 Nov 2020 17:10:27 +0100 Subject: [PATCH 7/7] events: fix docs --- src/WSEvents.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/WSEvents.cpp b/src/WSEvents.cpp index af94214e..ce27798d 100644 --- a/src/WSEvents.cpp +++ b/src/WSEvents.cpp @@ -507,7 +507,7 @@ void WSEvents::OnSceneCollectionChange() { /** * Triggered when a scene collection is created, added, renamed, or removed. * - * @return {Array} `sceneCollections` Scene collections list. + * @return {Array} `sceneCollections` Scene collections list. * @return {String} `sceneCollections.*.name` Scene collection name. * * @api events @@ -550,7 +550,8 @@ void WSEvents::OnTransitionChange() { * The list of available transitions has been modified. * Transitions have been added, removed, or renamed. * - * @return {Array} `transitions` Transitions list. + * @return {Array} `transitions` Transitions list. + * @return {String} `transitions.*.name` Transition name. * * @api events * @name TransitionListChanged @@ -595,7 +596,7 @@ void WSEvents::OnProfileChange() { /** * Triggered when a profile is created, added, renamed, or removed. * - * @return {Array} `profiles` Profiles list. + * @return {Array} `profiles` Profiles list. * @return {String} `profiles.*.name` Profile name. * * @api events