mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
Add tool.Blender.KEY_MODIFIERS instead of storing it at workspaces
This commit is contained in:
@@ -337,7 +337,7 @@ def add_layout_hotkey_operator(
|
||||
modifier, key = parts
|
||||
op_text = "" if ui_context == "TOOL_HEADER" else text
|
||||
custom_icon = custom_icon_previews.get(text.upper().replace(" ", "_"), custom_icon_previews["IFC"]).icon_id
|
||||
modifier_icon, modifier_str = MODIFIERS.get(modifier, ("NONE", ""))
|
||||
modifier_icon, modifier_str = tool.Blender.KEY_MODIFIERS.get(modifier, ("NONE", ""))
|
||||
|
||||
row = layout if ui_context == "TOOL_HEADER" else layout.row(align=True)
|
||||
op = row.operator("bim.cad_hotkey", text=op_text, icon_value=custom_icon)
|
||||
@@ -357,7 +357,3 @@ def add_layout_hotkey_operator(
|
||||
|
||||
custom_icon_previews = None
|
||||
display_mode = None
|
||||
|
||||
MODIFIERS = {
|
||||
"S": ("EVENT_SHIFT", "⇧"),
|
||||
}
|
||||
|
||||
@@ -383,7 +383,7 @@ def add_layout_hotkey_operator(
|
||||
|
||||
op_text = "" if ui_context == "TOOL_HEADER" else text
|
||||
custom_icon = custom_icon_previews.get(text.upper().replace(" ", "_"), custom_icon_previews["IFC"]).icon_id
|
||||
modifier_icon, modifier_str = MODIFIERS.get(modifier, ("NONE", ""))
|
||||
modifier_icon, modifier_str = tool.Blender.KEY_MODIFIERS.get(modifier, ("NONE", ""))
|
||||
|
||||
row = layout.row(align=True)
|
||||
op = row.operator(operator, text=op_text, icon_value=custom_icon)
|
||||
@@ -1441,10 +1441,3 @@ class Hotkey(bpy.types.Operator, tool.Ifc.Operator):
|
||||
|
||||
custom_icon_previews = None
|
||||
display_mode = None
|
||||
|
||||
MODIFIERS = {
|
||||
"A": ("EVENT_ALT", "OPTION" if sys.platform == "Darwin" else "ALT"),
|
||||
"C": ("EVENT_CTRL", "CTRL"),
|
||||
"S": ("EVENT_SHIFT", "⇧"),
|
||||
"E": ("EVENT_PADENTER", "ENTER" if sys.platform == "Darwin" else "RETURN"),
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
# along with Bonsai. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import annotations
|
||||
import sys
|
||||
import bpy
|
||||
import bmesh
|
||||
import json
|
||||
@@ -490,18 +491,22 @@ class Blender(bonsai.core.tool.Blender):
|
||||
)
|
||||
return keymap
|
||||
|
||||
KEY_MODIFIERS = {
|
||||
"A": ("EVENT_ALT", "OPTION" if sys.platform == "Darwin" else "ALT"),
|
||||
"C": ("EVENT_CTRL", "CTRL"),
|
||||
"S": ("EVENT_SHIFT", "⇧"),
|
||||
"E": ("EVENT_PADENTER", "ENTER" if sys.platform == "Darwin" else "RETURN"),
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def add_layout_hotkey_operator(
|
||||
cls, tool_name: str, layout: bpy.types.UILayout, text: str, hotkey: str, description: str
|
||||
) -> tuple[bpy.types.OperatorProperties, bpy.types.UILayout]:
|
||||
modifiers = {
|
||||
"A": "EVENT_ALT",
|
||||
"S": "EVENT_SHIFT",
|
||||
}
|
||||
modifier, key = hotkey.split("_")
|
||||
|
||||
row = layout.row(align=True)
|
||||
row.label(text="", icon=modifiers[modifier])
|
||||
modifier_icon, modifier_str = cls.KEY_MODIFIERS.get(modifier, ("NONE", ""))
|
||||
row.label(text="", icon=modifier_icon)
|
||||
row.label(text="", icon=f"EVENT_{key}")
|
||||
|
||||
op = row.operator(f"bim.{tool_name}_hotkey", text=text)
|
||||
|
||||
Reference in New Issue
Block a user