mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-12 14:33:28 +00:00
clash ui - make filters expandable for readibility
Example - https://imgur.com/a/ZeVeF3u
This commit is contained in:
@@ -357,8 +357,17 @@ def draw_expandable_panel(
|
|||||||
label: str,
|
label: str,
|
||||||
ui_func: Callable[[bpy.types.UILayout, bpy.types.Context], None],
|
ui_func: Callable[[bpy.types.UILayout, bpy.types.Context], None],
|
||||||
default_closed: bool = True,
|
default_closed: bool = True,
|
||||||
|
*,
|
||||||
|
panel_id: str = "",
|
||||||
) -> None:
|
) -> None:
|
||||||
header, panel = layout.panel(label, default_closed=default_closed)
|
"""
|
||||||
|
:param panel_id: Optional unique identifier for the panel.
|
||||||
|
By default is matching ``label``, but if more than one panel with the same name is used,
|
||||||
|
then ``panel_id`` can be provided explicitly to ensure panels can be expanded/collapsed separately.
|
||||||
|
"""
|
||||||
|
if not panel_id:
|
||||||
|
panel_id = label
|
||||||
|
header, panel = layout.panel(panel_id, default_closed=default_closed)
|
||||||
header.label(text=label)
|
header.label(text=label)
|
||||||
if panel:
|
if panel:
|
||||||
ui_func(panel, context)
|
ui_func(panel, context)
|
||||||
|
|||||||
@@ -87,24 +87,53 @@ class BIM_PT_ifcclash(Panel):
|
|||||||
row.operator("bim.add_clash_source", icon="ADD", text="").group = group
|
row.operator("bim.add_clash_source", icon="ADD", text="").group = group
|
||||||
|
|
||||||
sources = clash_set.get_clash_sources_group(group)
|
sources = clash_set.get_clash_sources_group(group)
|
||||||
|
if not sources:
|
||||||
|
return
|
||||||
|
layout_ = layout.box()
|
||||||
for index, source in enumerate(sources):
|
for index, source in enumerate(sources):
|
||||||
row = layout.row(align=True)
|
row = layout_.row(align=True)
|
||||||
row.prop(source, "name", text="")
|
row.column().label(text="", icon="POINTCLOUD_POINT")
|
||||||
|
|
||||||
|
# Draw user attention to empty filepaths.
|
||||||
|
col = row.column()
|
||||||
|
col.alert = not bool(source.name)
|
||||||
|
col.prop(source, "name", text="", placeholder="source.ifc")
|
||||||
|
|
||||||
op = row.operator("bim.select_clash_source", icon="FILE_FOLDER", text="")
|
op = row.operator("bim.select_clash_source", icon="FILE_FOLDER", text="")
|
||||||
op.index = index
|
op.index = index
|
||||||
op.group = group
|
op.group = group
|
||||||
|
# Make sure file selection sticks to "name" field.
|
||||||
|
row.label(text="", icon="BLANK1")
|
||||||
|
|
||||||
row.prop(source, "mode", text="")
|
row.prop(source, "mode", text="")
|
||||||
op = row.operator("bim.remove_clash_source", icon="X", text="")
|
op = row.operator("bim.remove_clash_source", icon="X", text="")
|
||||||
op.index = index
|
op.index = index
|
||||||
op.group = group
|
op.group = group
|
||||||
|
|
||||||
if source.mode != "a":
|
if source.mode != "a":
|
||||||
bonsai.bim.helper.draw_filter(
|
|
||||||
layout, source.filter_groups, ClashData, f"clash_{props.active_clash_set_index}_{group}_{index}"
|
def draw_filter(layout: bpy.types.UILayout, context: bpy.types.Context) -> None:
|
||||||
|
bonsai.bim.helper.draw_filter(
|
||||||
|
layout,
|
||||||
|
source.filter_groups,
|
||||||
|
ClashData,
|
||||||
|
f"clash_{props.active_clash_set_index}_{group}_{index}",
|
||||||
|
)
|
||||||
|
|
||||||
|
bonsai.bim.helper.draw_expandable_panel(
|
||||||
|
layout_,
|
||||||
|
context,
|
||||||
|
"Filter",
|
||||||
|
draw_filter,
|
||||||
|
default_closed=True,
|
||||||
|
panel_id=f"filter_{group}_{index}",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
layout.separator()
|
||||||
draw_clash_set_group("a")
|
draw_clash_set_group("a")
|
||||||
|
layout.separator()
|
||||||
draw_clash_set_group("b")
|
draw_clash_set_group("b")
|
||||||
|
layout.separator()
|
||||||
|
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
row.prop(props, "should_create_clash_snapshots")
|
row.prop(props, "should_create_clash_snapshots")
|
||||||
|
|||||||
Reference in New Issue
Block a user