diff --git a/source/blender/editors/space_view3d/view3d_navigate.cc b/source/blender/editors/space_view3d/view3d_navigate.cc index 84641c8e59f..856155a5d19 100644 --- a/source/blender/editors/space_view3d/view3d_navigate.cc +++ b/source/blender/editors/space_view3d/view3d_navigate.cc @@ -74,6 +74,18 @@ bool view3d_zoom_or_dolly_poll(bContext *C) /** \} */ +/* -------------------------------------------------------------------- */ +/** \name Generic Callbacks + * \{ */ + +void view3d_navigate_cancel_fn(bContext *C, wmOperator *op) +{ + viewops_data_free(C, (ViewOpsData *)op->customdata); + op->customdata = NULL; +} + +/** \} */ + /* -------------------------------------------------------------------- */ /** \name Generic View Operator Properties * \{ */ diff --git a/source/blender/editors/space_view3d/view3d_navigate.h b/source/blender/editors/space_view3d/view3d_navigate.h index 9087002dbdb..29e7264bb10 100644 --- a/source/blender/editors/space_view3d/view3d_navigate.h +++ b/source/blender/editors/space_view3d/view3d_navigate.h @@ -30,6 +30,7 @@ struct View3D; struct bContext; struct rcti; struct wmEvent; +struct wmOperator; enum eV3D_OpPropFlag { V3D_OP_PROP_MOUSE_CO = (1 << 0), @@ -158,6 +159,8 @@ bool view3d_location_poll(struct bContext *C); bool view3d_rotation_poll(struct bContext *C); bool view3d_zoom_or_dolly_poll(struct bContext *C); +void view3d_navigate_cancel_fn(struct bContext *C, struct wmOperator *op); + enum eViewOpsFlag viewops_flag_from_prefs(void); void calctrackballvec(const struct rcti *rect, const int event_xy[2], float r_dir[3]); void viewmove_apply(ViewOpsData *vod, int x, int y); diff --git a/source/blender/editors/space_view3d/view3d_navigate_dolly.c b/source/blender/editors/space_view3d/view3d_navigate_dolly.c index 682f8aa96a0..e27f035b02c 100644 --- a/source/blender/editors/space_view3d/view3d_navigate_dolly.c +++ b/source/blender/editors/space_view3d/view3d_navigate_dolly.c @@ -336,12 +336,6 @@ static int viewdolly_invoke(bContext *C, wmOperator *op, const wmEvent *event) return OPERATOR_FINISHED; } -static void viewdolly_cancel(bContext *C, wmOperator *op) -{ - viewops_data_free(C, op->customdata); - op->customdata = NULL; -} - void VIEW3D_OT_dolly(wmOperatorType *ot) { /* identifiers */ @@ -354,7 +348,7 @@ void VIEW3D_OT_dolly(wmOperatorType *ot) ot->exec = viewdolly_exec; ot->modal = viewdolly_modal; ot->poll = view3d_rotation_poll; - ot->cancel = viewdolly_cancel; + ot->cancel = view3d_navigate_cancel_fn; /* flags */ ot->flag = OPTYPE_BLOCKING | OPTYPE_GRAB_CURSOR_XY | OPTYPE_DEPENDS_ON_CURSOR; diff --git a/source/blender/editors/space_view3d/view3d_navigate_move.c b/source/blender/editors/space_view3d/view3d_navigate_move.c index f0a4200c224..29343793e45 100644 --- a/source/blender/editors/space_view3d/view3d_navigate_move.c +++ b/source/blender/editors/space_view3d/view3d_navigate_move.c @@ -203,12 +203,6 @@ static int viewmove_invoke(bContext *C, wmOperator *op, const wmEvent *event) return OPERATOR_RUNNING_MODAL; } -static void viewmove_cancel(bContext *C, wmOperator *op) -{ - viewops_data_free(C, op->customdata); - op->customdata = NULL; -} - void VIEW3D_OT_move(wmOperatorType *ot) { @@ -221,7 +215,7 @@ void VIEW3D_OT_move(wmOperatorType *ot) ot->invoke = viewmove_invoke; ot->modal = viewmove_modal; ot->poll = view3d_location_poll; - ot->cancel = viewmove_cancel; + ot->cancel = view3d_navigate_cancel_fn; /* flags */ ot->flag = OPTYPE_BLOCKING | OPTYPE_GRAB_CURSOR_XY; diff --git a/source/blender/editors/space_view3d/view3d_navigate_roll.c b/source/blender/editors/space_view3d/view3d_navigate_roll.c index 266fafaec9e..84a41a339f3 100644 --- a/source/blender/editors/space_view3d/view3d_navigate_roll.c +++ b/source/blender/editors/space_view3d/view3d_navigate_roll.c @@ -277,12 +277,6 @@ static int viewroll_invoke(bContext *C, wmOperator *op, const wmEvent *event) return OPERATOR_FINISHED; } -static void viewroll_cancel(bContext *C, wmOperator *op) -{ - viewops_data_free(C, op->customdata); - op->customdata = NULL; -} - void VIEW3D_OT_view_roll(wmOperatorType *ot) { PropertyRNA *prop; @@ -297,7 +291,7 @@ void VIEW3D_OT_view_roll(wmOperatorType *ot) ot->exec = viewroll_exec; ot->modal = viewroll_modal; ot->poll = ED_operator_rv3d_user_region_poll; - ot->cancel = viewroll_cancel; + ot->cancel = view3d_navigate_cancel_fn; /* flags */ ot->flag = 0; diff --git a/source/blender/editors/space_view3d/view3d_navigate_rotate.c b/source/blender/editors/space_view3d/view3d_navigate_rotate.c index b1971dda4e8..b7fee5538ab 100644 --- a/source/blender/editors/space_view3d/view3d_navigate_rotate.c +++ b/source/blender/editors/space_view3d/view3d_navigate_rotate.c @@ -464,12 +464,6 @@ static int viewrotate_invoke(bContext *C, wmOperator *op, const wmEvent *event) return OPERATOR_RUNNING_MODAL; } -static void viewrotate_cancel(bContext *C, wmOperator *op) -{ - viewops_data_free(C, op->customdata); - op->customdata = NULL; -} - void VIEW3D_OT_rotate(wmOperatorType *ot) { /* identifiers */ @@ -481,7 +475,7 @@ void VIEW3D_OT_rotate(wmOperatorType *ot) ot->invoke = viewrotate_invoke; ot->modal = viewrotate_modal; ot->poll = view3d_rotation_poll; - ot->cancel = viewrotate_cancel; + ot->cancel = view3d_navigate_cancel_fn; /* flags */ ot->flag = OPTYPE_BLOCKING | OPTYPE_GRAB_CURSOR_XY; diff --git a/source/blender/editors/space_view3d/view3d_navigate_zoom.c b/source/blender/editors/space_view3d/view3d_navigate_zoom.c index f766e4a454f..791e492a7cc 100644 --- a/source/blender/editors/space_view3d/view3d_navigate_zoom.c +++ b/source/blender/editors/space_view3d/view3d_navigate_zoom.c @@ -607,12 +607,6 @@ static int viewzoom_invoke(bContext *C, wmOperator *op, const wmEvent *event) return OPERATOR_FINISHED; } -static void viewzoom_cancel(bContext *C, wmOperator *op) -{ - viewops_data_free(C, op->customdata); - op->customdata = NULL; -} - void VIEW3D_OT_zoom(wmOperatorType *ot) { /* identifiers */ @@ -625,7 +619,7 @@ void VIEW3D_OT_zoom(wmOperatorType *ot) ot->exec = viewzoom_exec; ot->modal = viewzoom_modal; ot->poll = view3d_zoom_or_dolly_poll; - ot->cancel = viewzoom_cancel; + ot->cancel = view3d_navigate_cancel_fn; /* flags */ ot->flag = OPTYPE_BLOCKING | OPTYPE_GRAB_CURSOR_XY;