Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions docs/sphinx/reference-frontend-api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,11 @@ Structures/Enumerations
Triggered when the current preview scene has changed in studio
mode.

- **OBS_FRONTEND_EVENT_SWAP_SCENES_MODE_CHANGED**

Triggered when the "Swap preview/program scenes after transitioning"
option in studio mode is toggled

- **OBS_FRONTEND_EVENT_SCENE_COLLECTION_CLEANUP**

Triggered when a scene collection has been completely unloaded, and
Expand Down Expand Up @@ -820,6 +825,26 @@ Functions

---------------------------------------

.. function:: obs_frontend_set_swap_scenes_mode(bool enable)

Toggles the "Swap preview/program scenes after transitioning"
behavior while in studio mode. Useful for instances where
both behaviors may be desirable depending on circumstance.
Does nothing when not using studio mode.

:param enable: *true* to enable this mode, *false* to disable it

---------------------------------------

.. function:: obs_frontend_get_swap_scenes_mode(void)

Get the current value of "Swap preview/program scenes after transitioning"
option in studio mode.

:return: *true* if mode is enabled, *false* otherwise

---------------------------------------

.. function:: void *obs_frontend_take_screenshot(void)

Takes a screenshot of the main OBS output.
Expand Down
15 changes: 15 additions & 0 deletions frontend/OBSStudioAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,21 @@ void OBSStudioAPI::obs_frontend_set_current_preview_scene(obs_source_t *scene)
Q_ARG(bool, false));
}
}
bool OBSStudioAPI::obs_frontend_get_swap_scenes_mode(void)
{
OBSBasic *main = OBSBasic::Get();
if (!main)
return false;
return main->GetSwapScenesMode();
}

void OBSStudioAPI::obs_frontend_set_swap_scenes_mode(bool enabled)
{
OBSBasic *main = OBSBasic::Get();
if (!main)
return;
main->SetSwapScenesMode(enabled);
}

void OBSStudioAPI::obs_frontend_take_screenshot()
{
Expand Down
4 changes: 4 additions & 0 deletions frontend/OBSStudioAPI.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@ struct OBSStudioAPI : obs_frontend_callbacks {

void obs_frontend_set_current_preview_scene(obs_source_t *scene) override;

bool obs_frontend_get_swap_scenes_mode(void) override;

void obs_frontend_set_swap_scenes_mode(bool enabled) override;

void obs_frontend_take_screenshot(void) override;

void obs_frontend_take_source_screenshot(obs_source_t *source) override;
Expand Down
13 changes: 13 additions & 0 deletions frontend/api/obs-frontend-api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,19 @@ void obs_frontend_take_source_screenshot(obs_source_t *source)
c->obs_frontend_take_source_screenshot(source);
}

bool obs_frontend_get_swap_scenes_mode(void)
{
if (callbacks_valid())
return c->obs_frontend_get_swap_scenes_mode();
return false;
}

void obs_frontend_set_swap_scenes_mode(bool enabled)
{
if (callbacks_valid())
c->obs_frontend_set_swap_scenes_mode(enabled);
}

obs_output_t *obs_frontend_get_virtualcam_output(void)
{
return !!callbacks_valid() ? c->obs_frontend_get_virtualcam_output() : nullptr;
Expand Down
4 changes: 4 additions & 0 deletions frontend/api/obs-frontend-api.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ enum obs_frontend_event {

OBS_FRONTEND_EVENT_CANVAS_ADDED,
OBS_FRONTEND_EVENT_CANVAS_REMOVED,
OBS_FRONTEND_EVENT_SWAP_SCENES_MODE_CHANGED,
};

/* ------------------------------------------------------------------------- */
Expand Down Expand Up @@ -222,6 +223,9 @@ EXPORT bool obs_frontend_preview_enabled(void);
EXPORT obs_source_t *obs_frontend_get_current_preview_scene(void);
EXPORT void obs_frontend_set_current_preview_scene(obs_source_t *scene);

EXPORT bool obs_frontend_get_swap_scenes_mode(void);
EXPORT void obs_frontend_set_swap_scenes_mode(bool enabled);

EXPORT void obs_frontend_take_screenshot(void);
EXPORT void obs_frontend_take_source_screenshot(obs_source_t *source);

Expand Down
3 changes: 3 additions & 0 deletions frontend/api/obs-frontend-internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ struct obs_frontend_callbacks {
virtual obs_source_t *obs_frontend_get_current_preview_scene(void) = 0;
virtual void obs_frontend_set_current_preview_scene(obs_source_t *scene) = 0;

virtual bool obs_frontend_get_swap_scenes_mode(void) = 0;
virtual void obs_frontend_set_swap_scenes_mode(bool enabled) = 0;

virtual void on_load(obs_data_t *settings) = 0;
virtual void on_preload(obs_data_t *settings) = 0;
virtual void on_save(obs_data_t *settings) = 0;
Expand Down
3 changes: 3 additions & 0 deletions frontend/widgets/OBSBasic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1583,10 +1583,13 @@ private slots:
void CurrentTransitionChanged(const QString &uuid);

void TransitionDurationChanged(const int &duration);
void SwapScenesModeChanged(bool enabled);

public:
int GetTransitionDuration();
int GetTbarPosition();
bool GetSwapScenesMode() const { return swapScenesMode; }
void SetSwapScenesMode(bool enabled);

/* -------------------------------------
* MARK: - OBSBasic_Updater
Expand Down
2 changes: 1 addition & 1 deletion frontend/widgets/OBSBasic_StudioMode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ void OBSBasic::CreateProgramOptions()
};

auto toggleSwapScenesMode = [this]() {
swapScenesMode = !swapScenesMode;
SetSwapScenesMode(!swapScenesMode);
};

auto toggleSceneDuplication = [this]() {
Expand Down
16 changes: 16 additions & 0 deletions frontend/widgets/OBSBasic_Transitions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,22 @@ void OBSBasic::TransitionFullyStopped()
overridingTransition = false;
}
}
void OBSBasic::SetSwapScenesMode(bool enabled)

{
QMetaObject::invokeMethod(this, [this, enabled]() {
if (swapScenesMode == enabled)
return;

swapScenesMode = enabled;

blog(LOG_INFO, "SwapScenesMode set to: %s", enabled ? "enabled" : "disabled");

emit SwapScenesModeChanged(enabled);

OnEvent(OBS_FRONTEND_EVENT_SWAP_SCENES_MODE_CHANGED);
});
}

void OBSBasic::TransitionToScene(OBSSource source, bool force, bool quickTransition, int quickDuration, bool black,
bool manual)
Expand Down
Loading