Refactor mass and time units panel into collapsible section using .panel method in project wizard UI

This commit is contained in:
falken10vdl
2025-09-29 09:31:00 +02:00
parent f222a8ba4f
commit a98cad161e
2 changed files with 13 additions and 20 deletions
@@ -114,7 +114,6 @@ def register():
kmi = km.keymap_items.new("bim.save_project", "S", "PRESS", ctrl=True)
kmi.properties.should_save_as = False
addon_keymaps.append((km, kmi))
bpy.utils.register_class(ui.BIM_PT_mass_time_units)
def unregister():
@@ -132,4 +131,3 @@ def unregister():
for km, kmi in addon_keymaps:
km.keymap_items.remove(kmi)
addon_keymaps.clear()
bpy.utils.unregister_class(ui.BIM_PT_mass_time_units)
+13 -18
View File
@@ -358,29 +358,24 @@ class BIM_PT_new_project_wizard(Panel):
row.prop(props, "volume_unit", text="Volume Unit")
row = self.layout.row()
prop_with_search(self.layout, pprops, "template_file", text="Template")
header, body = self.layout.panel("Mass and Time Units", default_closed=True)
if header:
header.label(text="Mass and Time Units")
if body:
label = "Add Mass and Time Units" if not props.add_mass_time_units else "Remove Mass and Time Units"
body.prop(props, "add_mass_time_units", toggle=True, text=label)
if props.add_mass_time_units:
row = body.row()
row.prop(props, "mass_unit", text="Mass Unit")
row = body.row()
row.prop(props, "time_unit", text="Time Unit")
self.layout.use_property_split = True
row = self.layout.row()
row.operator("bim.create_project")
class BIM_PT_mass_time_units(Panel):
bl_label = "Mass and Time Units"
bl_idname = "BIM_PT_mass_time_units"
bl_options = {"DEFAULT_CLOSED"}
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
bl_context = "scene"
bl_parent_id = "BIM_PT_new_project_wizard"
def draw(self, context):
layout = self.layout
props = tool.Blender.get_bim_props()
label = "Add Mass and Time Units" if not props.add_mass_time_units else "Remove Mass and Time Units"
layout.prop(props, "add_mass_time_units", toggle=True, text=label)
if props.add_mass_time_units:
row = layout.row()
row.prop(props, "mass_unit", text="Mass Unit")
row = layout.row()
row.prop(props, "time_unit", text="Time Unit")
class BIM_PT_project_library(Panel):
bl_label = "Project Library"