mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 06:39:13 +00:00
Search button now only displays when an enum has more than 10 items
To reduce visual clutter for enums with only a few values Also tweak the online docs ui function
This commit is contained in:
@@ -118,11 +118,12 @@ def export_attributes(props, callback=None):
|
|||||||
def prop_with_search(layout, data, prop_name, **kwargs):
|
def prop_with_search(layout, data, prop_name, **kwargs):
|
||||||
# kwargs are layout.prop arguments (text, icon, etc.)
|
# kwargs are layout.prop arguments (text, icon, etc.)
|
||||||
row = layout.row(align=True)
|
row = layout.row(align=True)
|
||||||
# Magick courtesy of https://blender.stackexchange.com/a/203443/86891
|
|
||||||
row.context_pointer_set(name="data", data=data)
|
|
||||||
row.prop(data, prop_name, **kwargs)
|
row.prop(data, prop_name, **kwargs)
|
||||||
op = row.operator("bim.enum_property_search", text="", icon="VIEWZOOM")
|
if len(get_enum_items(data, prop_name)) > 10:
|
||||||
op.prop_name = prop_name
|
# Magick courtesy of https://blender.stackexchange.com/a/203443/86891
|
||||||
|
row.context_pointer_set(name="data", data=data)
|
||||||
|
op = row.operator("bim.enum_property_search", text="", icon="VIEWZOOM")
|
||||||
|
op.prop_name = prop_name
|
||||||
|
|
||||||
|
|
||||||
def get_enum_items(data, prop_name, context=None):
|
def get_enum_items(data, prop_name, context=None):
|
||||||
|
|||||||
@@ -385,10 +385,12 @@ class BIM_PT_misc_object(Panel):
|
|||||||
|
|
||||||
|
|
||||||
def draw_custom_context_menu(self, context):
|
def draw_custom_context_menu(self, context):
|
||||||
layout = self.layout
|
|
||||||
layout.separator()
|
|
||||||
# https://blender.stackexchange.com/a/275555/86891
|
# https://blender.stackexchange.com/a/275555/86891
|
||||||
prop_value = getattr(context.button_pointer, context.button_prop.identifier)
|
prop = context.button_pointer
|
||||||
|
prop_name = context.button_prop.identifier
|
||||||
|
prop_value = getattr(prop, prop_name, None)
|
||||||
|
if prop_value is None:
|
||||||
|
return
|
||||||
try:
|
try:
|
||||||
url = get_ifc_entity_doc_url(prop_value)
|
url = get_ifc_entity_doc_url(prop_value)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
@@ -396,5 +398,7 @@ def draw_custom_context_menu(self, context):
|
|||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
if url:
|
if url:
|
||||||
url_op = layout.operator("bim.open_webbrowser", icon="URL", text="Open IFC Documentation")
|
layout = self.layout
|
||||||
|
layout.separator()
|
||||||
|
url_op = layout.operator("bim.open_webbrowser", icon="URL", text="Online IFC Documentation")
|
||||||
url_op.url = url
|
url_op.url = url
|
||||||
|
|||||||
Reference in New Issue
Block a user