Skip to content

Commit

Permalink
libobs: Remove relative positioning functions
Browse files Browse the repository at this point in the history
Revert "docs: Add new relative positioning scene functions"

This partially reverts commit 366cfdb.

The addition of obs_sceneitem_(get/set)_info2 was not removed as that is
still valid.
  • Loading branch information
derrod authored and RytoEX committed Dec 4, 2024
1 parent e9c6105 commit 10dc43b
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 130 deletions.
32 changes: 0 additions & 32 deletions docs/sphinx/reference-scenes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -365,18 +365,6 @@ Scene Item Functions

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

.. function:: void obs_sceneitem_set_relative_pos(obs_sceneitem_t *item, const struct vec2 *pos)
void obs_sceneitem_get_relative_pos(const obs_sceneitem_t *item, struct vec2 *pos)
Sets/gets the position of a scene item in relative coordinates.
In this system `(0.0, 0.0)` is the center of the screen, `(0, -1.0)` the bottom and `(0, 1.0)` the top.
The visible range of the horizontal axis depends on aspect ratio, for example, with 16:9 (1.7777...) this is `[-1.777.., -1.777..]`.
Positions are rounded to the nearest half-pixel when converting from relative to absolute pixel values to maintain backwards compaibility.

.. versionadded:: 31.0

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

.. function:: void obs_sceneitem_set_rot(obs_sceneitem_t *item, float rot_deg)
float obs_sceneitem_get_rot(const obs_sceneitem_t *item)
Expand Down Expand Up @@ -469,16 +457,6 @@ Scene Item Functions

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

.. function:: void obs_sceneitem_set_relative_bounds(obs_sceneitem_t *item, const struct vec2 *bounds)
void obs_sceneitem_get_relative_bounds(const obs_sceneitem_t *item, struct vec2 *bounds)
Sets/gets the bounding box width/height of the scene item in relative sizes.
See :c:func:`obs_sceneitem_get_relative_pos()`/:c:func:`obs_sceneitem_set_relative_pos()` for details on the relative coordinate system.

.. versionadded:: 31.0

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

.. function:: void obs_sceneitem_set_info(obs_sceneitem_t *item, const struct obs_transform_info *info)
void obs_sceneitem_get_info(const obs_sceneitem_t *item, struct obs_transform_info *info)
Expand All @@ -496,16 +474,6 @@ Scene Item Functions

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

.. function:: void obs_sceneitem_set_info3(obs_sceneitem_t *item, const struct obs_transform_info *info)
void obs_sceneitem_get_info3(const obs_sceneitem_t *item, struct obs_transform_info *info)
Sets/gets the transform information of the scene item.
This version uses relative coordinates, see :c:func:`obs_sceneitem_get_relative_pos()`/:c:func:`obs_sceneitem_set_relative_pos()` for details.

.. versionadded:: 31.0

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

.. function:: void obs_sceneitem_get_draw_transform(const obs_sceneitem_t *item, struct matrix4 *transform)

Gets the transform matrix of the scene item used for drawing the
Expand Down
92 changes: 0 additions & 92 deletions libobs/obs-scene.c
Original file line number Diff line number Diff line change
Expand Up @@ -2740,18 +2740,6 @@ void obs_sceneitem_set_pos(obs_sceneitem_t *item, const struct vec2 *pos)
}
}

void obs_sceneitem_set_relative_pos(obs_sceneitem_t *item, const struct vec2 *pos)
{
if (item) {
if (!item->absolute_coordinates)
vec2_copy(&item->pos, pos);
else
pos_to_absolute(&item->pos, pos, item);

do_update_transform(item);
}
}

void obs_sceneitem_set_rot(obs_sceneitem_t *item, float rot)
{
if (item) {
Expand Down Expand Up @@ -2937,18 +2925,6 @@ void obs_sceneitem_set_bounds(obs_sceneitem_t *item, const struct vec2 *bounds)
}
}

