Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/space_view3d/view3d_gizmo_tool_generic.c')
-rw-r--r--source/blender/editors/space_view3d/view3d_gizmo_tool_generic.c48
1 files changed, 44 insertions, 4 deletions
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 ad91af73a71..0e0d59764e5 100644
--- a/source/blender/editors/space_view3d/view3d_gizmo_tool_generic.c
+++ b/source/blender/editors/space_view3d/view3d_gizmo_tool_generic.c
@@ -36,6 +36,7 @@
#include "WM_toolsystem.h"
#include "RNA_access.h"
+#include "RNA_define.h"
#include "WM_api.h"
#include "WM_message.h"
@@ -47,6 +48,9 @@
static const char *handle_normal_id;
static const char *handle_free_id;
+static const float handle_normal_radius_default = 100.0f;
+static const float handle_free_radius_default = 36.0f;
+
/* -------------------------------------------------------------------- */
/** \name Generic Tool
* \{ */
@@ -72,6 +76,7 @@ static bool WIDGETGROUP_tool_generic_poll(const bContext *C, wmGizmoGroupType *g
static wmGizmo *tool_generic_create_gizmo(const bContext *C, wmGizmoGroup *gzgroup)
{
+
wmGizmo *gz = WM_gizmo_new("GIZMO_GT_button_2d", gzgroup, NULL);
gz->flag |= WM_GIZMO_OPERATOR_TOOL_INIT;
@@ -82,8 +87,17 @@ static wmGizmo *tool_generic_create_gizmo(const bContext *C, wmGizmoGroup *gzgro
RNA_enum_set(gz->ptr, "icon", ICON_NONE);
+ bToolRef *tref = WM_toolsystem_ref_from_context((bContext *)C);
+ PointerRNA gzgt_ptr;
+ const bool gzgt_ptr_is_valid = WM_toolsystem_ref_properties_get_from_gizmo_group(
+ tref, gzgroup->type, &gzgt_ptr);
+
if (gzgroup->type->idname == handle_normal_id) {
- gz->scale_basis = 0.12f;
+ const float radius = (gzgt_ptr_is_valid ? RNA_float_get(&gzgt_ptr, "radius") :
+ handle_normal_radius_default) /
+ 12.0f;
+
+ gz->scale_basis = radius / U.gizmo_size;
gz->matrix_offset[3][2] -= 12.0;
RNA_enum_set(gz->ptr,
"draw_options",
@@ -91,16 +105,20 @@ static wmGizmo *tool_generic_create_gizmo(const bContext *C, wmGizmoGroup *gzgro
ED_GIZMO_BUTTON_SHOW_OUTLINE));
}
else {
- gz->scale_basis = 0.16f * 3;
+ const float radius = gzgt_ptr_is_valid ? RNA_float_get(&gzgt_ptr, "radius") :
+ handle_free_radius_default;
+
+ gz->scale_basis = radius / U.gizmo_size;
RNA_enum_set(gz->ptr, "draw_options", ED_GIZMO_BUTTON_SHOW_BACKDROP);
/* Make the center low alpha. */
WM_gizmo_set_line_width(gz, 2.0f);
- RNA_float_set(gz->ptr, "backdrop_fill_alpha", 0.125f);
+ RNA_float_set(gz->ptr,
+ "backdrop_fill_alpha",
+ gzgt_ptr_is_valid ? RNA_float_get(&gzgt_ptr, "backdrop_fill_alpha") : 0.125f);
}
- bToolRef *tref = WM_toolsystem_ref_from_context((bContext *)C);
wmWindowManager *wm = CTX_wm_manager(C);
struct wmKeyConfig *kc = wm->defaultconf;
@@ -206,6 +224,16 @@ void VIEW3D_GGT_tool_generic_handle_normal(wmGizmoGroupType *gzgt)
gzgt->setup = WIDGETGROUP_tool_generic_setup;
gzgt->refresh = WIDGETGROUP_tool_generic_refresh;
gzgt->message_subscribe = WIDGETGROUP_gizmo_message_subscribe;
+
+ RNA_def_float(gzgt->srna,
+ "radius",
+ handle_normal_radius_default,
+ 0.0f,
+ 1000.0,
+ "Radius",
+ "Radius in pixels",
+ 0.0f,
+ 1000.0f);
}
void VIEW3D_GGT_tool_generic_handle_free(wmGizmoGroupType *gzgt)
@@ -224,6 +252,18 @@ void VIEW3D_GGT_tool_generic_handle_free(wmGizmoGroupType *gzgt)
gzgt->setup = WIDGETGROUP_tool_generic_setup;
gzgt->refresh = WIDGETGROUP_tool_generic_refresh;
gzgt->message_subscribe = WIDGETGROUP_gizmo_message_subscribe;
+
+ RNA_def_float(gzgt->srna,
+ "radius",
+ handle_free_radius_default,
+ 0.0f,
+ 1000.0,
+ "Radius",
+ "Radius in pixels",
+ 0.0f,
+ 1000.0f);
+ RNA_def_float(
+ gzgt->srna, "backdrop_fill_alpha", 0.125, 0.0f, 1.0f, "Backdrop Alpha", "", 0.0f, 1.0f);
}
/** \} */