From 719309571e9d8c53b158af4ffb8be9ba0cf3f0cb Mon Sep 17 00:00:00 2001 From: Ryan Schultz Date: Mon, 25 May 2026 09:35:12 -0500 Subject: [PATCH] Improve active tool panel hotkey button display Use add_layout_hotkey_operator for draw_regen_operations so the Regen button shows text and shortcut icons in the sidebar like all other panel buttons. Add a separator between modifier and key icons for readability. --- .../bonsai/bim/module/model/workspace.py | 18 ++++++------------ src/bonsai/bonsai/tool/blender.py | 4 +++- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/bonsai/bonsai/bim/module/model/workspace.py b/src/bonsai/bonsai/bim/module/model/workspace.py index 828fc2c21f..0d9e6305ad 100644 --- a/src/bonsai/bonsai/bim/module/model/workspace.py +++ b/src/bonsai/bonsai/bim/module/model/workspace.py @@ -841,7 +841,7 @@ class EditObjectUI: row = cls.layout.row(align=True) row.separator() row.label(text="Operations") if ui_context != "TOOL_HEADER" else row - cls.draw_regen_operations(row) + cls.draw_regen_operations(row, ui_context) if AuthoringData.data["active_material_usage"] == "LAYER2": row = cls.layout.row(align=True) if ui_context != "TOOL_HEADER" else row @@ -962,20 +962,14 @@ class EditObjectUI: return row @classmethod - def draw_regen_operations(cls, row): - custom_icon = custom_icon_previews.get("REGEN", custom_icon_previews["IFC"]).icon_id - + def draw_regen_operations(cls, row, ui_context): if AuthoringData.data["is_regenable_element"]: - op = row.operator("bim.hotkey", text="", icon_value=custom_icon) - description = "Recalculate Element Geometry\nHotkey: S G" - op.hotkey = "S_G" - op.description = description.strip() + row = cls.layout.row(align=True) if ui_context != "TOOL_HEADER" else row + add_layout_hotkey_operator(row, "Regen", "S_G", "Recalculate Element Geometry", ui_context) if PortData.data["total_ports"] > 0: - op = row.operator("bim.hotkey", text="", icon_value=custom_icon) - description = f"{bpy.ops.bim.regenerate_distribution_element.__doc__}\n\nHotkey: S G" - op.hotkey = "S_G" - op.description = description.strip() + row = cls.layout.row(align=True) if ui_context != "TOOL_HEADER" else row + add_layout_hotkey_operator(row, "Regen", "S_G", bpy.ops.bim.regenerate_distribution_element.__doc__, ui_context) @classmethod def draw_void(cls, context, row): diff --git a/src/bonsai/bonsai/tool/blender.py b/src/bonsai/bonsai/tool/blender.py index 53f91c06da..9e5515d07a 100644 --- a/src/bonsai/bonsai/tool/blender.py +++ b/src/bonsai/bonsai/tool/blender.py @@ -637,10 +637,11 @@ class Blender(bonsai.core.tool.Blender): op_text = "" if ui_context == "TOOL_HEADER" else text modifier_icon, modifier_str = cls.KEY_MODIFIERS.get(modifier, ("NONE", "")) - row = layout if ui_context == "TOOL_HEADER" else layout.row(align=True) module = sys.modules[module_name] icon_previews: Union[bpy.utils.previews.ImagePreviewCollection, None] icon_previews = getattr(module, "custom_icon_previews", None) + + row = layout if ui_context == "TOOL_HEADER" else layout.row(align=True) if icon_previews: custom_icon = icon_previews.get(text.upper().replace(" ", "_"), icon_previews["IFC"]).icon_id op = row.operator(operator_to_use, text=op_text, icon_value=custom_icon) @@ -648,6 +649,7 @@ class Blender(bonsai.core.tool.Blender): op = row.operator(operator_to_use, text=op_text) if ui_context != "TOOL_HEADER": row.label(text="", icon=modifier_icon) + row.separator(factor=1) row.label(text="", icon=f"EVENT_{key}") if operator_to_use == hotkey_operator: