UI: Header / Tool Settings: Show tool icon when tools are collapsed

Show the scaled down tool icon when the tool region is collapsed. Show a
blank space when the tool region is visible.

* Minimize the UI flickering when changing the active tool.
* Show the active tool when the tool region is collapsed.
* Smaler header footprint (the tool name is not visible).

This is a follow up for T91536.

Differential Revision: https://developer.blender.org/D12939
This commit is contained in:
Dalai Felinto 2021-10-20 16:19:49 +02:00
parent e79e86018e
commit 84bb6d7c02
1 changed files with 8 additions and 4 deletions

View File

@ -190,7 +190,7 @@ class ToolActivePanelHelper:
ToolSelectPanelHelper.draw_active_tool_header(
context,
layout.column(),
show_tool_icon=True,
show_tool_icon_always=True,
tool_key=ToolSelectPanelHelper._tool_key_from_context(context, space_type=self.bl_space_type),
)
@ -766,7 +766,7 @@ class ToolSelectPanelHelper:
def draw_active_tool_header(
context, layout,
*,
show_tool_icon=False,
show_tool_icon_always=False,
tool_key=None,
):
if tool_key is None:
@ -783,11 +783,15 @@ class ToolSelectPanelHelper:
return None
# Note: we could show 'item.text' here but it makes the layout jitter when switching tools.
# Add some spacing since the icon is currently assuming regular small icon size.
if show_tool_icon:
if show_tool_icon_always:
layout.label(text=" " + item.label, icon_value=icon_value)
layout.separator()
else:
layout.label(text=item.label)
if context.space_data.show_region_toolbar:
layout.template_icon(icon_value=0, scale=0.5)
else:
layout.template_icon(icon_value=icon_value, scale=0.5)
layout.separator()
draw_settings = item.draw_settings
if draw_settings is not None: