Skip to content
Draft
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
1 change: 1 addition & 0 deletions libobs/build/libobs.core-source+.h.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#include "libobs/obs-scene-item-select-fields.c.h"
#include "libobs/obs-scene-item-set-info2-fields.c.h"
#include "libobs/obs-scene-item-set-order-fields.c.h"
#include "libobs/obs-scene-item-set-order-position.c.h"
#include "libobs/obs-scene-item-set-visibility-fields.c.h"
#include "libobs/obs-scene-item-transition-fields.c.h"
#include "libobs/obs-scene-item-visible-fields.c.h"
Expand Down
43 changes: 43 additions & 0 deletions libobs/obs-scene-item-set-order-position.c.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#include "libobs/build/libobs.pch.h"

/* Dependencies stay in obs-scene.c.h in this same unity group. */
static inline void full_lock(struct obs_scene *scene);
static inline void full_unlock(struct obs_scene *scene);
static inline void detach_sceneitem(struct obs_scene_item *item);
static inline void attach_sceneitem(struct obs_scene *parent, struct obs_scene_item *item, struct obs_scene_item *prev);
static inline void signal_reorder(struct obs_scene_item *item);

void obs_sceneitem_set_order_position(obs_sceneitem_t *item, int position)
{
if (!item)
return;

struct obs_scene *scene = obs_scene_get_ref(item->parent);

if (!scene)
return;

full_lock(scene);

detach_sceneitem(item);

size_t steps = 0;
if (obs_scene_item_order_position(position, scene->first_item != NULL, &steps)) {
attach_sceneitem(scene, item, NULL);
} else {
struct obs_scene_item *next = scene->first_item;

for (size_t i = steps; i > 0; --i) {
if (next->next == NULL)
break;
next = next->next;
}

attach_sceneitem(scene, item, next);
}

full_unlock(scene);

signal_reorder(item);
obs_scene_release(scene);
}
35 changes: 0 additions & 35 deletions libobs/obs-scene.c.h
Original file line number Diff line number Diff line change
Expand Up @@ -1874,41 +1874,6 @@ _Static_assert(OBS_ORDER_MOVE_TOP == 2, "OBS_ORDER_MOVE_TOP");
_Static_assert(OBS_ORDER_MOVE_BOTTOM == 3, "OBS_ORDER_MOVE_BOTTOM");
_Static_assert(sizeof(struct obs_sceneitem_order_info) == 2 * sizeof(void *), "struct obs_sceneitem_order_info");

void obs_sceneitem_set_order_position(obs_sceneitem_t *item, int position)
{
if (!item)
return;

struct obs_scene *scene = obs_scene_get_ref(item->parent);

if (!scene)
return;

full_lock(scene);

detach_sceneitem(item);

size_t steps = 0;
if (obs_scene_item_order_position(position, scene->first_item != NULL, &steps)) {
attach_sceneitem(scene, item, NULL);
} else {
struct obs_scene_item *next = scene->first_item;

for (size_t i = steps; i > 0; --i) {
if (next->next == NULL)
break;
next = next->next;
}

attach_sceneitem(scene, item, next);
}

full_unlock(scene);

signal_reorder(item);
obs_scene_release(scene);
}

static bool group_item_transition(obs_scene_t *scene, obs_sceneitem_t *item, void *param)
{
if (!param || !item)
Expand Down
Loading