Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(split type preset): add default option & use grid_flow #252

Merged
merged 1 commit into from
Jan 14, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions addon/i3dio/ui/object.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,8 +508,11 @@ def description(cls, _context, properties):
f"Supports wood harvester: {'Yes' if support_harvester else 'No'}")

def execute(self, context):
preset = SPLIT_TYPE_PRESETS.get(self.preset, {})
i3d_attributes = context.object.i3d_attributes
if self.preset == "Default":
i3d_attributes.split_type = i3d_attributes.i3d_map['split_type']['default']
return {'FINISHED'}
preset = SPLIT_TYPE_PRESETS.get(self.preset, {})
i3d_attributes.split_type = preset['split_type']
return {'FINISHED'}

Expand All @@ -521,17 +524,12 @@ class I3D_IO_MT_split_type_presets(bpy.types.Menu):

def draw(self, _context):
layout = self.layout
row = layout.row(align=False)
col1 = row.column(align=True)
col2 = row.column(align=True)
presets = list(SPLIT_TYPE_PRESETS.keys())
middle = len(presets) // 2

for idx, preset in enumerate(presets):
if idx <= middle:
col1.operator(I3D_IO_OT_set_split_type_preset.bl_idname, text=preset).preset = preset
else:
col2.operator(I3D_IO_OT_set_split_type_preset.bl_idname, text=preset).preset = preset
grid = layout.grid_flow(columns=2, even_columns=True, even_rows=True)
for preset in list(SPLIT_TYPE_PRESETS.keys()):
grid.operator(I3D_IO_OT_set_split_type_preset.bl_idname, text=preset).preset = preset

layout.separator()
layout.operator(I3D_IO_OT_set_split_type_preset.bl_idname, text="Default").preset = "Default"


@register
Expand Down