void obs_sceneitem_set_relative_bounds(obs_sceneitem_t *item, const struct vec2 *bounds)
{
if (item) {
if (!item->absolute_coordinates)
vec2_copy(&item->bounds, bounds);
else
size_to_absolute(&item->bounds, bounds, item);

do_update_transform(item);
}
}

void obs_sceneitem_get_pos(const obs_sceneitem_t *item, struct vec2 *pos)
{
if (!item)
Expand All @@ -2960,17 +2936,6 @@ void obs_sceneitem_get_pos(const obs_sceneitem_t *item, struct vec2 *pos)
vec2_copy(pos, &item->pos);
}

void obs_sceneitem_get_relative_pos(const obs_sceneitem_t *item, struct vec2 *pos)
{
if (!item)
return;

if (!item->absolute_coordinates)
vec2_copy(pos, &item->pos);
else
pos_from_absolute(pos, &item->pos, item);
}

float obs_sceneitem_get_rot(const obs_sceneitem_t *item)
{
return item ? item->rot : 0.0f;
Expand Down Expand Up @@ -3018,17 +2983,6 @@ void obs_sceneitem_get_bounds(const obs_sceneitem_t *item, struct vec2 *bounds)
vec2_copy(bounds, &item->bounds);
}

void obs_sceneitem_get_relative_bounds(const obs_sceneitem_t *item, struct vec2 *bounds)
{
if (!item)
return;

if (!item->absolute_coordinates)
vec2_copy(bounds, &item->bounds);
else
size_from_absolute(bounds, &item->bounds, item);
}

