From f874d4658970970538e71fc687b0684ffd0fe6b7 Mon Sep 17 00:00:00 2001 From: John Kiril Swenson Date: Fri, 28 Feb 2025 21:14:36 +0100 Subject: [PATCH] Fix: UI: Transform Feedback for Invalid Trackball Patch #132957 added helpful UI feedback when attempting to rotate or scale an object whose transforms are set to "only affect locations." But it neglected to check for invalid trackpad rotations that are affected the same way. This patch renames the original `HLP_ERROR` to `HLP_ERROR_DASH` to distinguish it from a `HLP_ERROR` transform cursor with no dashed line present, which matches trackball's normal state. Pull Request: https://projects.blender.org/blender/blender/pulls/134653 --- source/blender/editors/transform/transform.hh | 2 ++ .../blender/editors/transform/transform_draw_cursors.cc | 3 ++- source/blender/editors/transform/transform_input.cc | 5 +++++ source/blender/editors/transform/transform_mode.cc | 7 +++++++ source/blender/editors/transform/transform_mode.hh | 1 + .../blender/editors/transform/transform_mode_resize.cc | 9 +++------ .../blender/editors/transform/transform_mode_rotate.cc | 8 ++------ .../editors/transform/transform_mode_trackball.cc | 9 ++++++++- source/blender/editors/transform/transform_ops.cc | 2 +- 9 files changed, 31 insertions(+), 15 deletions(-) diff --git a/source/blender/editors/transform/transform.hh b/source/blender/editors/transform/transform.hh index d08c71e2d3c..2adc6619f2b 100644 --- a/source/blender/editors/transform/transform.hh +++ b/source/blender/editors/transform/transform.hh @@ -257,6 +257,7 @@ enum eTHelpline { HLP_CARROW = 5, HLP_TRACKBALL = 6, HLP_ERROR = 7, + HLP_ERROR_DASH = 8, }; enum eTOType { @@ -959,6 +960,7 @@ enum MouseInputMode { INPUT_CUSTOM_RATIO, INPUT_CUSTOM_RATIO_FLIP, INPUT_ERROR, + INPUT_ERROR_DASH, }; void initMouseInput(TransInfo *t, diff --git a/source/blender/editors/transform/transform_draw_cursors.cc b/source/blender/editors/transform/transform_draw_cursors.cc index 85727726b69..8e730186291 100644 --- a/source/blender/editors/transform/transform_draw_cursors.cc +++ b/source/blender/editors/transform/transform_draw_cursors.cc @@ -128,7 +128,7 @@ void transform_draw_cursor_draw(bContext *C, int x, int y, void *customdata) immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); /* Dashed lines first. */ - if (ELEM(t->helpline, HLP_SPRING, HLP_ANGLE, HLP_ERROR)) { + if (ELEM(t->helpline, HLP_SPRING, HLP_ANGLE, HLP_ERROR_DASH)) { GPU_line_width(DASH_WIDTH); immBindBuiltinProgram(GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR); immUniform2f("viewport_size", viewport_size[2], viewport_size[3]); @@ -250,6 +250,7 @@ void transform_draw_cursor_draw(bContext *C, int x, int y, void *customdata) break; } case HLP_ERROR: + case HLP_ERROR_DASH: case HLP_NONE: break; } diff --git a/source/blender/editors/transform/transform_input.cc b/source/blender/editors/transform/transform_input.cc index 6f50ec8a1fe..5d46379e858 100644 --- a/source/blender/editors/transform/transform_input.cc +++ b/source/blender/editors/transform/transform_input.cc @@ -430,6 +430,10 @@ void initMouseInputMode(TransInfo *t, MouseInput *mi, MouseInputMode mode) mi->apply = nullptr; t->helpline = HLP_ERROR; break; + case INPUT_ERROR_DASH: + mi->apply = nullptr; + t->helpline = HLP_ERROR_DASH; + break; case INPUT_NONE: default: mi->apply = nullptr; @@ -472,6 +476,7 @@ void initMouseInputMode(TransInfo *t, MouseInput *mi, MouseInputMode mode) } break; case HLP_ERROR: + case HLP_ERROR_DASH: t->flag |= T_MODAL_CURSOR_SET; WM_cursor_modal_set(win, WM_CURSOR_STOP); break; diff --git a/source/blender/editors/transform/transform_mode.cc b/source/blender/editors/transform/transform_mode.cc index 1623c9c5e35..df83d8645f4 100644 --- a/source/blender/editors/transform/transform_mode.cc +++ b/source/blender/editors/transform/transform_mode.cc @@ -79,6 +79,13 @@ bool transform_mode_is_changeable(const int mode) TFM_NORMAL_ROTATION); } +bool transform_mode_affect_only_locations(const TransInfo *t) +{ + return (t->flag & T_V3D_ALIGN) && (t->options & CTX_OBJECT) && + (t->settings->transform_pivot_point != V3D_AROUND_CURSOR) && t->context && + (CTX_DATA_COUNT(t->context, selected_editable_objects) == 1); +} + /* -------------------------------------------------------------------- */ /** \name Transform Locks * \{ */ diff --git a/source/blender/editors/transform/transform_mode.hh b/source/blender/editors/transform/transform_mode.hh index b159d812b05..d36121d8490 100644 --- a/source/blender/editors/transform/transform_mode.hh +++ b/source/blender/editors/transform/transform_mode.hh @@ -68,6 +68,7 @@ bool transdata_check_local_center(const TransInfo *t, short around); * Informs if the mode can be switched during modal. */ bool transform_mode_is_changeable(int mode); +bool transform_mode_affect_only_locations(const TransInfo *t); void protectedTransBits(short protectflag, float vec[3]); void protectedSizeBits(short protectflag, float size[3]); void constraintTransLim(const TransInfo *t, const TransDataContainer *tc, TransData *td); diff --git a/source/blender/editors/transform/transform_mode_resize.cc b/source/blender/editors/transform/transform_mode_resize.cc index bcf8379e34a..4d9b221def4 100644 --- a/source/blender/editors/transform/transform_mode_resize.cc +++ b/source/blender/editors/transform/transform_mode_resize.cc @@ -312,17 +312,14 @@ static void initResize(TransInfo *t, wmOperator *op) zero_v3(mouse_dir_constraint); } - const bool only_location = (t->flag & T_V3D_ALIGN) && (t->options & CTX_OBJECT) && - (t->settings->transform_pivot_point != V3D_AROUND_CURSOR) && - t->context && - (CTX_DATA_COUNT(t->context, selected_editable_objects) == 1); + const bool only_location = transform_mode_affect_only_locations(t); if (only_location) { WorkspaceStatus status(t->context); status.item(TIP_("Transform is set to only affect location"), ICON_ERROR); } if (is_zero_v3(mouse_dir_constraint)) { - initMouseInputMode(t, &t->mouse, only_location ? INPUT_ERROR : INPUT_SPRING_FLIP); + initMouseInputMode(t, &t->mouse, only_location ? INPUT_ERROR_DASH : INPUT_SPRING_FLIP); } else { int mval_start[2], mval_end[2]; @@ -350,7 +347,7 @@ static void initResize(TransInfo *t, wmOperator *op) setCustomPoints(t, &t->mouse, mval_end, mval_start); - initMouseInputMode(t, &t->mouse, only_location ? INPUT_ERROR : INPUT_CUSTOM_RATIO); + initMouseInputMode(t, &t->mouse, only_location ? INPUT_ERROR_DASH : INPUT_CUSTOM_RATIO); } t->num.val_flag[0] |= NUM_NULL_ONE; diff --git a/source/blender/editors/transform/transform_mode_rotate.cc b/source/blender/editors/transform/transform_mode_rotate.cc index b359730319e..fde11a12269 100644 --- a/source/blender/editors/transform/transform_mode_rotate.cc +++ b/source/blender/editors/transform/transform_mode_rotate.cc @@ -411,14 +411,10 @@ static void initRotation(TransInfo *t, wmOperator * /*op*/) t->mode = TFM_ROTATION; - const bool only_location = (t->flag & T_V3D_ALIGN) && (t->options & CTX_OBJECT) && - (t->settings->transform_pivot_point != V3D_AROUND_CURSOR) && - t->context && - (CTX_DATA_COUNT(t->context, selected_editable_objects) == 1); - if (only_location) { + if (transform_mode_affect_only_locations(t)) { WorkspaceStatus status(t->context); status.item(TIP_("Transform is set to only affect location"), ICON_ERROR); - initMouseInputMode(t, &t->mouse, INPUT_ERROR); + initMouseInputMode(t, &t->mouse, INPUT_ERROR_DASH); } else { initMouseInputMode(t, &t->mouse, INPUT_ANGLE); diff --git a/source/blender/editors/transform/transform_mode_trackball.cc b/source/blender/editors/transform/transform_mode_trackball.cc index 491d639a8db..95e8b274842 100644 --- a/source/blender/editors/transform/transform_mode_trackball.cc +++ b/source/blender/editors/transform/transform_mode_trackball.cc @@ -191,7 +191,14 @@ static void initTrackball(TransInfo *t, wmOperator * /*op*/) { t->mode = TFM_TRACKBALL; - initMouseInputMode(t, &t->mouse, INPUT_TRACKBALL); + if (transform_mode_affect_only_locations(t)) { + WorkspaceStatus status(t->context); + status.item(TIP_("Transform is set to only affect location"), ICON_ERROR); + initMouseInputMode(t, &t->mouse, INPUT_ERROR); + } + else { + initMouseInputMode(t, &t->mouse, INPUT_TRACKBALL); + } t->idx_max = 1; t->num.idx_max = 1; diff --git a/source/blender/editors/transform/transform_ops.cc b/source/blender/editors/transform/transform_ops.cc index bb6dbb11e1a..5a69198c994 100644 --- a/source/blender/editors/transform/transform_ops.cc +++ b/source/blender/editors/transform/transform_ops.cc @@ -420,7 +420,7 @@ static int transform_modal(bContext *C, wmOperator *op, const wmEvent *event) /* XXX insert keys are called here, and require context. */ t->context = C; - if ((t->helpline != HLP_ERROR)) { + if (t->helpline != HLP_ERROR && t->helpline != HLP_ERROR_DASH) { ED_workspace_status_text(t->context, nullptr); }