mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-26 10:11:46 +00:00
Element types dropdown + search #6943
Example - https://files.catbox.moe/jv9uxt.png
This commit is contained in:
@@ -360,9 +360,17 @@ def prop_with_search(
|
|||||||
prop_name: str,
|
prop_name: str,
|
||||||
should_click_ok: bool = False,
|
should_click_ok: bool = False,
|
||||||
original_operator_path: Optional[str] = None,
|
original_operator_path: Optional[str] = None,
|
||||||
|
*,
|
||||||
|
button_kwargs: Union[dict[str, Any], None] = None,
|
||||||
**kwargs: Any,
|
**kwargs: Any,
|
||||||
) -> bpy.types.UILayout:
|
) -> bpy.types.UILayout:
|
||||||
"""
|
"""
|
||||||
|
Draw a row with enum prop and enum search operator.
|
||||||
|
|
||||||
|
Search operator appears only in case if there's more than 10 item in enum.
|
||||||
|
|
||||||
|
:arg button_kwargs: kwargs to pass to ``UILayout.operator()``.
|
||||||
|
:arg kwargs: kwargs to pass to ``UILayout.prop()``.
|
||||||
:return: Added row.
|
:return: Added row.
|
||||||
"""
|
"""
|
||||||
# kwargs are layout.prop arguments (text, icon, etc.)
|
# kwargs are layout.prop arguments (text, icon, etc.)
|
||||||
@@ -372,7 +380,7 @@ def prop_with_search(
|
|||||||
if len(get_enum_items(data, prop_name, original_operator_path=original_operator_path)) > 10:
|
if len(get_enum_items(data, prop_name, original_operator_path=original_operator_path)) > 10:
|
||||||
# Magick courtesy of https://blender.stackexchange.com/a/203443/86891
|
# Magick courtesy of https://blender.stackexchange.com/a/203443/86891
|
||||||
row.context_pointer_set(name="data", data=data)
|
row.context_pointer_set(name="data", data=data)
|
||||||
op = row.operator("bim.enum_property_search", text="", icon="VIEWZOOM")
|
op = row.operator("bim.enum_property_search", text="", icon="VIEWZOOM", **(button_kwargs or {}))
|
||||||
op.prop_name = prop_name
|
op.prop_name = prop_name
|
||||||
op.should_click_ok = should_click_ok
|
op.should_click_ok = should_click_ok
|
||||||
op.original_operator_path = original_operator_path or ""
|
op.original_operator_path = original_operator_path or ""
|
||||||
|
|||||||
@@ -654,7 +654,14 @@ class CreateObjectUI:
|
|||||||
row = box.row(align=True)
|
row = box.row(align=True)
|
||||||
thumbnail: int = AuthoringData.type_thumbnails.get(relating_type_data["id"], 0)
|
thumbnail: int = AuthoringData.type_thumbnails.get(relating_type_data["id"], 0)
|
||||||
row.template_icon(icon_value=thumbnail)
|
row.template_icon(icon_value=thumbnail)
|
||||||
row.operator("bim.launch_type_manager", text=relating_type_data["name"], emboss=False)
|
prop_with_search(
|
||||||
|
row,
|
||||||
|
cls.props,
|
||||||
|
"relating_type_id",
|
||||||
|
text="",
|
||||||
|
button_kwargs={"emboss": False},
|
||||||
|
emboss=True,
|
||||||
|
)
|
||||||
row.operator(
|
row.operator(
|
||||||
"bim.launch_type_manager",
|
"bim.launch_type_manager",
|
||||||
icon=tool.Blender.TYPE_MANAGER_ICON,
|
icon=tool.Blender.TYPE_MANAGER_ICON,
|
||||||
|
|||||||
Reference in New Issue
Block a user