UI: Transform Feedback for Invalid States
This adds support for Transform MouseInputMode INPUT_ERROR using a new transform cursor HLP_ERROR (dashed line ending with WM_CURSOR_STOP. This is shown when attempting an object rotation or scale when transforms are set to "Affect Only Locations". At this time the status bar is also cleared and an warning message is shown. Pull Request: #132957
This commit is contained in:
parent
fd9f046db2
commit
40eadc75be
@ -256,6 +256,7 @@ enum eTHelpline {
|
||||
HLP_VARROW = 4,
|
||||
HLP_CARROW = 5,
|
||||
HLP_TRACKBALL = 6,
|
||||
HLP_ERROR = 7,
|
||||
};
|
||||
|
||||
enum eTOType {
|
||||
@ -957,6 +958,7 @@ enum MouseInputMode {
|
||||
INPUT_VERTICAL_ABSOLUTE,
|
||||
INPUT_CUSTOM_RATIO,
|
||||
INPUT_CUSTOM_RATIO_FLIP,
|
||||
INPUT_ERROR,
|
||||
};
|
||||
|
||||
void initMouseInput(TransInfo *t,
|
||||
|
@ -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)) {
|
||||
if (ELEM(t->helpline, HLP_SPRING, HLP_ANGLE, HLP_ERROR)) {
|
||||
GPU_line_width(DASH_WIDTH);
|
||||
immBindBuiltinProgram(GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR);
|
||||
immUniform2f("viewport_size", viewport_size[2], viewport_size[3]);
|
||||
@ -249,6 +249,7 @@ void transform_draw_cursor_draw(bContext *C, int x, int y, void *customdata)
|
||||
drawArrow(pos_id, DOWN);
|
||||
break;
|
||||
}
|
||||
case HLP_ERROR:
|
||||
case HLP_NONE:
|
||||
break;
|
||||
}
|
||||
|
@ -426,6 +426,10 @@ void initMouseInputMode(TransInfo *t, MouseInput *mi, MouseInputMode mode)
|
||||
mi->apply = InputCustomRatioFlip;
|
||||
t->helpline = HLP_CARROW;
|
||||
break;
|
||||
case INPUT_ERROR:
|
||||
mi->apply = nullptr;
|
||||
t->helpline = HLP_ERROR;
|
||||
break;
|
||||
case INPUT_NONE:
|
||||
default:
|
||||
mi->apply = nullptr;
|
||||
@ -467,6 +471,10 @@ void initMouseInputMode(TransInfo *t, MouseInput *mi, MouseInputMode mode)
|
||||
WM_cursor_modal_set(win, WM_CURSOR_NONE);
|
||||
}
|
||||
break;
|
||||
case HLP_ERROR:
|
||||
t->flag |= T_MODAL_CURSOR_SET;
|
||||
WM_cursor_modal_set(win, WM_CURSOR_STOP);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -14,9 +14,13 @@
|
||||
#include "BLI_math_vector.h"
|
||||
#include "BLI_task.h"
|
||||
|
||||
#include "BKE_context.hh"
|
||||
|
||||
#include "BKE_image.hh"
|
||||
#include "BKE_unit.hh"
|
||||
|
||||
#include "BLT_translation.hh"
|
||||
|
||||
#include "ED_screen.hh"
|
||||
|
||||
#include "RNA_access.hh"
|
||||
@ -311,8 +315,17 @@ 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);
|
||||
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, INPUT_SPRING_FLIP);
|
||||
initMouseInputMode(t, &t->mouse, only_location ? INPUT_ERROR : INPUT_SPRING_FLIP);
|
||||
}
|
||||
else {
|
||||
int mval_start[2], mval_end[2];
|
||||
@ -340,7 +353,7 @@ static void initResize(TransInfo *t, wmOperator *op)
|
||||
|
||||
setCustomPoints(t, &t->mouse, mval_end, mval_start);
|
||||
|
||||
initMouseInputMode(t, &t->mouse, INPUT_CUSTOM_RATIO);
|
||||
initMouseInputMode(t, &t->mouse, only_location ? INPUT_ERROR : INPUT_CUSTOM_RATIO);
|
||||
}
|
||||
|
||||
t->num.val_flag[0] |= NUM_NULL_ONE;
|
||||
|
@ -13,9 +13,12 @@
|
||||
#include "BLI_math_vector.h"
|
||||
#include "BLI_task.h"
|
||||
|
||||
#include "BKE_context.hh"
|
||||
#include "BKE_report.hh"
|
||||
#include "BKE_unit.hh"
|
||||
|
||||
#include "BLT_translation.hh"
|
||||
|
||||
#include "ED_screen.hh"
|
||||
|
||||
#include "UI_interface.hh"
|
||||
@ -408,7 +411,18 @@ static void initRotation(TransInfo *t, wmOperator * /*op*/)
|
||||
|
||||
t->mode = TFM_ROTATION;
|
||||
|
||||
initMouseInputMode(t, &t->mouse, INPUT_ANGLE);
|
||||
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) {
|
||||
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_ANGLE);
|
||||
}
|
||||
|
||||
t->idx_max = 0;
|
||||
t->num.idx_max = 0;
|
||||
|
@ -419,6 +419,11 @@ 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)) {
|
||||
ED_workspace_status_text(t->context, nullptr);
|
||||
}
|
||||
|
||||
exit_code = transformEvent(t, op, event);
|
||||
t->context = nullptr;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user