diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-09-18 09:10:07 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-09-18 09:15:06 +0300 |
commit | d421adb83e8d39bd9d74ea3d526326b70e93c341 (patch) | |
tree | 4c5e16b5e2fcd8c587204aa85dde175a6951392a /source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c | |
parent | 0a3b66cfb573a91ba3b19f30ead4a026bdfa6873 (diff) |
Gizmo: de-duplicate poll logic
Checking the active tool or operator was a common way to check
if the gizmo was still in use.
Diffstat (limited to 'source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c')
-rw-r--r-- | source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c | 24 |
1 files changed, 3 insertions, 21 deletions
diff --git a/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c b/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c index 800e679b8a9..bba5be4ba7d 100644 --- a/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c +++ b/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c @@ -32,6 +32,7 @@ #include "WM_types.h" #include "WM_message.h" +#include "ED_gizmo_utils.h" #include "ED_screen.h" #include "ED_view3d.h" @@ -67,20 +68,6 @@ typedef struct GizmoGroupData_SpinInit { } data; } GizmoGroupData_SpinInit; -static bool gizmo_mesh_spin_init_poll(const bContext *C, wmGizmoGroupType *gzgt) -{ - ScrArea *sa = CTX_wm_area(C); - bToolRef_Runtime *tref_rt = sa->runtime.tool ? sa->runtime.tool->runtime : NULL; - if ((tref_rt == NULL) || - !STREQ(gzgt->idname, tref_rt->gizmo_group) || - !ED_operator_editmesh_view3d((bContext *)C)) - { - WM_gizmo_group_type_unlink_delayed_ptr(gzgt); - return false; - } - return true; -} - static void gizmo_mesh_spin_init_setup(const bContext *UNUSED(C), wmGizmoGroup *gzgroup) { /* alpha values for normal/highlighted states */ @@ -241,7 +228,7 @@ void MESH_GGT_spin(struct wmGizmoGroupType *gzgt) gzgt->gzmap_params.spaceid = SPACE_VIEW3D; gzgt->gzmap_params.regionid = RGN_TYPE_WINDOW; - gzgt->poll = gizmo_mesh_spin_init_poll; + gzgt->poll = ED_gizmo_poll_or_unlink_delayed_from_tool; gzgt->setup = gizmo_mesh_spin_init_setup; gzgt->refresh = gizmo_mesh_spin_init_refresh; gzgt->message_subscribe = gizmo_mesh_spin_init_message_subscribe; @@ -506,12 +493,7 @@ static void gizmo_spin_prop_angle_set( static bool gizmo_mesh_spin_redo_poll(const bContext *C, wmGizmoGroupType *gzgt) { - wmOperator *op = WM_operator_last_redo(C); - if (op == NULL || !STREQ(op->type->idname, "MESH_OT_spin")) { - WM_gizmo_group_type_unlink_delayed_ptr(gzgt); - return false; - } - return true; + return ED_gizmo_poll_or_unlink_delayed_from_operator(C, gzgt, "MESH_OT_spin"); } |