[Bf-blender-cvs] [66e24ce35bb] master: Fix menu width regression in c7d94a7827a5be9343eea22a9638bb059f185206

Campbell Barton noreply at git.blender.org
Thu Sep 30 05:20:25 CEST 2021


Commit: 66e24ce35bb37753b8002283a72d55639bb40239
Author: Campbell Barton
Date:   Thu Sep 30 12:41:01 2021 +1000
Branches: master
https://developer.blender.org/rB66e24ce35bb37753b8002283a72d55639bb40239

Fix menu width regression in c7d94a7827a5be9343eea22a9638bb059f185206

Icon only popup buttons needed to be adjusted too,
add an uiTextIconPadFactor.icon_only to support this.

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

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

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

diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index c10ba3894ea..3437b9ad2ac 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -295,6 +295,7 @@ static bool ui_layout_variable_size(uiLayout *layout)
 struct uiTextIconPadFactor {
   float text;
   float icon;
+  float icon_only;
 };
 
 /**
@@ -309,18 +310,21 @@ struct uiTextIconPadFactor {
 static const struct uiTextIconPadFactor ui_text_pad_default = {
     .text = 1.50f,
     .icon = 0.25f,
+    .icon_only = 0.0f,
 };
 
 /** #ui_text_pad_default scaled down. */
 static const struct uiTextIconPadFactor ui_text_pad_compact = {
     .text = 1.25f,
-    .icon = 0.35,
+    .icon = 0.35f,
+    .icon_only = 0.0f,
 };
 
 /** Least amount of padding not to clip the text or icon. */
 static const struct uiTextIconPadFactor ui_text_pad_none = {
-    .text = 0.25,
+    .text = 0.25f,
     .icon = 1.50f,
+    .icon_only = 0.0f,
 };
 
 /**
@@ -333,14 +337,13 @@ static int ui_text_icon_width_ex(uiLayout *layout,
 {
   const int unit_x = UI_UNIT_X * (layout->scale[0] ? layout->scale[0] : 1.0f);
 
-  if (icon && !name[0]) {
-    return unit_x; /* icon only */
+  /* When there is no text, always behave as if this is an icon-only button
+   * since it's not useful to return empty space. */
+  if (!name[0]) {
+    return unit_x * (1.0f + pad_factor->icon_only);
   }
 
   if (ui_layout_variable_size(layout)) {
-    if (!icon && !name[0]) {
-      return unit_x; /* No icon or name. */
-    }
     if (layout->alignment != UI_LAYOUT_ALIGN_EXPAND) {
       layout->item.flag |= UI_ITEM_FIXED_SIZE;
     }
@@ -2907,11 +2910,10 @@ static uiBut *ui_item_menu(uiLayout *layout,
     }
     else if (force_menu) {
       pad_factor.text = 1.85;
+      pad_factor.icon_only = 0.6f;
     }
     else {
-      if (name[0]) {
-        pad_factor.text = 0.75;
-      }
+      pad_factor.text = 0.75f;
     }
   }



More information about the Bf-blender-cvs mailing list