diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-09-20 05:43:06 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-09-20 05:43:06 +0400 |
commit | d783cbbd846e29cc400bc0f500e8b7bfedafef35 (patch) | |
tree | bea95b3f4d0b2b110ac30fee0f1acdb2df664127 /source/blender | |
parent | 9d8a6b493b400b224aadc4878699cf4fbc10f8a5 (diff) |
replace VIEW3D_OP_OFS_LOCK_TEST() macro with static function view3d_operator_offset_lock_check()
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/space_view3d/view3d_edit.c | 46 |
1 files changed, 24 insertions, 22 deletions
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index bf0f38d9ae6..005bb5940bc 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -85,26 +85,23 @@ /* for ndof prints */ // #define DEBUG_NDOF_MOTION -static void view3d_offset_lock_report(ReportList *reports) -{ - BKE_report(reports, RPT_WARNING, "View offset is locked"); -} - bool ED_view3d_offset_lock_check(struct View3D *v3d, struct RegionView3D *rv3d) { return (rv3d->persp != RV3D_CAMOB) && (v3d->ob_centre_cursor || v3d->ob_centre); } -#define VIEW3D_OP_OFS_LOCK_TEST(C, op) \ - { \ - View3D *v3d_tmp = CTX_wm_view3d(C); \ - RegionView3D *rv3d_tmp = CTX_wm_region_view3d(C); \ - if (ED_view3d_offset_lock_check(v3d_tmp, rv3d_tmp)) { \ - view3d_offset_lock_report((op)->reports); \ - return OPERATOR_CANCELLED; \ - } \ - } (void)0 - +static bool view3d_operator_offset_lock_check(bContext *C, wmOperator *op) +{ + View3D *v3d = CTX_wm_view3d(C); + RegionView3D *rv3d = CTX_wm_region_view3d(C); + if (ED_view3d_offset_lock_check(v3d, rv3d)) { + BKE_report(op->reports, RPT_WARNING, "View offset is locked"); + return true; + } + else { + return false; + } +} /* ********************** view3d_edit: view manipulations ********************* */ @@ -1191,8 +1188,9 @@ static void view3d_ndof_orbit(const struct wmNDOFMotionData *ndof, RegionView3D static int ndof_orbit_invoke(bContext *C, wmOperator *op, const wmEvent *event) { - if (event->type != NDOF_MOTION) + if (event->type != NDOF_MOTION) { return OPERATOR_CANCELLED; + } else { View3D *v3d = CTX_wm_view3d(C); ViewOpsData *vod; @@ -1274,8 +1272,9 @@ void VIEW3D_OT_ndof_orbit(struct wmOperatorType *ot) static int ndof_orbit_zoom_invoke(bContext *C, wmOperator *op, const wmEvent *event) { - if (event->type != NDOF_MOTION) + if (event->type != NDOF_MOTION) { return OPERATOR_CANCELLED; + } else { ViewOpsData *vod; View3D *v3d = CTX_wm_view3d(C); @@ -1372,14 +1371,16 @@ void VIEW3D_OT_ndof_orbit_zoom(struct wmOperatorType *ot) */ static int ndof_pan_invoke(bContext *C, wmOperator *op, const wmEvent *event) { - if (event->type != NDOF_MOTION) + if (event->type != NDOF_MOTION) { return OPERATOR_CANCELLED; + } else { View3D *v3d = CTX_wm_view3d(C); RegionView3D *rv3d = CTX_wm_region_view3d(C); wmNDOFMotionData *ndof = (wmNDOFMotionData *) event->customdata; - VIEW3D_OP_OFS_LOCK_TEST(C, op); + if (view3d_operator_offset_lock_check(C, op)) + return OPERATOR_CANCELLED; ED_view3d_camera_lock_init(v3d, rv3d); @@ -1472,7 +1473,6 @@ static int ndof_all_invoke(bContext *C, wmOperator *op, const wmEvent *event) return OPERATOR_CANCELLED; } else { - ViewOpsData *vod; RegionView3D *rv3d; @@ -2260,7 +2260,8 @@ static int viewdolly_invoke(bContext *C, wmOperator *op, const wmEvent *event) { ViewOpsData *vod; - VIEW3D_OP_OFS_LOCK_TEST(C, op); + if (view3d_operator_offset_lock_check(C, op)) + return OPERATOR_CANCELLED; /* makes op->customdata */ viewops_data_alloc(C, op); @@ -3819,7 +3820,8 @@ static int viewpan_exec(bContext *C, wmOperator *op) float zfac; int pandir; - VIEW3D_OP_OFS_LOCK_TEST(C, op); + if (view3d_operator_offset_lock_check(C, op)) + return OPERATOR_CANCELLED; pandir = RNA_enum_get(op->ptr, "type"); |