[Bf-blender-cvs] [8ebc6be43dd] master: Cleanup: de-duplicate tool gizmo

Campbell Barton noreply at git.blender.org
Tue Dec 17 06:32:06 CET 2019


Commit: 8ebc6be43ddf5a4c28b848c62d09f9435dd1bffe
Author: Campbell Barton
Date:   Tue Dec 17 16:30:11 2019 +1100
Branches: master
https://developer.blender.org/rB8ebc6be43ddf5a4c28b848c62d09f9435dd1bffe

Cleanup: de-duplicate tool gizmo

===================================================================

M	source/blender/editors/space_view3d/view3d_gizmo_tool_generic.c

===================================================================

diff --git a/source/blender/editors/space_view3d/view3d_gizmo_tool_generic.c b/source/blender/editors/space_view3d/view3d_gizmo_tool_generic.c
index 81e5a8a76b9..f761a44fe16 100644
--- a/source/blender/editors/space_view3d/view3d_gizmo_tool_generic.c
+++ b/source/blender/editors/space_view3d/view3d_gizmo_tool_generic.c
@@ -70,19 +70,17 @@ static bool WIDGETGROUP_tool_generic_poll(const bContext *C, wmGizmoGroupType *g
 
 static wmGizmo *tool_generic_create_gizmo(const bContext *C, wmGizmoGroup *gzgroup)
 {
-  wmGizmo *gz;
-
-  if (gzgroup->type->idname == handle_normal_id) {
-    gz = WM_gizmo_new("GIZMO_GT_button_2d", gzgroup, NULL);
+  wmGizmo *gz = WM_gizmo_new("GIZMO_GT_button_2d", gzgroup, NULL);
+  gz->flag |= WM_GIZMO_OPERATOR_TOOL_INIT;
 
-    UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, gz->color);
-    UI_GetThemeColor3fv(TH_GIZMO_HI, gz->color_hi);
+  UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, gz->color);
+  UI_GetThemeColor3fv(TH_GIZMO_HI, gz->color_hi);
 
-    unit_m4(gz->matrix_offset);
+  unit_m4(gz->matrix_offset);
 
-    PropertyRNA *prop = RNA_struct_find_property(gz->ptr, "icon");
-    RNA_property_enum_set(gz->ptr, prop, ICON_NONE);
+  RNA_enum_set(gz->ptr, "icon", ICON_NONE);
 
+  if (gzgroup->type->idname == handle_normal_id) {
     gz->scale_basis = 0.12f;
     gz->matrix_offset[3][2] -= 12.0;
     RNA_enum_set(gz->ptr,
@@ -91,17 +89,8 @@ static wmGizmo *tool_generic_create_gizmo(const bContext *C, wmGizmoGroup *gzgro
                   ED_GIZMO_BUTTON_SHOW_OUTLINE));
   }
   else {
-    gz = WM_gizmo_new("GIZMO_GT_button_2d", gzgroup, NULL);
-
-    UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, gz->color);
-    UI_GetThemeColor3fv(TH_GIZMO_HI, gz->color_hi);
-
-    unit_m4(gz->matrix_offset);
     gz->scale_basis = 0.16f * 3;
 
-    PropertyRNA *prop = RNA_struct_find_property(gz->ptr, "icon");
-    RNA_property_enum_set(gz->ptr, prop, ICON_NONE);
-
     RNA_enum_set(gz->ptr, "draw_options", ED_GIZMO_BUTTON_SHOW_BACKDROP);
 
     /* Make the center low alpha. */
@@ -109,8 +98,6 @@ static wmGizmo *tool_generic_create_gizmo(const bContext *C, wmGizmoGroup *gzgro
     RNA_float_set(gz->ptr, "backdrop_fill_alpha", 0.125f);
   }
 
-  gz->flag |= WM_GIZMO_OPERATOR_TOOL_INIT;
-
   bToolRef *tref = WM_toolsystem_ref_from_context((bContext *)C);
   wmWindowManager *wm = CTX_wm_manager(C);
   struct wmKeyConfig *kc = wm->defaultconf;



More information about the Bf-blender-cvs mailing list