From 8d0f043ac6288789bbe75f7ce7bc8fc2cafd2434 Mon Sep 17 00:00:00 2001 From: Penwywern Date: Fri, 7 Jul 2023 04:25:23 +0200 Subject: [PATCH] UI: Fix draw and find of rot handle with bounding box and flip The preview interaction and decoration of items inside bounding boxes is based on the bounding box state, not on the item's state. As such, the flip state of the item should be ignored when drawing and finding the rotation handle, since the bounding box itself isn't flipped, only the item inside the bounding box. --- UI/window-basic-preview.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/UI/window-basic-preview.cpp b/UI/window-basic-preview.cpp index 340034fec..d0cbcba0f 100644 --- a/UI/window-basic-preview.cpp +++ b/UI/window-basic-preview.cpp @@ -392,18 +392,19 @@ static bool FindHandleAtPos(obs_scene_t * /* scene */, obs_sceneitem_t *item, vec2 scale; obs_sceneitem_get_scale(item, &scale); + obs_bounds_type boundsType = obs_sceneitem_get_bounds_type(item); vec2 rotHandleOffset; vec2_set(&rotHandleOffset, 0.0f, HANDLE_RADIUS * data.radius * 1.5 - data.radius); - float angle = - atan2(scale.x < 0.0f ? transform.x.y * -1.0f : transform.x.y, - scale.x < 0.0f ? transform.x.x * -1.0f : transform.x.x); + bool invertx = scale.x < 0.0f && boundsType == OBS_BOUNDS_NONE; + float angle = atan2(invertx ? transform.x.y * -1.0f : transform.x.y, + invertx ? transform.x.x * -1.0f : transform.x.x); RotatePos(&rotHandleOffset, angle); RotatePos(&rotHandleOffset, RAD(data.angleOffset)); - bool invert = scale.y < 0.0f; + bool inverty = scale.y < 0.0f && boundsType == OBS_BOUNDS_NONE; vec3 handlePos = - GetTransformedPos(0.5f, invert ? 1.0f : 0.0f, transform); + GetTransformedPos(0.5f, inverty ? 1.0f : 0.0f, transform); vec3_transform(&handlePos, &handlePos, &data.parent_xform); handlePos.x -= rotHandleOffset.x; handlePos.y -= rotHandleOffset.y; @@ -2115,7 +2116,8 @@ bool OBSBasicPreview::DrawSelectedItem(obs_scene_t *, obs_sceneitem_t *item, prev->circleFill = gs_render_save(); } - bool invert = info.scale.y < 0.0f; + bool invert = info.scale.y < 0.0f && + info.bounds_type == OBS_BOUNDS_NONE; DrawRotationHandle(prev->circleFill, info.rot + prev->groupRot, pixelRatio, invert); }