From 6f885770f86e5f0277baa8fc9634002f0b187add Mon Sep 17 00:00:00 2001 From: Penwywern Date: Fri, 7 Jul 2023 06:08:16 +0200 Subject: [PATCH] UI: Fix crop on flipped sceneitems in bounding boxes Same as previous commits, flipped sceneitems in bounding boxes ought to be treated as not flipped for the purpose of UI interaction in order to function correctly. --- UI/window-basic-preview.cpp | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/UI/window-basic-preview.cpp b/UI/window-basic-preview.cpp index c3936951d..d3c9e4e55 100644 --- a/UI/window-basic-preview.cpp +++ b/UI/window-basic-preview.cpp @@ -1360,9 +1360,13 @@ void OBSBasicPreview::CropItem(const vec2 &pos) vec3_transform(&pos3, &pos3, &screenToItem); obs_sceneitem_crop crop = startCrop; - vec2 scale; + vec2 scale, rawscale; - obs_sceneitem_get_scale(stretchItem, &scale); + obs_sceneitem_get_scale(stretchItem, &rawscale); + vec2_set(&scale, + boundsType == OBS_BOUNDS_NONE ? rawscale.x : fabsf(rawscale.x), + boundsType == OBS_BOUNDS_NONE ? rawscale.y + : fabsf(rawscale.y)); vec2 max_tl; vec2 max_br; @@ -1374,10 +1378,18 @@ void OBSBasicPreview::CropItem(const vec2 &pos) typedef std::function minmax_func_t; - minmax_func_t min_x = scale.x < 0.0f ? maxfunc : minfunc; - minmax_func_t min_y = scale.y < 0.0f ? maxfunc : minfunc; - minmax_func_t max_x = scale.x < 0.0f ? minfunc : maxfunc; - minmax_func_t max_y = scale.y < 0.0f ? minfunc : maxfunc; + minmax_func_t min_x = scale.x < 0.0f && boundsType == OBS_BOUNDS_NONE + ? maxfunc + : minfunc; + minmax_func_t min_y = scale.y < 0.0f && boundsType == OBS_BOUNDS_NONE + ? maxfunc + : minfunc; + minmax_func_t max_x = scale.x < 0.0f && boundsType == OBS_BOUNDS_NONE + ? minfunc + : maxfunc; + minmax_func_t max_y = scale.y < 0.0f && boundsType == OBS_BOUNDS_NONE + ? minfunc + : maxfunc; pos3.x = min_x(pos3.x, max_br.x); pos3.x = max_x(pos3.x, max_tl.x);