diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-01-16 10:08:21 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-01-16 10:14:11 +0300 |
commit | 2346e0850fdee44ad13fc5964fac58aee453e37a (patch) | |
tree | 030b739006af9762c439481932e989e682a9ccb5 | |
parent | fd80b83e8e5850d34dcddea44d80547c3685c344 (diff) |
Ruler Manipulator: dragging out of the view removes
Not ideal, but means we don't need to override Delete key.
-rw-r--r-- | source/blender/editors/space_view3d/view3d_manipulator_ruler.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/source/blender/editors/space_view3d/view3d_manipulator_ruler.c b/source/blender/editors/space_view3d/view3d_manipulator_ruler.c index 230b4f44c16..bda692a0e5c 100644 --- a/source/blender/editors/space_view3d/view3d_manipulator_ruler.c +++ b/source/blender/editors/space_view3d/view3d_manipulator_ruler.c @@ -148,6 +148,11 @@ static RulerItem *ruler_item_add(wmManipulatorGroup *mgroup) return ruler_item; } +static void ruler_item_remove(bContext *C, wmManipulatorGroup *mgroup, RulerItem *ruler_item) +{ + WM_manipulator_unlink(&mgroup->manipulators, mgroup->parent_mmap, &ruler_item->mpr, C); +} + static void ruler_item_as_string(RulerItem *ruler_item, UnitSettings *unit, char *numstr, size_t numstr_size, int prec) { @@ -908,16 +913,24 @@ static void manipulator_ruler_exit(bContext *C, wmManipulator *mpr, const bool c { wmManipulatorGroup *mgroup = mpr->parent_mgroup; RulerInfo *ruler_info = mgroup->customdata; - RulerItem *ruler_item = (RulerItem *)mpr; - RulerInteraction *inter = mpr->interaction_data; if (!cancel) { if (ruler_info->state == RULER_STATE_DRAG) { + RulerItem *ruler_item = (RulerItem *)mpr; + RulerInteraction *inter = mpr->interaction_data; /* rubber-band angle removal */ - if (ruler_item && (inter->co_index == 1) && (ruler_item->flag & RULERITEM_USE_ANGLE)) { - if (!inter->inside_region) { + if (!inter->inside_region) { + if ((inter->co_index == 1) && (ruler_item->flag & RULERITEM_USE_ANGLE)) { ruler_item->flag &= ~RULERITEM_USE_ANGLE; } + else { + /* Not ideal, since the ruler isn't a mode and we don't want to override delete key + * use dragging out of the view for removal. */ + ruler_item_remove(C, mgroup, ruler_item); + ruler_item = NULL; + mpr = NULL; + inter = NULL; + } } if (ruler_info->snap_flag & RULER_SNAP_OK) { ruler_info->snap_flag &= ~RULER_SNAP_OK; @@ -928,7 +941,9 @@ static void manipulator_ruler_exit(bContext *C, wmManipulator *mpr, const bool c view3d_ruler_to_gpencil(C, mgroup); } - MEM_SAFE_FREE(mpr->interaction_data); + if (mpr) { + MEM_SAFE_FREE(mpr->interaction_data); + } ruler_state_set(C, ruler_info, RULER_STATE_NORMAL); } |