From 72d89eee8779fb6bad4758d729aec5a1a90fa507 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 4 Mar 2025 10:10:09 +1100 Subject: [PATCH] Fix use of the pixelsize for the size of rounded area bounds Use the scale-factor instead of the pixelsize. Without this, changing the line-width can double or half the size of rounded corners. Ref !135383 --- source/blender/editors/screen/screen_draw.cc | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/source/blender/editors/screen/screen_draw.cc b/source/blender/editors/screen/screen_draw.cc index 052c0a30091..91df017a403 100644 --- a/source/blender/editors/screen/screen_draw.cc +++ b/source/blender/editors/screen/screen_draw.cc @@ -231,7 +231,7 @@ void ED_screen_draw_edges(wmWindow *win) UI_GetThemeColor4fv(TH_EDITOR_BORDER, col); col[3] = 1.0f; - corner_scale = U.pixelsize * 8.0f; + corner_scale = UI_SCALE_FAC * 8.0f; edge_thickness = corner_scale * 0.21f; GPU_blend(GPU_BLEND_ALPHA); @@ -265,7 +265,7 @@ void ED_screen_draw_edges(wmWindow *win) 1.0f, (area == active_area) ? outline2 : outline1, U.pixelsize, - 6.0f * U.pixelsize); + 6.0f * UI_SCALE_FAC); } GPU_blend(GPU_BLEND_NONE); @@ -305,7 +305,7 @@ void screen_draw_move_highlight(bScreen *screen, eScreenAxis dir_axis) float outline[4] = {0.0f, 0.0f, 0.0f, 0.8f}; UI_draw_roundbox_corner_set(UI_CNR_ALL); UI_draw_roundbox_4fv_ex( - &rect, inner, nullptr, 1.0f, outline, 2.0f * U.pixelsize, 2.5f * U.pixelsize); + &rect, inner, nullptr, 1.0f, outline, 2.0f * U.pixelsize, 2.5f * UI_SCALE_FAC); } static void screen_draw_area_drag_tip( @@ -375,7 +375,7 @@ static void screen_draw_area_closed(int xmin, int xmax, int ymin, int ymax) rctf rect = {float(xmin), float(xmax), float(ymin), float(ymax)}; float darken[4] = {0.0f, 0.0f, 0.0f, 0.7f}; UI_draw_roundbox_corner_set(UI_CNR_ALL); - UI_draw_roundbox_4fv_ex(&rect, darken, nullptr, 1.0f, nullptr, U.pixelsize, 6 * U.pixelsize); + UI_draw_roundbox_4fv_ex(&rect, darken, nullptr, 1.0f, nullptr, U.pixelsize, 6 * UI_SCALE_FAC); } void screen_draw_join_highlight(const wmWindow *win, ScrArea *sa1, ScrArea *sa2, eScreenDir dir) @@ -446,7 +446,7 @@ void screen_draw_join_highlight(const wmWindow *win, ScrArea *sa1, ScrArea *sa2, UI_draw_roundbox_corner_set(UI_CNR_ALL); float outline[4] = {1.0f, 1.0f, 1.0f, 0.4f}; float inner[4] = {1.0f, 1.0f, 1.0f, 0.10f}; - UI_draw_roundbox_4fv_ex(&combined, inner, nullptr, 1.0f, outline, U.pixelsize, 6 * U.pixelsize); + UI_draw_roundbox_4fv_ex(&combined, inner, nullptr, 1.0f, outline, U.pixelsize, 6 * UI_SCALE_FAC); screen_draw_area_drag_tip( win, win->eventstate->xy[0], win->eventstate->xy[1], sa1, IFACE_("Join Areas")); @@ -457,7 +457,7 @@ static void rounded_corners(rctf rect, float color[4], int corners) GPUVertFormat *format = immVertexFormat(); const uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); - const float rad = 7 * U.pixelsize; + const float rad = 7 * UI_SCALE_FAC; float vec[4][2] = { {0.195, 0.02}, @@ -576,7 +576,7 @@ void screen_draw_dock_preview(const wmWindow *win, } rounded_corners(dest, border, corners); - UI_draw_roundbox_4fv_ex(&dest, inner, nullptr, 1.0f, outline, U.pixelsize, 6 * U.pixelsize); + UI_draw_roundbox_4fv_ex(&dest, inner, nullptr, 1.0f, outline, U.pixelsize, 6 * UI_SCALE_FAC); if (dock_target != AreaDockTarget::Center) { /* Darken the split position itself. */ @@ -612,7 +612,7 @@ void screen_draw_split_preview(ScrArea *area, const eScreenAxis dir_axis, const if (factor < 0.0001 || factor > 0.9999) { /* Highlight the entire area. */ - UI_draw_roundbox_4fv_ex(&rect, inner, nullptr, 1.0f, outline, U.pixelsize, 7 * U.pixelsize); + UI_draw_roundbox_4fv_ex(&rect, inner, nullptr, 1.0f, outline, U.pixelsize, 7 * UI_SCALE_FAC); return; } @@ -630,7 +630,7 @@ void screen_draw_split_preview(ScrArea *area, const eScreenAxis dir_axis, const border, (dir_axis == SCREEN_AXIS_H) ? UI_CNR_TOP_RIGHT | UI_CNR_TOP_LEFT : UI_CNR_BOTTOM_RIGHT | UI_CNR_TOP_RIGHT); - UI_draw_roundbox_4fv_ex(&rect, inner, nullptr, 1.0f, outline, U.pixelsize, 7 * U.pixelsize); + UI_draw_roundbox_4fv_ex(&rect, inner, nullptr, 1.0f, outline, U.pixelsize, 7 * UI_SCALE_FAC); /* Outlined rectangle to right/below split position. */ if (dir_axis == SCREEN_AXIS_H) { @@ -646,7 +646,7 @@ void screen_draw_split_preview(ScrArea *area, const eScreenAxis dir_axis, const border, (dir_axis == SCREEN_AXIS_H) ? UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT : UI_CNR_BOTTOM_LEFT | UI_CNR_TOP_LEFT); - UI_draw_roundbox_4fv_ex(&rect, inner, nullptr, 1.0f, outline, U.pixelsize, 7 * U.pixelsize); + UI_draw_roundbox_4fv_ex(&rect, inner, nullptr, 1.0f, outline, U.pixelsize, 7 * UI_SCALE_FAC); /* Darken the split position itself. */ if (dir_axis == SCREEN_AXIS_H) {