diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/mesh/editmesh_add_gizmo.c | 13 | ||||
-rw-r--r-- | source/blender/windowmanager/gizmo/WM_gizmo_api.h | 14 | ||||
-rw-r--r-- | source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c | 34 |
3 files changed, 43 insertions, 18 deletions
diff --git a/source/blender/editors/mesh/editmesh_add_gizmo.c b/source/blender/editors/mesh/editmesh_add_gizmo.c index 460b70cecca..38fc7d58dcf 100644 --- a/source/blender/editors/mesh/editmesh_add_gizmo.c +++ b/source/blender/editors/mesh/editmesh_add_gizmo.c @@ -380,17 +380,10 @@ static int add_primitive_cube_gizmo_invoke(bContext *C, wmOperator *op, const wm if (ret & OPERATOR_FINISHED) { /* Setup gizmos */ if (v3d && ((v3d->gizmo_flag & V3D_GIZMO_HIDE) == 0)) { - ARegion *ar = CTX_wm_region(C); - wmGizmoMap *gzmap = ar->gizmo_map; wmGizmoGroupType *gzgt = WM_gizmogrouptype_find("MESH_GGT_add_bounds", false); - wmGizmoGroup *gzgroup = WM_gizmomap_group_find_ptr(gzmap, gzgt); - if (gzgroup != NULL) { - GizmoPlacementGroup *ggd = gzgroup->customdata; - ggd->data.op = op; - gizmo_mesh_placement_modal_from_setup(C, gzgroup); - } - else { - WM_gizmo_group_type_ensure_ptr(gzgt); + if (!WM_gizmo_group_type_ensure_ptr(gzgt)) { + struct Main *bmain = CTX_data_main(C); + WM_gizmo_group_type_reinit_ptr(bmain, gzgt); } } } diff --git a/source/blender/windowmanager/gizmo/WM_gizmo_api.h b/source/blender/windowmanager/gizmo/WM_gizmo_api.h index 4a01e33cae7..153840986ef 100644 --- a/source/blender/windowmanager/gizmo/WM_gizmo_api.h +++ b/source/blender/windowmanager/gizmo/WM_gizmo_api.h @@ -314,12 +314,12 @@ void WM_gizmo_group_type_add_ptr( struct wmGizmoGroupType *gzgt); void WM_gizmo_group_type_add(const char *idname); -void WM_gizmo_group_type_ensure_ptr_ex( +bool WM_gizmo_group_type_ensure_ptr_ex( struct wmGizmoGroupType *gzgt, struct wmGizmoMapType *gzmap_type); -void WM_gizmo_group_type_ensure_ptr( +bool WM_gizmo_group_type_ensure_ptr( struct wmGizmoGroupType *gzgt); -void WM_gizmo_group_type_ensure(const char *idname); +bool WM_gizmo_group_type_ensure(const char *idname); void WM_gizmo_group_type_remove_ptr_ex( struct Main *bmain, struct wmGizmoGroupType *gzgt, @@ -335,6 +335,14 @@ void WM_gizmo_group_type_unlink_delayed_ptr( struct wmGizmoGroupType *gzgt); void WM_gizmo_group_type_unlink_delayed(const char *idname); +/* Has the result of unlinking and linking (re-initializes gizmo's). */ +void WM_gizmo_group_type_reinit_ptr_ex( + struct Main *bmain, struct wmGizmoGroupType *gzgt, + struct wmGizmoMapType *gzmap_type); +void WM_gizmo_group_type_reinit_ptr( + struct Main *bmain, struct wmGizmoGroupType *gzgt); +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); diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c index e46cd9049a5..aa4058c95f4 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c @@ -879,26 +879,28 @@ void WM_gizmo_group_type_add(const char *idname) WM_gizmo_group_type_add_ptr(gzgt); } -void WM_gizmo_group_type_ensure_ptr_ex( +bool WM_gizmo_group_type_ensure_ptr_ex( wmGizmoGroupType *gzgt, wmGizmoMapType *gzmap_type) { wmGizmoGroupTypeRef *gzgt_ref = WM_gizmomaptype_group_find_ptr(gzmap_type, gzgt); if (gzgt_ref == NULL) { WM_gizmo_group_type_add_ptr_ex(gzgt, gzmap_type); + return true; } + return false; } -void WM_gizmo_group_type_ensure_ptr( +bool WM_gizmo_group_type_ensure_ptr( wmGizmoGroupType *gzgt) { wmGizmoMapType *gzmap_type = WM_gizmomaptype_ensure(&gzgt->gzmap_params); - WM_gizmo_group_type_ensure_ptr_ex(gzgt, gzmap_type); + return WM_gizmo_group_type_ensure_ptr_ex(gzgt, gzmap_type); } -void WM_gizmo_group_type_ensure(const char *idname) +bool WM_gizmo_group_type_ensure(const char *idname) { wmGizmoGroupType *gzgt = WM_gizmogrouptype_find(idname, false); BLI_assert(gzgt != NULL); - WM_gizmo_group_type_ensure_ptr(gzgt); + return WM_gizmo_group_type_ensure_ptr(gzgt); } void WM_gizmo_group_type_remove_ptr_ex( @@ -921,6 +923,28 @@ void WM_gizmo_group_type_remove(struct Main *bmain, const char *idname) WM_gizmo_group_type_remove_ptr(bmain, gzgt); } +void WM_gizmo_group_type_reinit_ptr_ex( + struct Main *bmain, wmGizmoGroupType *gzgt, + wmGizmoMapType *gzmap_type) +{ + wmGizmoGroupTypeRef *gzgt_ref = WM_gizmomaptype_group_find_ptr(gzmap_type, gzgt); + BLI_assert(gzgt_ref != NULL); + WM_gizmomaptype_group_unlink(NULL, bmain, gzmap_type, gzgt); + WM_gizmo_group_type_add_ptr_ex(gzgt, gzmap_type); +} +void WM_gizmo_group_type_reinit_ptr( + struct Main *bmain, wmGizmoGroupType *gzgt) +{ + wmGizmoMapType *gzmap_type = WM_gizmomaptype_ensure(&gzgt->gzmap_params); + WM_gizmo_group_type_reinit_ptr_ex(bmain, gzgt, gzmap_type); +} +void WM_gizmo_group_type_reinit(struct Main *bmain, const char *idname) +{ + wmGizmoGroupType *gzgt = WM_gizmogrouptype_find(idname, false); + BLI_assert(gzgt != NULL); + WM_gizmo_group_type_reinit_ptr(bmain, gzgt); +} + /* delayed versions */ void WM_gizmo_group_type_unlink_delayed_ptr_ex( |