diff options
author | Campbell Barton <ideasman42@gmail.com> | 2017-10-28 08:07:56 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2017-10-30 06:26:57 +0300 |
commit | 689ad9ade42fbb03084aaca7e478efddbe891e7f (patch) | |
tree | c5838ab57c43d531b9dc0d014f4f63784cb3f214 | |
parent | ca495381c566b31ab8edc387dc7f21e9b5f90a5d (diff) |
Fix manipulator drawing before their refresh callback
Caused glitch with Scale-Cage tool.
3 files changed, 15 insertions, 6 deletions
diff --git a/source/blender/windowmanager/manipulators/WM_manipulator_types.h b/source/blender/windowmanager/manipulators/WM_manipulator_types.h index 22f1eb68181..d4477b8e508 100644 --- a/source/blender/windowmanager/manipulators/WM_manipulator_types.h +++ b/source/blender/windowmanager/manipulators/WM_manipulator_types.h @@ -109,6 +109,7 @@ typedef enum eWM_ManipulatorGroupTypeFlag { typedef enum eWM_ManipulatorGroupInitFlag { /* mgroup has been initialized */ WM_MANIPULATORGROUP_INIT_SETUP = (1 << 0), + WM_MANIPULATORGROUP_INIT_REFRESH = (1 << 1), } eWM_ManipulatorGroupInitFlag; /** diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulator_group.c b/source/blender/windowmanager/manipulators/intern/wm_manipulator_group.c index 24786695cba..e0b12289b9e 100644 --- a/source/blender/windowmanager/manipulators/intern/wm_manipulator_group.c +++ b/source/blender/windowmanager/manipulators/intern/wm_manipulator_group.c @@ -184,9 +184,16 @@ void wm_manipulatorgroup_ensure_initialized(wmManipulatorGroup *mgroup, const bC wm_manipulatorgrouptype_setup_keymap(wgt, wm->defaultconf); BLI_assert(wgt->keymap != NULL); } - mgroup->init_flag |= WM_MANIPULATORGROUP_INIT_SETUP; } + + /* refresh may be called multiple times, this just ensures its called at least once before we draw. */ + if (UNLIKELY((mgroup->init_flag & WM_MANIPULATORGROUP_INIT_REFRESH) == 0)) { + if (mgroup->type->refresh) { + mgroup->type->refresh(C, mgroup); + } + mgroup->init_flag |= WM_MANIPULATORGROUP_INIT_REFRESH; + } } bool wm_manipulatorgroup_is_visible(const wmManipulatorGroup *mgroup, const bContext *C) diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c b/source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c index 0d2a8f7dcc5..1d8ee35cd32 100644 --- a/source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c +++ b/source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c @@ -327,13 +327,14 @@ static void manipulatormap_prepare_drawing( } /* needs to be initialized on first draw */ - wm_manipulatorgroup_ensure_initialized(mgroup, C); - /* update data if needed */ /* XXX weak: Manipulator-group may skip refreshing if it's invisible (map gets untagged nevertheless) */ - if ((mmap->update_flag[drawstep] & MANIPULATORMAP_IS_REFRESH_CALLBACK) && mgroup->type->refresh) { - mgroup->type->refresh(C, mgroup); - /* cleared below */ + if (mmap->update_flag[drawstep] & MANIPULATORMAP_IS_REFRESH_CALLBACK) { + /* force refresh again. */ + mgroup->init_flag &= ~WM_MANIPULATORGROUP_INIT_REFRESH; } + /* Calls `setup`, `setup_keymap` and `refresh` if they're defined. */ + wm_manipulatorgroup_ensure_initialized(mgroup, C); + /* prepare drawing */ if (mgroup->type->draw_prepare) { mgroup->type->draw_prepare(C, mgroup); |