static inline void scene_item_get_info_internal(const obs_sceneitem_t *item, struct obs_transform_info *info)
{
if (!item->absolute_coordinates) {
Expand Down Expand Up @@ -3061,26 +3015,6 @@ void obs_sceneitem_get_info2(const obs_sceneitem_t *item, struct obs_transform_i
}
}

void obs_sceneitem_get_info3(const obs_sceneitem_t *item, struct obs_transform_info *info)
{
if (item && info) {
if (!item->absolute_coordinates) {
info->pos = item->pos;
item_canvas_scale(&info->scale, item);
info->bounds = item->bounds;
} else {
pos_from_absolute(&info->pos, &item->pos, item);
item_relative_scale(&info->scale, &item->scale, item);
size_from_absolute(&info->bounds, &item->bounds, item);
}
info->rot = item->rot;
info->alignment = item->align;
info->bounds_type = item->bounds_type;
info->bounds_alignment = item->bounds_align;
info->crop_to_bounds = item->crop_to_bounds;
}
}

static inline void scene_item_set_info_internal(obs_sceneitem_t *item, const struct obs_transform_info *info)
{
if (!item->absolute_coordinates) {
Expand Down Expand Up @@ -3120,32 +3054,6 @@ void obs_sceneitem_set_info2(obs_sceneitem_t *item, const struct obs_transform_i
}
}

void obs_sceneitem_set_info3(obs_sceneitem_t *item, const struct obs_transform_info *info)
{
if (item && info) {
if (!item->absolute_coordinates) {
item->pos = info->pos;
item->bounds = info->bounds;
if (isfinite(info->scale.x) && isfinite(info->scale.y)) {
item_relative_scale(&item->scale, &info->scale, item);
}
} else {
pos_to_absolute(&item->pos, &info->pos, item);
size_to_absolute(&item->bounds, &info->bounds, item);
if (isfinite(info->scale.x) && isfinite(info->scale.y)) {
item_canvas_scale(&item->scale, item);
}
}

item->rot = info->rot;
item->align = info->alignment;
item->bounds_type = info->bounds_type;
item->bounds_align = info->bounds_alignment;
item->crop_to_bounds = info->crop_to_bounds;
do_update_transform(item);
}
}

void obs_sceneitem_get_draw_transform(const obs_sceneitem_t *item, struct matrix4 *transform)
{
if (item)
Expand Down
6 changes: 0 additions & 6 deletions libobs/obs.h
Original file line number Diff line number Diff line change
Expand Up @@ -1672,7 +1672,6 @@ EXPORT bool obs_sceneitem_set_locked(obs_sceneitem_t *item, bool lock);

/* Functions for getting/setting specific orientation of a scene item */
EXPORT void obs_sceneitem_set_pos(obs_sceneitem_t *item, const struct vec2 *pos);
EXPORT void obs_sceneitem_set_relative_pos(obs_sceneitem_t *item, const struct vec2 *pos);
EXPORT void obs_sceneitem_set_rot(obs_sceneitem_t *item, float rot_deg);
EXPORT void obs_sceneitem_set_scale(obs_sceneitem_t *item, const struct vec2 *scale);
EXPORT void obs_sceneitem_set_alignment(obs_sceneitem_t *item, uint32_t alignment);
Expand All @@ -1682,12 +1681,10 @@ EXPORT void obs_sceneitem_set_bounds_type(obs_sceneitem_t *item, enum obs_bounds
EXPORT void obs_sceneitem_set_bounds_alignment(obs_sceneitem_t *item, uint32_t alignment);
EXPORT void obs_sceneitem_set_bounds_crop(obs_sceneitem_t *item, bool crop);
EXPORT void obs_sceneitem_set_bounds(obs_sceneitem_t *item, const struct vec2 *bounds);
EXPORT void obs_sceneitem_set_relative_bounds(obs_sceneitem_t *item, const struct vec2 *bounds);

EXPORT int64_t obs_sceneitem_get_id(const obs_sceneitem_t *item);

EXPORT void obs_sceneitem_get_pos(const obs_sceneitem_t *item, struct vec2 *pos);
EXPORT void obs_sceneitem_get_relative_pos(const obs_sceneitem_t *item, struct vec2 *pos);
EXPORT float obs_sceneitem_get_rot(const obs_sceneitem_t *item);
EXPORT void obs_sceneitem_get_scale(const obs_sceneitem_t *item, struct vec2 *scale);
EXPORT uint32_t obs_sceneitem_get_alignment(const obs_sceneitem_t *item);
Expand All @@ -1696,14 +1693,11 @@ EXPORT enum obs_bounds_type obs_sceneitem_get_bounds_type(const obs_sceneitem_t
EXPORT uint32_t obs_sceneitem_get_bounds_alignment(const obs_sceneitem_t *item);
EXPORT bool obs_sceneitem_get_bounds_crop(const obs_sceneitem_t *item);
EXPORT void obs_sceneitem_get_bounds(const obs_sceneitem_t *item, struct vec2 *bounds);
EXPORT void obs_sceneitem_get_relative_bounds(const obs_sceneitem_t *item, struct vec2 *bounds);

OBS_DEPRECATED EXPORT void obs_sceneitem_get_info(const obs_sceneitem_t *item, struct obs_transform_info *info);
OBS_DEPRECATED EXPORT void obs_sceneitem_set_info(obs_sceneitem_t *item, const struct obs_transform_info *info);
EXPORT void obs_sceneitem_get_info2(const obs_sceneitem_t *item, struct obs_transform_info *info);
EXPORT void obs_sceneitem_set_info2(obs_sceneitem_t *item, const struct obs_transform_info *info);
EXPORT void obs_sceneitem_get_info3(const obs_sceneitem_t *item, struct obs_transform_info *info);
EXPORT void obs_sceneitem_set_info3(obs_sceneitem_t *item, const struct obs_transform_info *info);

EXPORT void obs_sceneitem_get_draw_transform(const obs_sceneitem_t *item, struct matrix4 *transform);
EXPORT void obs_sceneitem_get_box_transform(const obs_sceneitem_t *item, struct matrix4 *transform);
Expand Down

0 comments on commit 10dc43b

Please sign in to comment.