From e0d9621d3e4285222f2906b4308b38b40fba74e3 Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Mon, 28 Aug 2023 17:16:51 -0700 Subject: [PATCH 1/2] UI: Node Grid Adjustments for Line Width Have Line Width change Node Grid point size but NOT grid spacing. --- source/blender/editors/include/ED_node_c.hh | 2 +- source/blender/editors/interface/view2d.cc | 14 ++++++++++---- source/blender/editors/space_node/node_draw.cc | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/source/blender/editors/include/ED_node_c.hh b/source/blender/editors/include/ED_node_c.hh index ad100f511cc..62dca4b5700 100644 --- a/source/blender/editors/include/ED_node_c.hh +++ b/source/blender/editors/include/ED_node_c.hh @@ -30,7 +30,7 @@ enum NodeBorder { }; ENUM_OPERATORS(NodeBorder, NODE_RIGHT) -#define NODE_GRID_STEP_SIZE U.widget_unit /* Based on the grid nodes snap to. */ +#define NODE_GRID_STEP_SIZE (20.0f * UI_SCALE_FAC) /* Based on the grid nodes snap to. */ #define NODE_EDGE_PAN_INSIDE_PAD 2 #define NODE_EDGE_PAN_OUTSIDE_PAD 0 /* Disable clamping for node panning, use whole screen. */ #define NODE_EDGE_PAN_SPEED_RAMP 1 diff --git a/source/blender/editors/interface/view2d.cc b/source/blender/editors/interface/view2d.cc index a08627150de..44633ea9dda 100644 --- a/source/blender/editors/interface/view2d.cc +++ b/source/blender/editors/interface/view2d.cc @@ -1308,7 +1308,7 @@ void UI_view2d_dot_grid_draw(const View2D *v2d, immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR); /* Scaling the dots fully with the zoom looks too busy, but a bit of size variation is nice. */ - const float min_point_size = 2.0f * UI_SCALE_FAC; + const float min_point_size = 2.0f * U.pixelsize; const float point_size_factor = 1.5f; const float max_point_size = point_size_factor * min_point_size; @@ -1330,6 +1330,9 @@ void UI_view2d_dot_grid_draw(const View2D *v2d, const float point_size_draw = ceilf( clamp_f(point_size_precise, min_point_size, max_point_size)); + /* Offset point by this amount to better align centers as size changes. */ + const float point_size_offset = point_size_draw / 2.0f; + /* To compensate the for the clamped point_size we adjust the alpha to make the overall * brightness of the grid background more consistent. */ const float alpha = pow2f(point_size_precise / point_size_draw); @@ -1353,10 +1356,13 @@ void UI_view2d_dot_grid_draw(const View2D *v2d, const float step = min_step * level_scale; int count_x; float start_x; - grid_axis_start_and_count(step, v2d->cur.xmin, v2d->cur.xmax, &start_x, &count_x); + /* Count points that fit in viewport minus space for the scrollbars. */ + grid_axis_start_and_count( + step, v2d->cur.xmin, v2d->cur.xmax - (1.5f * U.widget_unit), &start_x, &count_x); int count_y; float start_y; - grid_axis_start_and_count(step, v2d->cur.ymin, v2d->cur.ymax, &start_y, &count_y); + grid_axis_start_and_count( + step, v2d->cur.ymin + (1.2f * U.widget_unit), v2d->cur.ymax, &start_y, &count_y); if (count_x == 0 || count_y == 0) { continue; } @@ -1371,7 +1377,7 @@ void UI_view2d_dot_grid_draw(const View2D *v2d, for (int i_x = 0; i_x < count_x; i_x++) { const float x = start_x + step * i_x; immAttr4fv(color_id, color); - immVertex2f(pos, x, y); + immVertex2f(pos, x + point_size_offset, y + point_size_offset); } } diff --git a/source/blender/editors/space_node/node_draw.cc b/source/blender/editors/space_node/node_draw.cc index e72de7a93b7..9c478fcc66c 100644 --- a/source/blender/editors/space_node/node_draw.cc +++ b/source/blender/editors/space_node/node_draw.cc @@ -130,7 +130,7 @@ struct TreeDrawContext { float ED_node_grid_size() { - return U.widget_unit; + return NODE_GRID_STEP_SIZE; } void ED_node_tree_update(const bContext *C) -- 2.30.2 From 19e91d9b1b20ad697f152b9e041e5ee13a0b3e83 Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Mon, 28 Aug 2023 20:47:15 -0700 Subject: [PATCH 2/2] Slightly better sport center offset. Using scroll size defines. --- source/blender/editors/interface/view2d.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/source/blender/editors/interface/view2d.cc b/source/blender/editors/interface/view2d.cc index 44633ea9dda..36e7a671610 100644 --- a/source/blender/editors/interface/view2d.cc +++ b/source/blender/editors/interface/view2d.cc @@ -1331,7 +1331,7 @@ void UI_view2d_dot_grid_draw(const View2D *v2d, clamp_f(point_size_precise, min_point_size, max_point_size)); /* Offset point by this amount to better align centers as size changes. */ - const float point_size_offset = point_size_draw / 2.0f; + const float point_size_offset = (point_size_draw / 2.0f) - U.pixelsize; /* To compensate the for the clamped point_size we adjust the alpha to make the overall * brightness of the grid background more consistent. */ @@ -1356,13 +1356,14 @@ void UI_view2d_dot_grid_draw(const View2D *v2d, const float step = min_step * level_scale; int count_x; float start_x; + /* Count points that fit in viewport minus space for the scrollbars. */ grid_axis_start_and_count( - step, v2d->cur.xmin, v2d->cur.xmax - (1.5f * U.widget_unit), &start_x, &count_x); + step, v2d->cur.xmin, v2d->cur.xmax - V2D_SCROLL_WIDTH, &start_x, &count_x); int count_y; float start_y; grid_axis_start_and_count( - step, v2d->cur.ymin + (1.2f * U.widget_unit), v2d->cur.ymax, &start_y, &count_y); + step, v2d->cur.ymin + V2D_SCROLL_HEIGHT, v2d->cur.ymax, &start_y, &count_y); if (count_x == 0 || count_y == 0) { continue; } -- 2.30.2