UI: avoid excessive padding for labels in headers

Labels in headers reserved space for an icon even when no icon was used.

This is caused by the shared function ui_text_icon_width adding 1.5x
a buttons X-units width the the width of the string.

Menu buttons detected this and subtracted the extra padding.

Instead of adding the same workaround for labels,
add ui_text_icon_width_ex that takes a padding argument.

Add presets for 'default', 'compact' and 'none' to avoid duplicating
padding values.

This allows removal of hard-coded label scaling for the add-object tool.
This commit is contained in:
2021-09-28 14:07:59 +10:00
parent 986d60490c
commit c7d94a7827
2 changed files with 57 additions and 18 deletions

View File

@@ -497,18 +497,14 @@ class _defs_view3d_add:
props = tool.operator_properties("view3d.interactive_add")
if not extra:
row = layout.row()
row.scale_x = 0.8
row.label(text="Depth:")
row = layout.row()
row.scale_x = 0.9
row.prop(props, "plane_depth", text="")
row = layout.row()
row.scale_x = 0.8
row.label(text="Orientation:")
row = layout.row()
row.prop(props, "plane_orientation", text="")
row = layout.row()
row.scale_x = 0.8
row.prop(props, "snap_target")
region_is_header = bpy.context.region.type == 'TOOL_HEADER'