[Bf-blender-cvs] [6daff9a08e7] master: UI: Fix icon width and padding in search menus

Hans Goudey noreply at git.blender.org
Thu Feb 25 17:28:50 CET 2021


Commit: 6daff9a08e79546a28a24a6306d9f067e7f7fa59
Author: Hans Goudey
Date:   Thu Feb 25 10:28:39 2021 -0600
Branches: master
https://developer.blender.org/rB6daff9a08e79546a28a24a6306d9f067e7f7fa59

UI: Fix icon width and padding in search menus

Previously the padding size and the width saved for the icon were
constant regardless of the zoom level. This resulted in overlapping
icons and text, and ugly padding with more extreme zoom levels.
We can retrieve the size of the row from the `rect` argument.

===================================================================

M	source/blender/editors/interface/interface_widgets.c

===================================================================

diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index 5c59d0edeb5..0fa5999976b 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -5237,8 +5237,9 @@ void ui_draw_menu_item(const uiFontStyle *fstyle,
 {
   uiWidgetType *wt = widget_type(UI_WTYPE_MENU_ITEM);
   const rcti _rect = *rect;
+  const int row_height = BLI_rcti_size_y(rect);
   int max_hint_width = INT_MAX;
-  int padding = 0.25f * UI_UNIT_X;
+  int padding = 0.25f * row_height;
   char *cpoin = NULL;
 
   wt->state(wt, state, 0, UI_EMBOSS_UNDEFINED);
@@ -5249,7 +5250,7 @@ void ui_draw_menu_item(const uiFontStyle *fstyle,
   /* text location offset */
   rect->xmin += padding;
   if (iconid) {
-    rect->xmin += UI_DPI_ICON_SIZE;
+    rect->xmin += row_height; /* Use square area for icon. */
   }
 
   /* cut string in 2 parts? */



More information about the Bf-blender-cvs mailing list