diff options
author | Campbell Barton <ideasman42@gmail.com> | 2017-12-18 08:06:32 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2017-12-19 04:46:36 +0300 |
commit | 12bc63a0fee0bf88595ffc823ad00beb22c32b7a (patch) | |
tree | 3a4582525f83faa682b836fbfecbffdf924b3625 /source/blender/windowmanager | |
parent | 02abb17ae2d86a2639b43373a8be72b6e044de20 (diff) |
Manipulaor: de-duplicate finish call
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r-- | source/blender/windowmanager/manipulators/intern/wm_manipulator_group.c | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulator_group.c b/source/blender/windowmanager/manipulators/intern/wm_manipulator_group.c index ebb5d835455..edf10afad8c 100644 --- a/source/blender/windowmanager/manipulators/intern/wm_manipulator_group.c +++ b/source/blender/windowmanager/manipulators/intern/wm_manipulator_group.c @@ -323,6 +323,7 @@ static int manipulator_tweak_modal(bContext *C, wmOperator *op, const wmEvent *e { ManipulatorTweakData *mtweak = op->customdata; wmManipulator *mpr = mtweak->mpr_modal; + int retval = OPERATOR_PASS_THROUGH; if (mpr == NULL) { BLI_assert(0); @@ -330,20 +331,16 @@ static int manipulator_tweak_modal(bContext *C, wmOperator *op, const wmEvent *e } if (event->type == mtweak->init_event && event->val == KM_RELEASE) { - manipulator_tweak_finish(C, op, false); - return OPERATOR_FINISHED; + retval = OPERATOR_FINISHED; } - - - if (event->type == EVT_MODAL_MAP) { + else if (event->type == EVT_MODAL_MAP) { switch (event->val) { case TWEAK_MODAL_CANCEL: - manipulator_tweak_finish(C, op, true); - return OPERATOR_CANCELLED; + retval = OPERATOR_CANCELLED; + break; case TWEAK_MODAL_CONFIRM: - manipulator_tweak_finish(C, op, false); - return OPERATOR_FINISHED; - + retval = OPERATOR_FINISHED; + break; case TWEAK_MODAL_PRECISION_ON: mtweak->flag |= WM_MANIPULATOR_TWEAK_PRECISE; break; @@ -360,20 +357,28 @@ static int manipulator_tweak_modal(bContext *C, wmOperator *op, const wmEvent *e } } + if (retval != OPERATOR_PASS_THROUGH) { + manipulator_tweak_finish(C, op, retval != OPERATOR_FINISHED); + return retval; + } + /* handle manipulator */ wmManipulatorFnModal modal_fn = mpr->custom_modal ? mpr->custom_modal : mpr->type->modal; - int retval = modal_fn(C, mpr, event, mtweak->flag); + if (modal_fn) { + int modal_retval = modal_fn(C, mpr, event, mtweak->flag); - if ((retval & OPERATOR_RUNNING_MODAL) == 0) { - manipulator_tweak_finish(C, op, (retval & OPERATOR_CANCELLED) != 0); - return OPERATOR_FINISHED; - } + if ((modal_retval & OPERATOR_RUNNING_MODAL) == 0) { + manipulator_tweak_finish(C, op, (modal_retval & OPERATOR_CANCELLED) != 0); + return OPERATOR_FINISHED; + } - /* Ugly hack to send manipulator events */ - ((wmEvent *)event)->type = EVT_MANIPULATOR_UPDATE; + /* Ugly hack to send manipulator events */ + ((wmEvent *)event)->type = EVT_MANIPULATOR_UPDATE; + } /* always return PASS_THROUGH so modal handlers * with manipulators attached can update */ + BLI_assert(retval == OPERATOR_PASS_THROUGH); return OPERATOR_PASS_THROUGH; } |