diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-12-18 17:27:23 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-12-18 17:53:15 +0300 |
commit | d591c8a350310e69d4db23759847fb0df2ff23ae (patch) | |
tree | dc11974b50e0d2d06cdfc5a9fe8f2a2ff735f983 /source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c | |
parent | 5467f3de3a4aca99e678f16356c1d54cda5fb42f (diff) |
Gizmo: add the ability to postpone refreshing while tweaking
This resolves a logical problem using tweak as a fallback tool.
See: T66304#828742
The select action would immediately show the gizmo underneath it,
then the tweak would be handled by the gizmo instead of moving the item
under the cursor.
Currently this works by hiding the gizmo until the tweak event ends.
While it's simpler to check if the gizmo received a mouse-down event,
it causes flickering before each drag event which feels like a glitch.
This is optional for each gizmo type because there are cases where this
can be useful to activate the gizmo immediately (mesh rip for example).
Diffstat (limited to 'source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c')
-rw-r--r-- | source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c index d2638ae148e..73bee883cf8 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c @@ -284,8 +284,10 @@ void WM_gizmogroup_ensure_init(const bContext *C, wmGizmoGroup *gzgroup) /* Refresh may be called multiple times, * this just ensures its called at least once before we draw. */ if (UNLIKELY((gzgroup->init_flag & WM_GIZMOGROUP_INIT_REFRESH) == 0)) { - WM_gizmo_group_refresh(C, gzgroup); + /* Clear the flag before calling refresh so the callback + * can postpone the refresh by clearing this flag. */ gzgroup->init_flag |= WM_GIZMOGROUP_INIT_REFRESH; + WM_gizmo_group_refresh(C, gzgroup); } } @@ -1147,6 +1149,26 @@ bool WM_gizmo_group_type_poll(const bContext *C, const wmGizmoGroupType *gzgt) void WM_gizmo_group_refresh(const bContext *C, wmGizmoGroup *gzgroup) { const wmGizmoGroupType *gzgt = gzgroup->type; + if (gzgt->flag & WM_GIZMOGROUPTYPE_DELAY_REFRESH_FOR_TWEAK) { + wmGizmoMap *gzmap = gzgroup->parent_gzmap; + wmGizmo *gz = wm_gizmomap_highlight_get(gzmap); + if (!gz || gz->parent_gzgroup != gzgroup) { + wmWindow *win = CTX_wm_window(C); + if (win->tweak) { + /* We need to run refresh again. */ + gzgroup->init_flag &= ~WM_GIZMOGROUP_INIT_REFRESH; + WM_gizmomap_tag_refresh_drawstep(gzmap, WM_gizmomap_drawstep_from_gizmo_group(gzgroup)); + gzgroup->hide.delay_refresh_for_tweak = true; + return; + } + } + gzgroup->hide.delay_refresh_for_tweak = false; + } + + if (gzgroup->hide.any) { + return; + } + if (gzgt->refresh) { gzgt->refresh(C, gzgroup); } |