Gizmo: use compatible scale values between 2D/3D gizmos
Make the UV editor gizmos the same size as the 3D view.
This commit is contained in:
@@ -56,7 +56,6 @@
|
||||
/* own includes */
|
||||
#include "../gizmo_library_intern.h"
|
||||
|
||||
#define GIZMO_RESIZER_SIZE 10.0f
|
||||
#define GIZMO_MARGIN_OFFSET_SCALE 1.5f
|
||||
|
||||
static bool gizmo_calc_rect_view_scale(const wmGizmo *gz, const float dims[2], float scale[2])
|
||||
@@ -92,12 +91,7 @@ static bool gizmo_calc_rect_view_scale(const wmGizmo *gz, const float dims[2], f
|
||||
static bool gizmo_calc_rect_view_margin(const wmGizmo *gz, const float dims[2], float margin[2])
|
||||
{
|
||||
float handle_size;
|
||||
if (gz->parent_gzgroup->type->flag & WM_GIZMOGROUPTYPE_3D) {
|
||||
handle_size = 0.15f;
|
||||
}
|
||||
else {
|
||||
handle_size = GIZMO_RESIZER_SIZE;
|
||||
}
|
||||
handle_size = 0.15f;
|
||||
handle_size *= gz->scale_final;
|
||||
float scale_xy[2];
|
||||
if (!gizmo_calc_rect_view_scale(gz, dims, scale_xy)) {
|
||||
|
||||
@@ -91,13 +91,7 @@ static void gizmo_calc_rect_view_scale(const wmGizmo *gz, const float dims[3], f
|
||||
|
||||
static void gizmo_calc_rect_view_margin(const wmGizmo *gz, const float dims[3], float margin[3])
|
||||
{
|
||||
float handle_size;
|
||||
if (gz->parent_gzgroup->type->flag & WM_GIZMOGROUPTYPE_3D) {
|
||||
handle_size = 0.15f;
|
||||
}
|
||||
else {
|
||||
handle_size = GIZMO_RESIZER_SIZE;
|
||||
}
|
||||
const float handle_size = 0.15f;
|
||||
// XXX, the scale isn't taking offset into account, we need to calculate scale per handle!
|
||||
// handle_size *= gz->scale_final;
|
||||
|
||||
|
||||
@@ -208,7 +208,6 @@ void ED_widgetgroup_gizmo2d_xform_setup(const bContext *UNUSED(C), wmGizmoGroup
|
||||
|
||||
/* custom handler! */
|
||||
WM_gizmo_set_fn_custom_modal(gz, gizmo2d_modal);
|
||||
WM_gizmo_set_scale(gz, U.gizmo_size);
|
||||
|
||||
if (i < 2) {
|
||||
float color[4], color_hi[4];
|
||||
@@ -221,6 +220,8 @@ void ED_widgetgroup_gizmo2d_xform_setup(const bContext *UNUSED(C), wmGizmoGroup
|
||||
WM_gizmo_set_line_width(gz, GIZMO_AXIS_LINE_WIDTH);
|
||||
WM_gizmo_set_color(gz, color);
|
||||
WM_gizmo_set_color_highlight(gz, color_hi);
|
||||
|
||||
WM_gizmo_set_scale(gz, 1.0f);
|
||||
}
|
||||
else {
|
||||
PropertyRNA *prop = RNA_struct_find_property(gz->ptr, "icon");
|
||||
@@ -230,6 +231,8 @@ void ED_widgetgroup_gizmo2d_xform_setup(const bContext *UNUSED(C), wmGizmoGroup
|
||||
/* Make the center low alpha. */
|
||||
WM_gizmo_set_line_width(gz, 2.0f);
|
||||
RNA_float_set(gz->ptr, "backdrop_fill_alpha", 0.0);
|
||||
|
||||
WM_gizmo_set_scale(gz, 1.2f);
|
||||
}
|
||||
|
||||
/* Assign operator. */
|
||||
@@ -511,7 +514,6 @@ void ED_widgetgroup_gizmo2d_resize_setup(const bContext *UNUSED(C), wmGizmoGroup
|
||||
|
||||
/* custom handler! */
|
||||
WM_gizmo_set_fn_custom_modal(gz, gizmo2d_modal);
|
||||
WM_gizmo_set_scale(gz, U.gizmo_size);
|
||||
|
||||
if (i < 2) {
|
||||
const float offset[3] = {0.0f, 0.2f};
|
||||
@@ -527,6 +529,8 @@ void ED_widgetgroup_gizmo2d_resize_setup(const bContext *UNUSED(C), wmGizmoGroup
|
||||
WM_gizmo_set_line_width(gz, GIZMO_AXIS_LINE_WIDTH);
|
||||
WM_gizmo_set_color(gz, color);
|
||||
WM_gizmo_set_color_highlight(gz, color_hi);
|
||||
|
||||
WM_gizmo_set_scale(gz, 1.0f);
|
||||
}
|
||||
else {
|
||||
PropertyRNA *prop = RNA_struct_find_property(gz->ptr, "icon");
|
||||
@@ -536,6 +540,8 @@ void ED_widgetgroup_gizmo2d_resize_setup(const bContext *UNUSED(C), wmGizmoGroup
|
||||
/* Make the center low alpha. */
|
||||
WM_gizmo_set_line_width(gz, 2.0f);
|
||||
RNA_float_set(gz->ptr, "backdrop_fill_alpha", 0.0);
|
||||
|
||||
WM_gizmo_set_scale(gz, 1.2f);
|
||||
}
|
||||
|
||||
/* Assign operator. */
|
||||
@@ -629,7 +635,7 @@ void ED_widgetgroup_gizmo2d_rotate_setup(const bContext *UNUSED(C), wmGizmoGroup
|
||||
|
||||
/* custom handler! */
|
||||
WM_gizmo_set_fn_custom_modal(gz, gizmo2d_modal);
|
||||
WM_gizmo_set_scale(gz, U.gizmo_size);
|
||||
WM_gizmo_set_scale(gz, 1.0f);
|
||||
|
||||
{
|
||||
PropertyRNA *prop = RNA_struct_find_property(gz->ptr, "icon");
|
||||
|
||||
@@ -503,9 +503,6 @@ void wm_gizmo_calculate_scale(wmGizmo *gz, const bContext *C)
|
||||
/* Exclude matrix_offset from scale. */
|
||||
scale *= ED_view3d_pixel_size_no_ui_scale(rv3d, matrix_world[3]);
|
||||
}
|
||||
else {
|
||||
scale *= 0.02f;
|
||||
}
|
||||
}
|
||||
|
||||
gz->scale_final = gz->scale_basis * scale;
|
||||
|
||||
Reference in New Issue
Block a user