Merge branch 'mb-0001-operator-repeat' into main

This commit is contained in:
Jaume Bellet 2024-02-26 08:39:54 +01:00
commit 760b76a0e3
7 changed files with 36 additions and 1 deletions

View File

@ -1377,6 +1377,10 @@ int transformEvent(TransInfo *t, const wmEvent *event)
/* Else do non-mapped events. */
else if (event->val == KM_PRESS) {
switch (event->type) {
case EVT_MKEY :
t->flag |= T_TRANSFORM_MULTIPLE;
handled = true;
break;
case EVT_CKEY:
if (event->flag & WM_EVENT_IS_REPEAT) {
break;
@ -1919,6 +1923,12 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
RNA_property_boolean_set(
op->ptr, prop, (t->settings->uvcalc_flag & UVCALC_TRANSFORM_CORRECT_SLIDE) != 0);
}
if ((prop = RNA_struct_find_property(op->ptr, "transform_multiple"))) {
RNA_boolean_set(op->ptr, "transform_multiple", (t->flag & T_TRANSFORM_MULTIPLE) != 0);
}
}
static void initSnapSpatial(TransInfo *t, float r_snap[3], float *r_snap_precision)
@ -2015,6 +2025,12 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
initTransInfo(C, t, op, event);
if (prop = RNA_struct_find_property(op->ptr, "transform_multiple")) {
if (RNA_boolean_get(op->ptr, "transform_multiple")) {
t->flag |= T_TRANSFORM_MULTIPLE;
}
}
if (t->spacetype == SPACE_VIEW3D) {
t->draw_handle_view = ED_region_draw_cb_activate(
t->region->type, drawTransformView, t, REGION_DRAW_POST_VIEW);
@ -2272,6 +2288,10 @@ int transformEnd(bContext *C, TransInfo *t)
exit_code = OPERATOR_FINISHED;
}
if (t->state == TRANS_CONFIRM && (t->flag & T_TRANSFORM_MULTIPLE)) {
exit_code |= OPERATOR_REPEAT;
}
/* aftertrans does insert keyframes, and clears base flags; doesn't read transdata */
special_aftertrans_update(C, t);

View File

@ -150,6 +150,12 @@ enum eTFlag {
/** Special flag for when the transform code is called after keys have been duplicated. */
T_DUPLICATED_KEYFRAMES = 1 << 26,
/* Used on MB-0001-operator-repeat */
T_TRANSFORM_MULTIPLE = 1 << 27,
/* Used on MB-0006-allow-no-modal-transform*/
T_TRANSFORM_NO_MODAL = 1 << 28,
};
ENUM_OPERATORS(eTFlag, T_DUPLICATED_KEYFRAMES);

View File

@ -832,6 +832,8 @@ void Transform_Properties(wmOperatorType *ot, int flags)
"Forces the use of Auto Merge and Split");
RNA_def_property_flag(prop, PROP_HIDDEN);
}
RNA_def_boolean(ot->srna, "transform_multiple", 0, "Multiple", "Apply Multiple times");
}
static void TRANSFORM_OT_translate(wmOperatorType *ot)

View File

@ -653,10 +653,12 @@ enum {
* \note this isn't great design (using operators to trigger UI) avoid where possible.
*/
OPERATOR_INTERFACE = (1 << 5),
/* Create a new operator based on current */
OPERATOR_REPEAT = (1 << 6),
};
#define OPERATOR_FLAGS_ALL \
(OPERATOR_RUNNING_MODAL | OPERATOR_CANCELLED | OPERATOR_FINISHED | OPERATOR_PASS_THROUGH | \
OPERATOR_HANDLED | OPERATOR_INTERFACE | 0)
OPERATOR_HANDLED | OPERATOR_INTERFACE | OPERATOR_REPEAT | 0)
/* sanity checks for debug mode only */
#define OPERATOR_RETVAL_CHECK(ret) \

View File

@ -0,0 +1 @@
/* Empty File */

View File

@ -0,0 +1 @@
/* Empty File */

View File

@ -2551,6 +2551,9 @@ static eHandlerActionFlag wm_handler_operator_call(bContext *C,
CTX_wm_area_set(C, area);
CTX_wm_region_set(C, region);
}
else if (retval & OPERATOR_REPEAT) {
wm_operator_invoke(C, ot, event, properties, NULL, false, true);
}
else {
/* This special cases is for areas and regions that get removed. */
CTX_wm_area_set(C, nullptr);