From 40f956ae9a5bb267c1f5e7571ad8652508c2b2a0 Mon Sep 17 00:00:00 2001 From: ethan Date: Tue, 17 Dec 2024 13:13:12 -0500 Subject: [PATCH] Small UI refactor --- ui.py | 154 ++++++++++++++++++++++++++-------------------------------- 1 file changed, 70 insertions(+), 84 deletions(-) diff --git a/ui.py b/ui.py index 1890701..b5b3c71 100644 --- a/ui.py +++ b/ui.py @@ -29,14 +29,39 @@ def draw_header_preset(self, _context: Context): # pylint: disable=no-value-for-parameter GRABDOC_PT_presets.draw_panel_header(self.layout) + def marmo_header_layout(self, layout: UILayout): + preferences = bpy.context.preferences.addons[__package__].preferences + marmo_executable = preferences.marmo_executable + + col = layout.column(align=True) + row = col.row() + if not os.path.exists(marmo_executable): + row.alignment = 'CENTER' + row.label(text="Marmoset Toolbag Executable Required", icon='INFO') + row = col.row() + row.prop(preferences, 'marmo_executable', text="Executable Path") + return + row.prop(preferences, 'marmo_executable', text="Executable Path") + row = col.row(align=True) + row.scale_y = 1.25 + row.operator( + "grab_doc.bake_marmoset", + text="Bake in Marmoset", icon="EXPORT" + ).send_type = 'open' + row.operator( + "grab_doc.bake_marmoset", + text="", icon='FILE_REFRESH' + ).send_type = 'refresh' + def draw(self, context: Context): gd = context.scene.gd - layout = self.layout + + # Scene box = layout.box() scene_setup = proper_scene_setup() - split = box.split(factor=.65 if scene_setup else .9) - split.label(text="Scene Settings", icon="SCENE_DATA") + split = box.split(factor=.5 if scene_setup else .9) + split.label(text="Scene", icon="SCENE_DATA") if scene_setup: col = split.column(align=True) in_trim_cam = camera_in_3d_view() @@ -45,29 +70,10 @@ def draw(self, context: Context): text="Leave" if in_trim_cam else "View", icon="OUTLINER_OB_CAMERA" ) - col = box.column(align=True) - col.label(text="Camera Restrictions") - row = col.row(align=True) - row.prop( - gd, "coll_selectable", text="Select", - icon='RESTRICT_SELECT_OFF' if gd.coll_selectable else 'RESTRICT_SELECT_ON' - ) - row.prop( - gd, "coll_visible", text="Visible", - icon='RESTRICT_VIEW_OFF' if gd.coll_visible else 'RESTRICT_VIEW_ON' - ) - row.prop( - gd, "coll_rendered", text="Render", - icon='RESTRICT_RENDER_OFF' if gd.coll_rendered else 'RESTRICT_RENDER_ON' - ) - - box.use_property_split = True - box.use_property_decorate = False col = box.column(align=True) row = col.row(align=True) - row.scale_x = 1.25 - row.scale_y = 1.25 + row.scale_x = row.scale_y = 1.25 row.operator( "grab_doc.setup_scene", text="Rebuild Scene" if scene_setup else "Setup Scene", @@ -75,9 +81,26 @@ def draw(self, context: Context): ) if not scene_setup: return - row.operator("grab_doc.remove_setup", text="", icon="CANCEL") + col.label(text="Camera Restrictions") + row = col.row(align=True) + row.prop( + gd, "coll_selectable", text="Select", + icon='RESTRICT_SELECT_OFF' if gd.coll_selectable else 'RESTRICT_SELECT_ON' + ) + row.prop( + gd, "coll_visible", text="Visible", + icon='RESTRICT_VIEW_OFF' if gd.coll_visible else 'RESTRICT_VIEW_ON' + ) + row.prop( + gd, "coll_rendered", text="Render", + icon='RESTRICT_RENDER_OFF' if gd.coll_rendered else 'RESTRICT_RENDER_ON' + ) + + box.use_property_split = True + box.use_property_decorate = False + col = box.column() col.prop(gd, "scale", text='Scaling', expand=True) row = col.row() @@ -93,68 +116,33 @@ def draw(self, context: Context): row.prop(gd, "reference", text='Reference') row.operator("grab_doc.load_reference", text="", icon='FILE_FOLDER') + # Output + self.export_path_exists = \ + os.path.exists(bpy.path.abspath(gd.export_path)) -class GRABDOC_PT_export(PanelInfo, Panel): - bl_label = 'Export Maps' - bl_parent_id = "GRABDOC_PT_grabdoc" + layout = self.layout + layout.activate_init = True + layout.use_property_split = True + layout.use_property_decorate = False - @classmethod - def poll(cls, _context: Context) -> bool: - return proper_scene_setup() + box = layout.box() + + split = box.split(factor=.5) + split.label(text="Output", icon="OUTPUT") - def draw_header_preset(self, context: Context): gd = context.scene.gd preferences = bpy.context.preferences.addons[__package__].preferences marmo_executable = preferences.marmo_executable - layout = self.layout + row = split.row(align=True) if gd.baker_type == 'marmoset' \ and not os.path.exists(marmo_executable): - layout.enabled = False - layout.operator( - "grab_doc.export_maps", - text="Export", icon="EXPORT" - ) - - def marmo_header_layout(self, layout: UILayout): - preferences = bpy.context.preferences.addons[__package__].preferences - marmo_executable = preferences.marmo_executable - - col = layout.column(align=True) - row = col.row() - if not os.path.exists(marmo_executable): - row.alignment = 'CENTER' - row.label(text="Marmoset Toolbag Executable Required", icon='INFO') - row = col.row() - row.prop(preferences, 'marmo_executable', text="Executable Path") - return - row.prop(preferences, 'marmo_executable', text="Executable Path") - row = col.row(align=True) - row.scale_y = 1.25 - row.operator( - "grab_doc.bake_marmoset", - text="Bake in Marmoset", icon="EXPORT" - ).send_type = 'open' - row.operator( - "grab_doc.bake_marmoset", - text="", icon='FILE_REFRESH' - ).send_type = 'refresh' - - def draw(self, context: Context): - gd = context.scene.gd - self.export_path_exists = \ - os.path.exists(bpy.path.abspath(gd.export_path)) - - layout = self.layout - layout.activate_init = True - layout.use_property_split = True - layout.use_property_decorate = False + row.enabled = False + row.operator("grab_doc.export_maps", + text="Export", icon="EXPORT") if gd.baker_type == 'marmoset': - self.marmo_header_layout(layout) - - box = layout.box() - box.label(text="Output Settings", icon="OUTPUT") + self.marmo_header_layout(box) col2 = box.column() #row = col2.row() @@ -203,7 +191,7 @@ def draw(self, context: Context): row.prop(gd, "png_compression", text="Compression") elif gd.format == "OPEN_EXR": row.prop(image_settings, "exr_codec", text="Codec") - else: # TIFF + else: # TIFF row.prop(image_settings, "tiff_codec", text="Codec") if gd.baker_type == "marmoset": @@ -236,7 +224,7 @@ def draw(self, context: Context): class GRABDOC_PT_view_edit_maps(PanelInfo, Panel): - bl_label = 'Edit Maps' + bl_label = 'Bake Maps' bl_parent_id = "GRABDOC_PT_grabdoc" @classmethod @@ -244,12 +232,11 @@ def poll(cls, _context: Context) -> bool: return proper_scene_setup() def draw_header_preset(self, _context: Context): - self.layout.operator( - "grab_doc.config_maps", - emboss=False, - text="", - icon="SETTINGS" - ) + layout = self.layout + + row = layout.row(align=True) + row.operator("grab_doc.config_maps", + emboss=False, text="", icon="SETTINGS") def draw(self, context: Context): gd = context.scene.gd @@ -392,7 +379,6 @@ class GRABDOC_PT_metallic(BakerPanel, PanelInfo, Panel): classes = ( GRABDOC_PT_grabdoc, - GRABDOC_PT_export, GRABDOC_PT_view_edit_maps, GRABDOC_PT_pack_maps, GRABDOC_PT_normals,