From 84123446e3236edfc7a44679ba2db4b587d62bec Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Tue, 4 Mar 2025 18:11:00 +0100 Subject: [PATCH] Fix #135324: Data-block selector icon drawn too big DPI scaling was applied twice. Added an API comment to make this more clear for the caller of the function. This is exactly the changes to main committed in 47bbf3fcaefb2c63661a8ab9098f840925c67a9f, which is a correction to 1f88645728. Pull Request: https://projects.blender.org/blender/blender/pulls/135411 --- source/blender/editors/interface/interface_widgets.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/source/blender/editors/interface/interface_widgets.cc b/source/blender/editors/interface/interface_widgets.cc index 7b698d59f25..7e2eff18fb7 100644 --- a/source/blender/editors/interface/interface_widgets.cc +++ b/source/blender/editors/interface/interface_widgets.cc @@ -1253,6 +1253,8 @@ static void widget_draw_icon_centered(const BIFIconID icon, } /** + * \param aspect: The inverse zoom factor (typically #uiBlock.aspect), with DPI applied (i.e. not + * multiplied by #UI_INV_SCALE_FAC). * \param mono_color: Only for drawing monochrome icons. */ static void widget_draw_preview_icon( @@ -1295,11 +1297,9 @@ static int ui_but_draw_menu_icon(const uiBut *but) static void widget_draw_icon( const uiBut *but, BIFIconID icon, float alpha, const rcti *rect, const uchar mono_color[4]) { - const float aspect = but->block->aspect * UI_INV_SCALE_FAC; - if (but->flag & UI_BUT_ICON_PREVIEW) { GPU_blend(GPU_BLEND_ALPHA); - widget_draw_preview_icon(icon, alpha, aspect, rect, mono_color); + widget_draw_preview_icon(icon, alpha, but->block->aspect, rect, mono_color); GPU_blend(GPU_BLEND_NONE); return; } @@ -1309,6 +1309,7 @@ static void widget_draw_icon( return; } + const float aspect = but->block->aspect * UI_INV_SCALE_FAC; const float height = ICON_DEFAULT_HEIGHT / aspect; /* calculate blend color */ @@ -2274,7 +2275,6 @@ static void widget_draw_text_icon(const uiFontStyle *fstyle, /* Big previews with optional text label below */ if (but->flag & UI_BUT_ICON_PREVIEW && ui_block_is_menu(but->block)) { - const float aspect = but->block->aspect * UI_INV_SCALE_FAC; const BIFIconID icon = ui_but_icon(but); int icon_size = BLI_rcti_size_y(rect); int text_size = 0; @@ -2289,7 +2289,7 @@ static void widget_draw_text_icon(const uiFontStyle *fstyle, /* draw icon in rect above the space reserved for the label */ rect->ymin += text_size; GPU_blend(GPU_BLEND_ALPHA); - widget_draw_preview_icon(icon, alpha, aspect, rect, icon_color); + widget_draw_preview_icon(icon, alpha, but->block->aspect, rect, icon_color); GPU_blend(GPU_BLEND_NONE); /* offset rect to draw label in */