From 631cc5d56ee9445ece0a9982ed58b1de1dcbbe5b Mon Sep 17 00:00:00 2001 From: Juanfran Matheu Date: Fri, 12 Feb 2021 16:45:29 +1100 Subject: WM: Add 'Confirm On Release' option for WM_OT_radial_control Adds a new property called "Confirm On Release" that does what it says, confirm the action without having to do left-click or to press any other extra-key which concludes in a more dynamic and efficient way of changing brush size or strength for example, especially for tablet users. Reviewed By: campbellbarton Ref D10233 --- source/blender/windowmanager/intern/wm_operators.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'source/blender/windowmanager/intern/wm_operators.c') diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index e82f6cc9d76..297575e8dff 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -2087,6 +2087,7 @@ typedef struct { bool use_secondary_tex; void *cursor; NumInput num_input; + int init_event; } RadialControl; static void radial_control_update_header(wmOperator *op, bContext *C) @@ -2705,6 +2706,8 @@ static int radial_control_invoke(bContext *C, wmOperator *op, const wmEvent *eve radial_control_set_initial_mouse(rc, event); radial_control_set_tex(rc); + rc->init_event = WM_userdef_event_type_from_keymap_type(event->type); + /* temporarily disable other paint cursors */ wm = CTX_wm_manager(C); rc->orig_paintcursors = wm->paintcursors; @@ -2962,6 +2965,11 @@ static int radial_control_modal(bContext *C, wmOperator *op, const wmEvent *even return OPERATOR_RUNNING_MODAL; } + if (!handled && (event->val == KM_RELEASE) && (rc->init_event == event->type) && + RNA_boolean_get(op->ptr, "release_confirm")) { + ret = OPERATOR_FINISHED; + } + ED_region_tag_redraw(CTX_wm_region(C)); radial_control_update_header(op, C); @@ -3070,6 +3078,10 @@ static void WM_OT_radial_control(wmOperatorType *ot) prop = RNA_def_boolean( ot->srna, "secondary_tex", false, "Secondary Texture", "Tweak brush secondary/mask texture"); RNA_def_property_flag(prop, PROP_SKIP_SAVE); + + prop = RNA_def_boolean( + ot->srna, "release_confirm", false, "Confirm On Release", "Finish operation on key release"); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); } /** \} */ -- cgit v1.2.3