mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +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 = cls.layout.row(align=True)
|
||||||
row.separator()
|
row.separator()
|
||||||
row.label(text="Operations") if ui_context != "TOOL_HEADER" else row
|
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":
|
if AuthoringData.data["active_material_usage"] == "LAYER2":
|
||||||
row = cls.layout.row(align=True) if ui_context != "TOOL_HEADER" else row
|
row = cls.layout.row(align=True) if ui_context != "TOOL_HEADER" else row
|
||||||
@@ -962,20 +962,14 @@ class EditObjectUI:
|
|||||||
return row
|
return row
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def draw_regen_operations(cls, row):
|
def draw_regen_operations(cls, row, ui_context):
|
||||||
custom_icon = custom_icon_previews.get("REGEN", custom_icon_previews["IFC"]).icon_id
|
|
||||||
|
|
||||||
if AuthoringData.data["is_regenable_element"]:
|
if AuthoringData.data["is_regenable_element"]:
|
||||||
op = row.operator("bim.hotkey", text="", icon_value=custom_icon)
|
row = cls.layout.row(align=True) if ui_context != "TOOL_HEADER" else row
|
||||||
description = "Recalculate Element Geometry\nHotkey: S G"
|
add_layout_hotkey_operator(row, "Regen", "S_G", "Recalculate Element Geometry", ui_context)
|
||||||
op.hotkey = "S_G"
|
|
||||||
op.description = description.strip()
|
|
||||||
|
|
||||||
if PortData.data["total_ports"] > 0:
|
if PortData.data["total_ports"] > 0:
|
||||||
op = row.operator("bim.hotkey", text="", icon_value=custom_icon)
|
row = cls.layout.row(align=True) if ui_context != "TOOL_HEADER" else row
|
||||||
description = f"{bpy.ops.bim.regenerate_distribution_element.__doc__}\n\nHotkey: S G"
|
add_layout_hotkey_operator(row, "Regen", "S_G", bpy.ops.bim.regenerate_distribution_element.__doc__, ui_context)
|
||||||
op.hotkey = "S_G"
|
|
||||||
op.description = description.strip()
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def draw_void(cls, context, row):
|
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
|
op_text = "" if ui_context == "TOOL_HEADER" else text
|
||||||
modifier_icon, modifier_str = cls.KEY_MODIFIERS.get(modifier, ("NONE", ""))
|
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]
|
module = sys.modules[module_name]
|
||||||
icon_previews: Union[bpy.utils.previews.ImagePreviewCollection, None]
|
icon_previews: Union[bpy.utils.previews.ImagePreviewCollection, None]
|
||||||
icon_previews = getattr(module, "custom_icon_previews", None)
|
icon_previews = getattr(module, "custom_icon_previews", None)
|
||||||
|
|
||||||
|
row = layout if ui_context == "TOOL_HEADER" else layout.row(align=True)
|
||||||
if icon_previews:
|
if icon_previews:
|
||||||
custom_icon = icon_previews.get(text.upper().replace(" ", "_"), icon_previews["IFC"]).icon_id
|
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)
|
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)
|
op = row.operator(operator_to_use, text=op_text)
|
||||||
if ui_context != "TOOL_HEADER":
|
if ui_context != "TOOL_HEADER":
|
||||||
row.label(text="", icon=modifier_icon)
|
row.label(text="", icon=modifier_icon)
|
||||||
|
row.separator(factor=1)
|
||||||
row.label(text="", icon=f"EVENT_{key}")
|
row.label(text="", icon=f"EVENT_{key}")
|
||||||
|
|
||||||
if operator_to_use == hotkey_operator:
|
if operator_to_use == hotkey_operator:
|
||||||
|
|||||||
Reference in New Issue
Block a user