[Bf-blender-cvs] [f5af20d2b5b] temp-event-modifier: Use modifier flag for events
Campbell Barton
noreply at git.blender.org
Fri Feb 25 07:11:56 CET 2022
Commit: f5af20d2b5b2152c4eed8e46f055b88f6a9183d1
Author: Campbell Barton
Date: Fri Feb 25 16:59:37 2022 +1100
Branches: temp-event-modifier
https://developer.blender.org/rBf5af20d2b5b2152c4eed8e46f055b88f6a9183d1
Use modifier flag for events
===================================================================
M source/blender/editors/animation/anim_markers.c
M source/blender/editors/armature/pose_edit.c
M source/blender/editors/curve/editfont.c
M source/blender/editors/gpencil/annotate_paint.c
M source/blender/editors/gpencil/gpencil_fill.c
M source/blender/editors/gpencil/gpencil_paint.c
M source/blender/editors/gpencil/gpencil_primitive.c
M source/blender/editors/gpencil/gpencil_sculpt_paint.c
M source/blender/editors/gpencil/gpencil_select.c
M source/blender/editors/gpencil/gpencil_vertex_paint.c
M source/blender/editors/gpencil/gpencil_weight_paint.c
M source/blender/editors/interface/interface_eyedropper_gpencil_color.c
M source/blender/editors/interface/interface_handlers.c
M source/blender/editors/interface/interface_layout.c
M source/blender/editors/interface/interface_panel.c
M source/blender/editors/interface/interface_query.c
M source/blender/editors/interface/interface_region_tooltip.c
M source/blender/editors/interface/interface_templates.c
M source/blender/editors/mesh/editmesh_bevel.c
M source/blender/editors/mesh/editmesh_loopcut.c
M source/blender/editors/mesh/editmesh_select.c
M source/blender/editors/object/object_edit.c
M source/blender/editors/object/object_remesh.cc
M source/blender/editors/object/object_transform.c
M source/blender/editors/physics/particle_edit.c
M source/blender/editors/sculpt_paint/paint_stroke.c
M source/blender/editors/sculpt_paint/sculpt_mask_expand.c
M source/blender/editors/space_action/action_data.c
M source/blender/editors/space_buttons/buttons_ops.c
M source/blender/editors/space_console/console_ops.c
M source/blender/editors/space_nla/nla_channels.c
M source/blender/editors/space_outliner/outliner_collections.cc
M source/blender/editors/space_outliner/outliner_dragdrop.cc
M source/blender/editors/space_outliner/outliner_draw.cc
M source/blender/editors/space_text/text_autocomplete.c
M source/blender/editors/space_text/text_ops.c
M source/blender/editors/space_view3d/view3d_cursor_snap.c
M source/blender/editors/space_view3d/view3d_gizmo_preselect_type.c
M source/blender/editors/transform/transform.c
M source/blender/editors/transform/transform_gizmo_3d.c
M source/blender/editors/util/numinput.c
M source/blender/editors/uvedit/uvedit_smart_stitch.c
M source/blender/makesrna/intern/rna_wm.c
M source/blender/makesrna/intern/rna_wm_api.c
M source/blender/windowmanager/WM_api.h
M source/blender/windowmanager/WM_types.h
M source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c
M source/blender/windowmanager/intern/wm_event_query.c
M source/blender/windowmanager/intern/wm_event_system.c
M source/blender/windowmanager/intern/wm_operator_utils.c
M source/blender/windowmanager/intern/wm_operators.c
M source/blender/windowmanager/intern/wm_window.c
M source/blender/windowmanager/wm_event_types.h
===================================================================
diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c
index 9566402ad85..ab51702d628 100644
--- a/source/blender/editors/animation/anim_markers.c
+++ b/source/blender/editors/animation/anim_markers.c
@@ -960,7 +960,13 @@ static int ed_marker_move_modal(bContext *C, wmOperator *op, const wmEvent *even
mm->evtx = event->xy[0];
fac = ((float)(event->xy[0] - mm->firstx) * dx);
- apply_keyb_grid(event->shift, event->ctrl, &fac, 0.0, FPS, 0.1 * FPS, 0);
+ apply_keyb_grid((event->modifier & KM_SHIFT) != 0,
+ (event->modifier & KM_CTRL) != 0,
+ &fac,
+ 0.0,
+ FPS,
+ 0.1 * FPS,
+ 0);
RNA_int_set(op->ptr, "frames", (int)fac);
ed_marker_move_apply(C, op);
diff --git a/source/blender/editors/armature/pose_edit.c b/source/blender/editors/armature/pose_edit.c
index e227e69f9e1..13abcefa632 100644
--- a/source/blender/editors/armature/pose_edit.c
+++ b/source/blender/editors/armature/pose_edit.c
@@ -427,7 +427,7 @@ static int pose_clear_paths_exec(bContext *C, wmOperator *op)
/* operator callback/wrapper */
static int pose_clear_paths_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
- if ((event->shift) && !RNA_struct_property_is_set(op->ptr, "only_selected")) {
+ if ((event->modifier & KM_SHIFT) && !RNA_struct_property_is_set(op->ptr, "only_selected")) {
RNA_boolean_set(op->ptr, "only_selected", true);
}
return pose_clear_paths_exec(C, op);
diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c
index 3179aa50c35..02c7f3856e8 100644
--- a/source/blender/editors/curve/editfont.c
+++ b/source/blender/editors/curve/editfont.c
@@ -1640,7 +1640,9 @@ static int insert_text_invoke(bContext *C, wmOperator *op, const wmEvent *event)
EditFont *ef = cu->editfont;
static int accentcode = 0;
uintptr_t ascii = event->ascii;
- const bool alt = event->alt, shift = event->shift, ctrl = event->ctrl;
+ const bool alt = event->modifier & KM_ALT;
+ const bool shift = event->modifier & KM_SHIFT;
+ const bool ctrl = event->modifier & KM_CTRL;
int event_type = event->type, event_val = event->val;
char32_t inserted_text[2] = {0};
diff --git a/source/blender/editors/gpencil/annotate_paint.c b/source/blender/editors/gpencil/annotate_paint.c
index 163b5657326..b40dda146dc 100644
--- a/source/blender/editors/gpencil/annotate_paint.c
+++ b/source/blender/editors/gpencil/annotate_paint.c
@@ -2060,7 +2060,7 @@ static void annotation_draw_apply_event(
p->mval[1] = (float)event->mval[1] - y;
/* Key to toggle stabilization. */
- if (event->shift && p->paintmode == GP_PAINTMODE_DRAW) {
+ if ((event->modifier & KM_SHIFT) && (p->paintmode == GP_PAINTMODE_DRAW)) {
/* Using permanent stabilization, shift will deactivate the flag. */
if (p->flags & GP_PAINTFLAG_USE_STABILIZER) {
if (p->flags & GP_PAINTFLAG_USE_STABILIZER_TEMP) {
@@ -2075,7 +2075,7 @@ static void annotation_draw_apply_event(
}
}
/* verify key status for straight lines */
- else if (event->ctrl || event->alt) {
+ else if (event->modifier & (KM_CTRL | KM_ALT)) {
if (p->straight[0] == 0) {
int dx = abs((int)(p->mval[0] - p->mvalo[0]));
int dy = abs((int)(p->mval[1] - p->mvalo[1]));
@@ -2299,7 +2299,7 @@ static int annotation_draw_invoke(bContext *C, wmOperator *op, const wmEvent *ev
p->flags |= GP_PAINTFLAG_USE_STABILIZER | GP_PAINTFLAG_USE_STABILIZER_TEMP;
annotation_draw_toggle_stabilizer_cursor(p, true);
}
- else if (event->shift) {
+ else if (event->modifier & KM_SHIFT) {
p->flags |= GP_PAINTFLAG_USE_STABILIZER_TEMP;
annotation_draw_toggle_stabilizer_cursor(p, true);
}
diff --git a/source/blender/editors/gpencil/gpencil_fill.c b/source/blender/editors/gpencil/gpencil_fill.c
index 8e5161b3245..32dc086099c 100644
--- a/source/blender/editors/gpencil/gpencil_fill.c
+++ b/source/blender/editors/gpencil/gpencil_fill.c
@@ -2172,7 +2172,8 @@ static int gpencil_fill_modal(bContext *C, wmOperator *op, const wmEvent *event)
tgpf->on_back = RNA_boolean_get(op->ptr, "on_back");
const bool is_brush_inv = brush_settings->fill_direction == BRUSH_DIR_IN;
- const bool is_inverted = (is_brush_inv && !event->ctrl) || (!is_brush_inv && event->ctrl);
+ const bool is_inverted = (is_brush_inv && (event->modifier & KM_CTRL) == 0) ||
+ (!is_brush_inv && (event->modifier & KM_CTRL) != 0);
const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(tgpf->gpd);
const bool do_extend = (tgpf->fill_extend_fac > 0.0f);
const bool help_lines = ((tgpf->flag & GP_BRUSH_FILL_SHOW_HELPLINES) ||
@@ -2313,7 +2314,7 @@ static int gpencil_fill_modal(bContext *C, wmOperator *op, const wmEvent *event)
case EVT_PAGEUPKEY:
case WHEELUPMOUSE:
if (tgpf->oldkey == 1) {
- tgpf->fill_extend_fac -= (event->shift) ? 0.01f : 0.1f;
+ tgpf->fill_extend_fac -= (event->modifier & KM_SHIFT) ? 0.01f : 0.1f;
CLAMP_MIN(tgpf->fill_extend_fac, 0.0f);
gpencil_update_extend(tgpf);
}
@@ -2321,7 +2322,7 @@ static int gpencil_fill_modal(bContext *C, wmOperator *op, const wmEvent *event)
case EVT_PAGEDOWNKEY:
case WHEELDOWNMOUSE:
if (tgpf->oldkey == 1) {
- tgpf->fill_extend_fac += (event->shift) ? 0.01f : 0.1f;
+ tgpf->fill_extend_fac += (event->modifier & KM_SHIFT) ? 0.01f : 0.1f;
CLAMP_MAX(tgpf->fill_extend_fac, 100.0f);
gpencil_update_extend(tgpf);
}
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index a6691a12505..9442b2edc13 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -235,7 +235,7 @@ typedef struct tGPsdata {
/** key used for invoking the operator */
short keymodifier;
/** shift modifier flag */
- short shift;
+ bool shift;
/** size in pixels for uv calculation */
float totpixlen;
/** Special mode for fill brush. */
@@ -2841,11 +2841,11 @@ static void gpencil_draw_apply_event(bContext *C,
* add any x,y override position
*/
copy_v2fl_v2i(p->mval, event->mval);
- p->shift = event->shift;
+ p->shift = (event->modifier & KM_SHIFT) != 0;
/* verify direction for straight lines and guides */
if ((is_speed_guide) ||
- (event->alt && (RNA_boolean_get(op->ptr, "disable_straight") == false))) {
+ ((event->modifier & KM_ALT) && (RNA_boolean_get(op->ptr, "disable_straight") == false))) {
if (p->straight == 0) {
int dx = (int)fabsf(p->mval[0] - p->mvali[0]);
int dy = (int)fabsf(p->mval[1] - p->mvali[1]);
@@ -2886,13 +2886,13 @@ static void gpencil_draw_apply_event(bContext *C,
/* special eraser modes */
if (p->paintmode == GP_PAINTMODE_ERASER) {
- if (event->shift) {
+ if (event->modifier & KM_SHIFT) {
p->flags |= GP_PAINTFLAG_HARD_ERASER;
}
else {
p->flags &= ~GP_PAINTFLAG_HARD_ERASER;
}
- if (event->alt) {
+ if (event->modifier & KM_ALT) {
p->flags |= GP_PAINTFLAG_STROKE_ERASER;
}
else {
@@ -3116,11 +3116,11 @@ static void gpencil_guide_event_handling(bContext *C,
else if ((event->type == EVT_LKEY) && (event->val == KM_RELEASE)) {
add_notifier = true;
guide->use_guide = true;
- if (event->ctrl) {
+ if (event->modifier & KM_CTRL) {
guide->angle = 0.0f;
guide->type = GP_GUIDE_PARALLEL;
}
- else if (event->alt) {
+ else if (event->modifier & KM_ALT) {
guide->type = GP_GUIDE_PARALLEL;
guide->angle = RNA_float_get(op->ptr, "guide_last_angle");
}
@@ -3150,10 +3150,10 @@ static void gpencil_guide_event_handling(bContext *C,
add_notifier = true;
float angle = guide->angle;
float adjust = (float)M_PI / 180.0f;
- if (event->alt) {
+ if (event->modifier & KM_ALT) {
adjust *= 45.0f;
}
- else if (!event->shift) {
+ else if ((event->modifier & KM_SHIFT) == 0) {
adjust *= 15.0f;
}
angle += (event->type == EVT_JKEY) ? adjust : -adjust;
@@ -3633,7 +3633,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
*/
}
else if (event->type == EVT_ZKEY) {
- if (event->ctrl) {
+ if (event->modifier & KM_CTRL) {
p->status = GP_STATUS_DONE;
estate = OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/gpencil/gpencil_primitive.c b/source/blender/editors/gpencil/gpencil_primitive.c
index 2d761dd6c91..57a184b0e8d 100644
--- a/source/blender/editors/gpencil/gpencil_primitive.c
+++ b/source/blender/editors/gpencil/gpencil_primitive.c
@@ -1494,7 +1494,7 @@ static void gpencil_primitive_edit_event_handling(
float dy = (tgpi->mval[1] - tgpi->mvalo[1]);
tgpi->cp1[0] += dx;
tgpi->cp1[1] += dy;
- if (event->shift) {
+ if (event->modifier & KM_SHIFT) {
copy_v2_v2(tgpi->cp2, tgpi->cp1);
}
}
@@ -1503,7 +1503,7 @@ static void gpencil_primitive_edit_event_handling(
float dy = (tgpi->mval[1] - tgpi->mvalo[1]);
tgpi->cp2[0] += dx;
tgpi->cp2[1] += dy;
- if (event->shift) {
+ if (event->modifier & KM_SHIFT) {
copy_v2_v2(tgpi->cp1, tgpi->cp2);
}
}
@@ -1692,7 +1692,7 @@ static int gpencil_primitive_modal(bContext *C, wmOperator *op, const wmEvent *e
WM_cursor_modal_set(win, WM_CURSOR_NSEW_SCROLL);
copy_v2_v2(tgpi->end, tgpi->mval);
- if (event->shift) {
+ if (event->modifier & KM_SHIFT) {
gpencil_primitive_constrain(tgpi, true);
}
@@ -1722,7 +1722,7 @@ static int gpencil_primitive_modal(bContext *C, wmOperator *op, const wmEvent *e
case EVT_FKEY: /* brush thickness/ brush strength */
{
if ((event->val == KM_PRESS)) {
- if (event->shift) {
+ if (event->modifier & KM_SHIFT) {
tgpi-
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list