mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-06 16:01:36 +00:00
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.
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user