diff options
author | Campbell Barton <ideasman42@gmail.com> | 2017-08-24 10:04:28 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2017-08-24 10:04:28 +0300 |
commit | e20c825b05e00954995fe2ed74e7fb409d09abe8 (patch) | |
tree | 4491775682a618cb6e2e902bfe4ec61d72966d7b /source/blender/editors/manipulator_library/manipulator_types | |
parent | 134e927965c9871df8a9e13806f1cd48f4d43f16 (diff) |
Manipulator: modal callback can now cancel & pass events
Re-use operator return flags for manipulator modal & invoke,
this means manipulators can allow navigation or other events to be
handled as they run - see T52499
Diffstat (limited to 'source/blender/editors/manipulator_library/manipulator_types')
6 files changed, 33 insertions, 14 deletions
diff --git a/source/blender/editors/manipulator_library/manipulator_types/arrow2d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/arrow2d_manipulator.c index 1185bec2a2d..67583d28668 100644 --- a/source/blender/editors/manipulator_library/manipulator_types/arrow2d_manipulator.c +++ b/source/blender/editors/manipulator_library/manipulator_types/arrow2d_manipulator.c @@ -123,7 +123,7 @@ static void manipulator_arrow2d_setup(wmManipulator *mpr) mpr->flag |= WM_MANIPULATOR_DRAW_MODAL; } -static void manipulator_arrow2d_invoke( +static int manipulator_arrow2d_invoke( bContext *UNUSED(C), wmManipulator *mpr, const wmEvent *UNUSED(event)) { ManipulatorInteraction *inter = MEM_callocN(sizeof(ManipulatorInteraction), __func__); @@ -132,6 +132,8 @@ static void manipulator_arrow2d_invoke( WM_manipulator_calc_matrix_final(mpr, inter->init_matrix_final); mpr->interaction_data = inter; + + return OPERATOR_RUNNING_MODAL; } static int manipulator_arrow2d_test_select( diff --git a/source/blender/editors/manipulator_library/manipulator_types/arrow3d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/arrow3d_manipulator.c index 61f5a7b2786..5c984de2e27 100644 --- a/source/blender/editors/manipulator_library/manipulator_types/arrow3d_manipulator.c +++ b/source/blender/editors/manipulator_library/manipulator_types/arrow3d_manipulator.c @@ -235,7 +235,7 @@ static void manipulator_arrow_draw(const bContext *UNUSED(C), wmManipulator *mpr * Calculate arrow offset independent from prop min value, * meaning the range will not be offset by min value first. */ -static void manipulator_arrow_modal( +static int manipulator_arrow_modal( bContext *C, wmManipulator *mpr, const wmEvent *event, eWM_ManipulatorTweak tweak_flag) { @@ -352,6 +352,8 @@ static void manipulator_arrow_modal( /* tag the region for redraw */ ED_region_tag_redraw(ar); WM_event_add_mousemove(C); + + return OPERATOR_RUNNING_MODAL; } static void manipulator_arrow_setup(wmManipulator *mpr) @@ -363,7 +365,7 @@ static void manipulator_arrow_setup(wmManipulator *mpr) arrow->data.range_fac = 1.0f; } -static void manipulator_arrow_invoke( +static int manipulator_arrow_invoke( bContext *UNUSED(C), wmManipulator *mpr, const wmEvent *event) { ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr; @@ -384,6 +386,8 @@ static void manipulator_arrow_invoke( WM_manipulator_calc_matrix_final(mpr, inter->init_matrix_final); mpr->interaction_data = inter; + + return OPERATOR_RUNNING_MODAL; } static void manipulator_arrow_property_update(wmManipulator *mpr, wmManipulatorProperty *mpr_prop) diff --git a/source/blender/editors/manipulator_library/manipulator_types/cage2d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/cage2d_manipulator.c index 40ef5f48492..311c8acde9e 100644 --- a/source/blender/editors/manipulator_library/manipulator_types/cage2d_manipulator.c +++ b/source/blender/editors/manipulator_library/manipulator_types/cage2d_manipulator.c @@ -479,7 +479,7 @@ static void manipulator_rect_transform_setup(wmManipulator *mpr) mpr->flag |= WM_MANIPULATOR_DRAW_MODAL; } -static void manipulator_rect_transform_invoke( +static int manipulator_rect_transform_invoke( bContext *C, wmManipulator *mpr, const wmEvent *event) { RectTransformInteraction *data = MEM_callocN(sizeof(RectTransformInteraction), "cage_interaction"); @@ -493,9 +493,11 @@ static void manipulator_rect_transform_invoke( } mpr->interaction_data = data; + + return OPERATOR_RUNNING_MODAL; } -static void manipulator_rect_transform_modal( +static int manipulator_rect_transform_modal( bContext *C, wmManipulator *mpr, const wmEvent *event, eWM_ManipulatorTweak UNUSED(tweak_flag)) { @@ -514,7 +516,7 @@ static void manipulator_rect_transform_modal( if (manipulator_window_project_2d( C, mpr, (const float[2]){UNPACK2(event->mval)}, 2, false, point_local) == false) { - return; + return OPERATOR_RUNNING_MODAL; } float value_x = (point_local[0] - data->orig_mouse[0]); @@ -636,6 +638,8 @@ static void manipulator_rect_transform_modal( /* tag the region for redraw */ ED_region_tag_redraw(CTX_wm_region(C)); + + return OPERATOR_RUNNING_MODAL; } static void manipulator_rect_transform_property_update(wmManipulator *mpr, wmManipulatorProperty *mpr_prop) diff --git a/source/blender/editors/manipulator_library/manipulator_types/dial3d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/dial3d_manipulator.c index f7511c581ed..257ccfa88d8 100644 --- a/source/blender/editors/manipulator_library/manipulator_types/dial3d_manipulator.c +++ b/source/blender/editors/manipulator_library/manipulator_types/dial3d_manipulator.c @@ -71,7 +71,7 @@ /* to use custom dials exported to geom_dial_manipulator.c */ // #define USE_MANIPULATOR_CUSTOM_DIAL -static void manipulator_dial_modal( +static int manipulator_dial_modal( bContext *C, wmManipulator *mpr, const wmEvent *event, eWM_ManipulatorTweak tweak_flag); @@ -384,7 +384,7 @@ static void manipulator_dial_draw(const bContext *C, wmManipulator *mpr) } } -static void manipulator_dial_modal( +static int manipulator_dial_modal( bContext *C, wmManipulator *mpr, const wmEvent *event, eWM_ManipulatorTweak UNUSED(tweak_flag)) { @@ -408,6 +408,7 @@ static void manipulator_dial_modal( if (WM_manipulator_target_property_is_valid(mpr_prop)) { WM_manipulator_target_property_value_set(C, mpr, mpr_prop, inter->init_prop_angle + angle_delta); } + return OPERATOR_RUNNING_MODAL; } @@ -419,7 +420,7 @@ static void manipulator_dial_setup(wmManipulator *mpr) copy_v3_v3(mpr->matrix_basis[2], dir_default); } -static void manipulator_dial_invoke( +static int manipulator_dial_invoke( bContext *UNUSED(C), wmManipulator *mpr, const wmEvent *event) { DialInteraction *inter = MEM_callocN(sizeof(DialInteraction), __func__); @@ -433,6 +434,8 @@ static void manipulator_dial_invoke( } mpr->interaction_data = inter; + + return OPERATOR_RUNNING_MODAL; } /* -------------------------------------------------------------------- */ diff --git a/source/blender/editors/manipulator_library/manipulator_types/grab3d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/grab3d_manipulator.c index 38e350762c1..a714dd0f061 100644 --- a/source/blender/editors/manipulator_library/manipulator_types/grab3d_manipulator.c +++ b/source/blender/editors/manipulator_library/manipulator_types/grab3d_manipulator.c @@ -77,7 +77,7 @@ static void manipulator_grab_matrix_basis_get(const wmManipulator *mpr, float r_ add_v3_v3(r_matrix[3], grab->prop_co); } -static void manipulator_grab_modal( +static int manipulator_grab_modal( bContext *C, wmManipulator *mpr, const wmEvent *event, eWM_ManipulatorTweak tweak_flag); @@ -236,7 +236,7 @@ static void manipulator_grab_draw(const bContext *C, wmManipulator *mpr) glDisable(GL_BLEND); } -static void manipulator_grab_modal( +static int manipulator_grab_modal( bContext *C, wmManipulator *mpr, const wmEvent *event, eWM_ManipulatorTweak UNUSED(tweak_flag)) { @@ -255,7 +255,7 @@ static void manipulator_grab_modal( (manipulator_window_project_2d( C, mpr, (const float[2]){UNPACK2(event->mval)}, 2, false, mval_proj_curr) == false)) { - return; + return OPERATOR_RUNNING_MODAL; } sub_v2_v2v2(prop_delta, mval_proj_curr, mval_proj_init); prop_delta[2] = 0.0f; @@ -269,9 +269,11 @@ static void manipulator_grab_modal( } ED_region_tag_redraw(ar); + + return OPERATOR_RUNNING_MODAL; } -static void manipulator_grab_invoke( +static int manipulator_grab_invoke( bContext *UNUSED(C), wmManipulator *mpr, const wmEvent *event) { GrabInteraction *inter = MEM_callocN(sizeof(GrabInteraction), __func__); @@ -298,6 +300,8 @@ static void manipulator_grab_invoke( } mpr->interaction_data = inter; + + return OPERATOR_RUNNING_MODAL; } diff --git a/source/blender/editors/manipulator_library/manipulator_types/primitive3d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/primitive3d_manipulator.c index 44878a24430..eea14f2033f 100644 --- a/source/blender/editors/manipulator_library/manipulator_types/primitive3d_manipulator.c +++ b/source/blender/editors/manipulator_library/manipulator_types/primitive3d_manipulator.c @@ -145,7 +145,7 @@ static void manipulator_primitive_setup(wmManipulator *mpr) mpr->flag |= WM_MANIPULATOR_DRAW_MODAL; } -static void manipulator_primitive_invoke( +static int manipulator_primitive_invoke( bContext *UNUSED(C), wmManipulator *mpr, const wmEvent *UNUSED(event)) { ManipulatorInteraction *inter = MEM_callocN(sizeof(ManipulatorInteraction), __func__); @@ -153,6 +153,8 @@ static void manipulator_primitive_invoke( WM_manipulator_calc_matrix_final(mpr, inter->init_matrix_final); mpr->interaction_data = inter; + + return OPERATOR_RUNNING_MODAL; } /* -------------------------------------------------------------------- */ |