UI: Increase Gizmo 3D Wire Parts Hit Size
Gizmos that contain 3D wire parts, like the rounded lines of the "Rotate" gizmo, have a fairly small hit size that make it hard to grab, especially with tablet pens. This PR just increases the width of these lines during the (invisible) selection process. This is done in such ability way that it could be increased in the future for touch if needed. Pull Request: https://projects.blender.org/blender/blender/pulls/138406
This commit is contained in:
committed by
Harley Acheson
parent
7a125d5ebc
commit
107c744540
@@ -8,6 +8,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "DNA_userdef_types.h"
|
||||
|
||||
#include "gizmo_geometry.h"
|
||||
|
||||
struct IDProperty;
|
||||
@@ -17,6 +19,17 @@ struct wmGizmoProperty;
|
||||
|
||||
#define DIAL_RESOLUTION 48
|
||||
|
||||
/**
|
||||
* This bias is to be applied on wire gizmos or any small gizmos which may
|
||||
* be difficult to pick otherwise. The value is defined in logical pixels.
|
||||
*/
|
||||
#define WM_GIZMO_SELECT_BIAS 6.0f
|
||||
|
||||
static inline float WM_gizmo_select_bias(bool select)
|
||||
{
|
||||
return select ? WM_GIZMO_SELECT_BIAS * UI_SCALE_FAC : 0.0f;
|
||||
}
|
||||
|
||||
/**
|
||||
* Data for common interactions. Used in `gizmo_library_utils.cc` functions.
|
||||
*/
|
||||
|
||||
@@ -92,7 +92,7 @@ static void arrow_draw_geom(const ArrowGizmo3D *arrow,
|
||||
immUniform2fv("viewportSize", &viewport[2]);
|
||||
|
||||
if (draw_style == ED_GIZMO_ARROW_STYLE_CROSS) {
|
||||
immUniform1f("lineWidth", U.pixelsize);
|
||||
immUniform1f("lineWidth", U.pixelsize + WM_gizmo_select_bias(select));
|
||||
immUniformColor4fv(color);
|
||||
|
||||
immBegin(GPU_PRIM_LINES, 4);
|
||||
@@ -114,7 +114,8 @@ static void arrow_draw_geom(const ArrowGizmo3D *arrow,
|
||||
{-unitx, unity, 0},
|
||||
};
|
||||
|
||||
immUniform1f("lineWidth", arrow->gizmo.line_width * U.pixelsize);
|
||||
immUniform1f("lineWidth",
|
||||
(arrow->gizmo.line_width * U.pixelsize) + WM_gizmo_select_bias(select));
|
||||
wm_gizmo_vec_draw(color, vec, ARRAY_SIZE(vec), pos, GPU_PRIM_LINE_LOOP);
|
||||
}
|
||||
else if (draw_style == ED_GIZMO_ARROW_STYLE_PLANE) {
|
||||
@@ -132,7 +133,8 @@ static void arrow_draw_geom(const ArrowGizmo3D *arrow,
|
||||
GPU_matrix_push();
|
||||
GPU_matrix_translate_3f(0.0f, 0.0f, arrow_length);
|
||||
|
||||
immUniform1f("lineWidth", arrow->gizmo.line_width * U.pixelsize);
|
||||
immUniform1f("lineWidth",
|
||||
(arrow->gizmo.line_width * U.pixelsize) + WM_gizmo_select_bias(select));
|
||||
wm_gizmo_vec_draw(color, verts, ARRAY_SIZE(verts), pos, GPU_PRIM_LINE_LOOP);
|
||||
|
||||
immUnbindProgram();
|
||||
@@ -150,9 +152,8 @@ static void arrow_draw_geom(const ArrowGizmo3D *arrow,
|
||||
};
|
||||
|
||||
if (draw_options & ED_GIZMO_ARROW_DRAW_FLAG_STEM) {
|
||||
const float stem_width = arrow->gizmo.line_width * U.pixelsize +
|
||||
(select ? ARROW_SELECT_THRESHOLD_PX * UI_SCALE_FAC : 0);
|
||||
immUniform1f("lineWidth", stem_width);
|
||||
immUniform1f("lineWidth",
|
||||
(arrow->gizmo.line_width * U.pixelsize) + WM_gizmo_select_bias(select));
|
||||
wm_gizmo_vec_draw(color, vec, ARRAY_SIZE(vec), pos, GPU_PRIM_LINE_STRIP);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -94,7 +94,7 @@ static void button2d_geom_draw_backdrop(const wmGizmo *gz,
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR);
|
||||
immUniform2fv("viewportSize", &viewport[2]);
|
||||
immUniform1f("lineWidth", gz->line_width * U.pixelsize);
|
||||
immUniform1f("lineWidth", (gz->line_width * U.pixelsize) + WM_gizmo_select_bias(select));
|
||||
immUniformColor4fv(color);
|
||||
imm_draw_circle_wire_3d(pos, 0.0f, 0.0f, 1.0f, nsegments);
|
||||
immUnbindProgram();
|
||||
@@ -113,7 +113,7 @@ static void button2d_geom_draw_backdrop(const wmGizmo *gz,
|
||||
if ((fill_alpha != 1.0f) && (select == false)) {
|
||||
immBindBuiltinProgram(GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR);
|
||||
immUniform2fv("viewportSize", &viewport[2]);
|
||||
immUniform1f("lineWidth", gz->line_width * U.pixelsize);
|
||||
immUniform1f("lineWidth", (gz->line_width * U.pixelsize) + WM_gizmo_select_bias(select));
|
||||
immUniformColor4fv(color);
|
||||
imm_draw_circle_wire_3d(pos, 0.0f, 0.0f, 1.0f, nsegments);
|
||||
immUnbindProgram();
|
||||
@@ -176,7 +176,7 @@ static void button2d_draw_intern(const bContext *C,
|
||||
uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR);
|
||||
immUniform2fv("viewportSize", &viewport[2]);
|
||||
immUniform1f("lineWidth", gz->line_width * U.pixelsize);
|
||||
immUniform1f("lineWidth", (gz->line_width * U.pixelsize) + WM_gizmo_select_bias(select));
|
||||
immUniformColor4fv(color);
|
||||
immBegin(GPU_PRIM_LINE_STRIP, 2);
|
||||
immVertex3fv(pos, matrix_final[3]);
|
||||
|
||||
@@ -154,7 +154,7 @@ static void dial_geom_draw(const float color[4],
|
||||
float viewport[4];
|
||||
GPU_viewport_size_get_f(viewport);
|
||||
immUniform2fv("viewportSize", &viewport[2]);
|
||||
immUniform1f("lineWidth", line_width * U.pixelsize);
|
||||
immUniform1f("lineWidth", line_width);
|
||||
|
||||
if (arc_partial_angle == 0.0f) {
|
||||
imm_draw_circle_wire_3d(pos, 0.0f, 0.0f, 1.0f, DIAL_RESOLUTION);
|
||||
@@ -454,7 +454,9 @@ static void dial_draw_intern(
|
||||
params.arc_partial_angle = arc_partial_angle;
|
||||
params.arc_inner_factor = arc_inner_factor;
|
||||
params.clip_plane = clip_plane;
|
||||
dial_3d_draw_util(matrix_final, gz->line_width, color, select, ¶ms);
|
||||
|
||||
const float line_width = (gz->line_width * U.pixelsize) + WM_gizmo_select_bias(select);
|
||||
dial_3d_draw_util(matrix_final, line_width, color, select, ¶ms);
|
||||
}
|
||||
|
||||
static void gizmo_dial_draw_select(const bContext *C, wmGizmo *gz, int select_id)
|
||||
|
||||
@@ -108,7 +108,7 @@ static void move_geom_draw(const wmGizmo *gz,
|
||||
float viewport[4];
|
||||
GPU_viewport_size_get_f(viewport);
|
||||
immUniform2fv("viewportSize", &viewport[2]);
|
||||
immUniform1f("lineWidth", gz->line_width * U.pixelsize);
|
||||
immUniform1f("lineWidth", (gz->line_width * U.pixelsize) + WM_gizmo_select_bias(select));
|
||||
|
||||
immUniformColor4fv(color);
|
||||
|
||||
|
||||
@@ -108,7 +108,8 @@ static void gizmo_primitive_draw_geom(PrimitiveGizmo3D *gz_prim,
|
||||
const float col_inner[4],
|
||||
const float col_outer[4],
|
||||
const int nsegments,
|
||||
const bool draw_inner)
|
||||
const bool draw_inner,
|
||||
const bool select)
|
||||
{
|
||||
uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
|
||||
const bool use_polyline_shader = gz_prim->gizmo.line_width > 1.0f;
|
||||
@@ -145,7 +146,8 @@ static void gizmo_primitive_draw_geom(PrimitiveGizmo3D *gz_prim,
|
||||
float viewport[4];
|
||||
GPU_viewport_size_get_f(viewport);
|
||||
immUniform2fv("viewportSize", &viewport[2]);
|
||||
immUniform1f("lineWidth", gz_prim->gizmo.line_width * U.pixelsize);
|
||||
immUniform1f("lineWidth",
|
||||
(gz_prim->gizmo.line_width * U.pixelsize) + WM_gizmo_select_bias(select));
|
||||
}
|
||||
|
||||
if (gz_prim->draw_style == ED_GIZMO_PRIMITIVE_STYLE_PLANE) {
|
||||
@@ -185,7 +187,8 @@ static void gizmo_primitive_draw_intern(wmGizmo *gz, const bool select, const bo
|
||||
color_inner,
|
||||
color_outer,
|
||||
select ? 24 : DIAL_RESOLUTION,
|
||||
gz_prim->draw_inner || select);
|
||||
gz_prim->draw_inner || select,
|
||||
select);
|
||||
|
||||
GPU_matrix_pop();
|
||||
|
||||
@@ -200,7 +203,7 @@ static void gizmo_primitive_draw_intern(wmGizmo *gz, const bool select, const bo
|
||||
GPU_matrix_mul(inter->init_matrix_final);
|
||||
|
||||
gizmo_primitive_draw_geom(
|
||||
gz_prim, color_inner, color_outer, DIAL_RESOLUTION, gz_prim->draw_inner);
|
||||
gz_prim, color_inner, color_outer, DIAL_RESOLUTION, gz_prim->draw_inner, select);
|
||||
|
||||
GPU_matrix_pop();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user