mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 02:02:22 +00:00
materials ui - make expanding/contracting categories more natural
Previously if you had some item active before the category you're trying to expand/cotract it would jump back to that item which was confusing. Now it sets contracted/expanded category as active to prevent that jump. Before - https://imgur.com/a/87ZDnVq After - https://imgur.com/a/B9WOn8I In Blender when we reload materials in collection property it's resetting scroll position in the template_list and setting it based template_list index, so the only way to preserve the scroll position is to manipulate template_list index.
This commit is contained in:
@@ -705,8 +705,12 @@ class ExpandMaterialCategory(bpy.types.Operator):
|
||||
|
||||
def execute(self, context):
|
||||
props = context.scene.BIMMaterialProperties
|
||||
for category in [c for c in props.materials if c.is_category and c.name == self.category]:
|
||||
for index, category in [
|
||||
(i, c) for i, c in enumerate(props.materials)
|
||||
if c.is_category and c.name == self.category
|
||||
]:
|
||||
category.is_expanded = True
|
||||
props.active_material_index = index
|
||||
core.load_materials(tool.Material, props.material_type)
|
||||
return {"FINISHED"}
|
||||
|
||||
@@ -719,8 +723,12 @@ class ContractMaterialCategory(bpy.types.Operator):
|
||||
|
||||
def execute(self, context):
|
||||
props = context.scene.BIMMaterialProperties
|
||||
for category in [c for c in props.materials if c.is_category and c.name == self.category]:
|
||||
for index, category in [
|
||||
(i, c) for i, c in enumerate(props.materials)
|
||||
if c.is_category and c.name == self.category
|
||||
]:
|
||||
category.is_expanded = False
|
||||
props.active_material_index = index
|
||||
core.load_materials(tool.Material, props.material_type)
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user