diff options
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r-- | source/blender/windowmanager/gizmo/WM_gizmo_api.h | 5 | ||||
-rw-r--r-- | source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c | 47 | ||||
-rw-r--r-- | source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c | 5 |
3 files changed, 36 insertions, 21 deletions
diff --git a/source/blender/windowmanager/gizmo/WM_gizmo_api.h b/source/blender/windowmanager/gizmo/WM_gizmo_api.h index 5896424d5fe..a81a4596733 100644 --- a/source/blender/windowmanager/gizmo/WM_gizmo_api.h +++ b/source/blender/windowmanager/gizmo/WM_gizmo_api.h @@ -371,7 +371,6 @@ void WM_gizmo_group_type_reinit(struct Main *bmain, const char *idname); /* Utilities */ bool WM_gizmo_context_check_drawstep(const struct bContext *C, eWM_GizmoFlagMapDrawStep step); -bool WM_gizmo_group_type_poll(const struct bContext *C, const struct wmGizmoGroupType *gzgt); void WM_gizmo_group_remove_by_tool(struct bContext *C, struct Main *bmain, const struct wmGizmoGroupType *gzgt, @@ -379,4 +378,8 @@ void WM_gizmo_group_remove_by_tool(struct bContext *C, void WM_gizmo_group_tag_remove(struct wmGizmoGroup *gzgroup); +/* Wrap Group Type Callbacks. */ +bool WM_gizmo_group_type_poll(const struct bContext *C, const struct wmGizmoGroupType *gzgt); +void WM_gizmo_group_refresh(const struct bContext *C, struct wmGizmoGroup *gzgroup); + #endif /* __WM_GIZMO_API_H__ */ diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c index 77950c11c63..d2638ae148e 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c @@ -284,27 +284,11 @@ 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)) { - if (gzgroup->type->refresh) { - gzgroup->type->refresh(C, gzgroup); - } + WM_gizmo_group_refresh(C, gzgroup); gzgroup->init_flag |= WM_GIZMOGROUP_INIT_REFRESH; } } -bool WM_gizmo_group_type_poll(const bContext *C, const struct wmGizmoGroupType *gzgt) -{ - /* If we're tagged, only use compatible. */ - if (gzgt->owner_id[0] != '\0') { - const WorkSpace *workspace = CTX_wm_workspace(C); - if (BKE_workspace_owner_id_check(workspace, gzgt->owner_id) == false) { - return false; - } - } - /* Check for poll function, if gizmo-group belongs to an operator, - * also check if the operator is running. */ - return (!gzgt->poll || gzgt->poll(C, (wmGizmoGroupType *)gzgt)); -} - void WM_gizmo_group_remove_by_tool(bContext *C, Main *bmain, const wmGizmoGroupType *gzgt, @@ -1140,3 +1124,32 @@ void WM_gizmo_group_unlink_delayed_ptr_from_space(wmGizmoGroupType *gzgt, } /** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Gizmo Group Type Callback Wrappers + * + * \{ */ + +bool WM_gizmo_group_type_poll(const bContext *C, const wmGizmoGroupType *gzgt) +{ + /* If we're tagged, only use compatible. */ + if (gzgt->owner_id[0] != '\0') { + const WorkSpace *workspace = CTX_wm_workspace(C); + if (BKE_workspace_owner_id_check(workspace, gzgt->owner_id) == false) { + return false; + } + } + /* Check for poll function, if gizmo-group belongs to an operator, + * also check if the operator is running. */ + return (!gzgt->poll || gzgt->poll(C, (wmGizmoGroupType *)gzgt)); +} + +void WM_gizmo_group_refresh(const bContext *C, wmGizmoGroup *gzgroup) +{ + const wmGizmoGroupType *gzgt = gzgroup->type; + if (gzgt->refresh) { + gzgt->refresh(C, gzgroup); + } +} + +/** \} */ diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c index ef4d8174718..97bb203bcf6 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c @@ -730,9 +730,8 @@ wmGizmo *wm_gizmomap_highlight_find(wmGizmoMap *gzmap, } if (do_step[step]) { - if ((gzmap->update_flag[step] & GIZMOMAP_IS_REFRESH_CALLBACK) && - (gzgroup->type->refresh != NULL)) { - gzgroup->type->refresh(C, gzgroup); + if (gzmap->update_flag[step] & GIZMOMAP_IS_REFRESH_CALLBACK) { + WM_gizmo_group_refresh(C, gzgroup); /* cleared below */ } if (step == WM_GIZMOMAP_DRAWSTEP_3D) { |