From f4768033d876ed23567a71a2897c19c46753f788 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Sat, 27 Aug 2011 13:38:53 +0000 Subject: Addon UI Cleanup, Part 2 * You only have to do layout.prop if you want 1 property, no need for row then! * Use col, row, sub as variable names, not colsub, rowsub, row2 etc please. * Povray Addon: Still used a lot of splits, you need no split when you only have 1 column! --- development_api_navigator.py | 5 +-- io_import_gimp_image_to_scene.py | 2 ++ io_import_images_as_planes.py | 3 ++ io_import_scene_mhx.py | 3 +- light_field_tools/light_field_tools.py | 23 ++++++------ mesh_bsurfaces.py | 12 ++----- mesh_inset/__init__.py | 2 +- mocap/__init__.py | 32 +++++++++-------- object_cloud_gen.py | 5 --- render_povray/ui.py | 65 +++++++++++----------------------- rigify/ui.py | 7 ++-- space_view3d_3d_navigation.py | 19 +++++----- space_view3d_math_vis/__init__.py | 6 +--- system_demo_mode/__init__.py | 25 +++++++------ texture_paint_layer_manager.py | 19 ++++------ 15 files changed, 92 insertions(+), 136 deletions(-) diff --git a/development_api_navigator.py b/development_api_navigator.py index 6e7079af..23e0f0f6 100644 --- a/development_api_navigator.py +++ b/development_api_navigator.py @@ -627,9 +627,10 @@ class OBJECT_PT_api_navigator(ApiNavigator, bpy.types.Panel): ###### layout ###### layout = self.layout - col = layout.column() - layout.label(text='Tree Structure') + + layout.label(text="Tree Structure:") col = layout.column(align=True) + col.prop(bpy.context.window_manager.api_nav_props, 'path', text='') row = col.row() row.operator("api_navigator.parent", text="Parent", icon="BACK") diff --git a/io_import_gimp_image_to_scene.py b/io_import_gimp_image_to_scene.py index e0f6a7aa..4632c227 100644 --- a/io_import_gimp_image_to_scene.py +++ b/io_import_gimp_image_to_scene.py @@ -606,6 +606,7 @@ class GIMPImageToScene(bpy.types.Operator): def draw(self, context): layout = self.layout + box = layout.box() box.label('3D Layers:', icon='SORTSIZE') box.prop(self, 'SetCamera', icon='OUTLINER_DATA_CAMERA') @@ -616,6 +617,7 @@ class GIMPImageToScene(bpy.types.Operator): box.prop(self, 'ShadelessMats', icon='SOLID') box.prop(self, 'LayerOffset') box.prop(self, 'LayerScale') + box = layout.box() box.label('Compositing:', icon='RENDERLAYERS') box.prop(self, 'SetupCompo', icon='NODETREE') diff --git a/io_import_images_as_planes.py b/io_import_images_as_planes.py index 4770ceb9..7c5c6fd1 100644 --- a/io_import_images_as_planes.py +++ b/io_import_images_as_planes.py @@ -314,18 +314,21 @@ class IMPORT_OT_image_to_plane(bpy.types.Operator, ImportHelper, AddObjectHelper ## DRAW ## def draw(self, context): layout = self.layout + box = layout.box() box.label('Import Options:', icon='FILTER') box.prop(self, 'all_in_directory') box.prop(self, 'extension', icon='FILE_IMAGE') box.prop(self, 'align') box.prop(self, 'align_offset') + box = layout.box() box.label('Material mappings:', icon='MATERIAL') box.prop(self, 'use_shadeless') box.prop(self, 'use_transparency') box.prop(self, 'use_premultiply') box.prop(self, 'transparency_method', expand=True) + box = layout.box() box.label('Plane dimensions:', icon='ARROW_LEFTRIGHT') box.prop(self, 'use_dimension') diff --git a/io_import_scene_mhx.py b/io_import_scene_mhx.py index 69a70587..eb31353a 100644 --- a/io_import_scene_mhx.py +++ b/io_import_scene_mhx.py @@ -2907,8 +2907,7 @@ class RigifyMhxPanel(bpy.types.Panel): return False def draw(self, context): - layout = self.layout - layout.operator("mhxrig.rigify_mhx") + self.layout.operator("mhxrig.rigify_mhx") return ################################################################################### diff --git a/light_field_tools/light_field_tools.py b/light_field_tools/light_field_tools.py index 2251591b..89aa80fa 100644 --- a/light_field_tools/light_field_tools.py +++ b/light_field_tools/light_field_tools.py @@ -401,12 +401,11 @@ class VIEW3D_OT_lightfield_tools(bpy.types.Panel): bl_label = "Light Field Tools" def draw(self, context): + layout = self.layout + scene = context.scene - layout = self.layout - layout.row() # XXX, is this needed? col = layout.column() - col.prop(scene.lightfield, "row_length") col.prop(scene.lightfield, "angle") @@ -416,18 +415,16 @@ class VIEW3D_OT_lightfield_tools(bpy.types.Panel): col.prop(scene.lightfield, "animate_camera") col.prop(scene.lightfield, "do_projection") - sub = layout.row() - sub.enabled = scene.lightfield.do_projection - subcol = sub.column(align=True) - subcol.prop(scene.lightfield, "texture_path") - subcol.prop(scene.lightfield, "light_intensity") - subcol.prop(scene.lightfield, "spot_blend") + col = layout.column(align=True) + col.enabled = scene.lightfield.do_projection + col.prop(scene.lightfield, "texture_path") + col.prop(scene.lightfield, "light_intensity") + col.prop(scene.lightfield, "spot_blend") # create a basemesh - sub = layout.row() - subcol = sub.column(align=True) - subcol.operator("object.create_lightfield_basemesh", "Create Base Grid") - subcol.prop(scene.lightfield, "spacing") + col = layout.column(align=True) + col.operator("object.create_lightfield_basemesh", "Create Base Grid") + col.prop(scene.lightfield, "spacing") layout.operator("object.create_lightfield_rig", "Create Rig") diff --git a/mesh_bsurfaces.py b/mesh_bsurfaces.py index 40cf891c..6f131148 100644 --- a/mesh_bsurfaces.py +++ b/mesh_bsurfaces.py @@ -53,21 +53,15 @@ class VIEW3D_PT_tools_SURF_SKETCH(bpy.types.Panel): layout = self.layout scn = context.scene - ob = context.object col = layout.column(align=True) - row = layout.row() - row.separator() col.operator("gpencil.surfsk_add_surface", text="Add Surface") col.prop(scn, "SURFSK_edges_U") col.prop(scn, "SURFSK_edges_V") - row.separator() - col.prop(scn, "SURFSK_keep_strokes") - col.separator() - row.separator() - col.operator("gpencil.surfsk_strokes_to_curves", text="Strokes to curves") - + layout.prop(scn, "SURFSK_keep_strokes") + layout.operator("gpencil.surfsk_strokes_to_curves", text="Strokes to curves") + class GPENCIL_OT_SURFSK_add_surface(bpy.types.Operator): bl_idname = "gpencil.surfsk_add_surface" diff --git a/mesh_inset/__init__.py b/mesh_inset/__init__.py index 95a03830..d589cabd 100644 --- a/mesh_inset/__init__.py +++ b/mesh_inset/__init__.py @@ -90,7 +90,7 @@ class Inset(bpy.types.Operator): def draw(self, context): layout = self.layout box = layout.box() - box.label("Inset Options") + box.label("Inset Options:") box.prop(self, "scale") box.prop(self, "inset_amount") box.prop(self, "inset_height") diff --git a/mocap/__init__.py b/mocap/__init__.py index 1e9f125c..e3dc302a 100644 --- a/mocap/__init__.py +++ b/mocap/__init__.py @@ -257,24 +257,28 @@ class MocapPanel(bpy.types.Panel): bl_context = "object" def draw(self, context): - self.layout.label("Preprocessing") - row = self.layout.row(align=True) - row.alignment = 'EXPAND' + layout = self.layout() + + layout.label("Preprocessing:") + + row = layout.row(align=True) row.operator("mocap.denoise", text='Clean noise') row.operator("mocap.rotate_fix", text='Fix BVH Axis Orientation') row.operator("mocap.scale_fix", text='Auto scale Performer') - row2 = self.layout.row(align=True) - row2.operator("mocap.looper", text='Loop animation') - row2.operator("mocap.limitdof", text='Constrain Rig') - row2.operator("mocap.removelimitdof", text='Unconstrain Rig') - self.layout.label("Retargeting") + + row = layout.row(align=True) + row.operator("mocap.looper", text='Loop animation') + row.operator("mocap.limitdof", text='Constrain Rig') + row.operator("mocap.removelimitdof", text='Unconstrain Rig') + + layout.label("Retargeting:") enduser_obj = bpy.context.active_object performer_obj = [obj for obj in bpy.context.selected_objects if obj != enduser_obj] if enduser_obj is None or len(performer_obj) != 1: - self.layout.label("Select performer rig and target rig (as active)") + layout.label("Select performer rig and target rig (as active)") else: - self.layout.operator("mocap.guessmapping", text="Guess Hiearchy Mapping") - labelRow = self.layout.row(align=True) + layout.operator("mocap.guessmapping", text="Guess Hiearchy Mapping") + labelRow = layout.row(align=True) labelRow.label("Performer Rig") labelRow.label("End user Rig") performer_obj = performer_obj[0] @@ -283,7 +287,7 @@ class MocapPanel(bpy.types.Panel): perf = performer_obj.data enduser_arm = enduser_obj.data perf_pose_bones = enduser_obj.pose.bones - MappingRow = self.layout.row(align=True) + MappingRow = layout.row(align=True) footCol = MappingRow.column(align=True) nameCol = MappingRow.column(align=True) nameCol.scale_x = 2 @@ -316,7 +320,7 @@ class MocapPanel(bpy.types.Panel): twistCol.label(" ") IKCol.label(" ") IKLabel.label(" ") - mapRow = self.layout.row() + mapRow = layout.row() mapRow.operator("mocap.savemapping", text='Save mapping') mapRow.operator("mocap.loadmapping", text='Load mapping') extraSettings = self.layout.box() @@ -324,7 +328,7 @@ class MocapPanel(bpy.types.Panel): extraSettings.prop(data=performer_obj.animation_data.action, property='name', text='Action Name') extraSettings.prop(enduser_arm, "frameStep") extraSettings.prop(enduser_arm, "advancedRetarget", text='Advanced Retarget') - self.layout.operator("mocap.retarget", text='RETARGET!') + layout.operator("mocap.retarget", text='RETARGET!') class MocapConstraintsPanel(bpy.types.Panel): diff --git a/object_cloud_gen.py b/object_cloud_gen.py index a97f47bb..a6308683 100644 --- a/object_cloud_gen.py +++ b/object_cloud_gen.py @@ -321,26 +321,21 @@ class VIEW3D_PT_tools_cloud(bpy.types.Panel): WhatToDo = getActionToDo(active_obj) if WhatToDo == 'DEGENERATE': - col.operator("cloud.generate_cloud", text="DeGenerate") elif WhatToDo == 'CLOUD_CONVERT_TO_MESH': - col.operator("cloud.generate_cloud", text="Convert to Mesh") elif WhatToDo == 'NO_SELECTION_DO_NOTHING': - col.label(text="Select one or more") col.label(text="objects to generate") col.label(text="a cloud.") elif WhatToDo == 'CLOUD_DO_NOTHING': - col.label(text="Must select") col.label(text="bound box") elif WhatToDo == 'GENERATE': - col.operator("cloud.generate_cloud", text="Generate Cloud") col.prop(context.scene, "cloud_type") diff --git a/render_povray/ui.py b/render_povray/ui.py index 185249ad..3309c02f 100644 --- a/render_povray/ui.py +++ b/render_povray/ui.py @@ -177,32 +177,22 @@ class RENDER_PT_povray_export_settings(RenderButtonsPanel, bpy.types.Panel): col.label(text="Command line switches:") col.prop(scene.pov, "command_line_switches", text="") split = layout.split() - col = split.column() - col.prop(scene.pov, "tempfiles_enable", text="OS Tempfiles") + split.prop(scene.pov, "tempfiles_enable", text="OS Tempfiles") if not scene.pov.tempfiles_enable: - col = split.column() - col.prop(scene.pov, "deletefiles_enable", text="Delete files") - else: - col = split.column() + split.prop(scene.pov, "deletefiles_enable", text="Delete files") - split = layout.split() if not scene.pov.tempfiles_enable: - col = split.column() + col = layout.column() col.prop(scene.pov, "scene_name", text="Name") - split = layout.split() - col = split.column() col.prop(scene.pov, "scene_path", text="Path to files") #col.prop(scene.pov, "scene_path", text="Path to POV-file") - split = layout.split() - #col = split.column() # Bug in POV-Ray RC3 #col.prop(scene.pov, "renderimage_path", text="Path to image") - #split = layout.split() - col = split.column() - col.prop(scene.pov, "indentation_character", text="Indent") - col = split.column() + split = layout.split() + split.prop(scene.pov, "indentation_character", text="Indent") if scene.pov.indentation_character == "2": - col.prop(scene.pov, "indentation_spaces", text="Spaces") + split.prop(scene.pov, "indentation_spaces", text="Spaces") + row = layout.row() row.prop(scene.pov, "comments_enable", text="Comments") row.prop(scene.pov, "list_lf_enable", text="Line breaks in lists") @@ -219,22 +209,21 @@ class RENDER_PT_povray_render_settings(RenderButtonsPanel, bpy.types.Panel): layout.active = scene.pov.max_trace_level - split = layout.split() - col = split.column() + col = layout.column() - col.label(text="Global Settings") + col.label(text="Global Settings:") col.prop(scene.pov, "max_trace_level", text="Ray Depth") - col.label(text="Global Photons") + col.label(text="Global Photons:") col.prop(scene.pov, "photon_max_trace_level", text="Photon Depth") split = layout.split() + col = split.column() col.prop(scene.pov, "photon_spacing", text="Spacing") col.prop(scene.pov, "photon_gather_min") col = split.column() - col.prop(scene.pov, "photon_adc_bailout", text="Photon ADC") col.prop(scene.pov, "photon_gather_max") @@ -379,14 +368,10 @@ class MATERIAL_PT_povray_mirrorIOR(MaterialButtonsPanel, bpy.types.Panel): layout.active = mat.pov.mirror_use_IOR if mat.pov.mirror_use_IOR: - split = layout.split() - col = split.column() - row = col.row() - row.alignment = 'CENTER' - row.label(text="The current Raytrace ") - row = col.row() - row.alignment = 'CENTER' - row.label(text="Transparency IOR is: " + str(mat.raytrace_transparency.ior)) + col = layout.column() + col.alignment = 'CENTER' + col.label(text="The current Raytrace ") + col.label(text="Transparency IOR is: " + str(mat.raytrace_transparency.ior)) class MATERIAL_PT_povray_metallic(MaterialButtonsPanel, bpy.types.Panel): @@ -453,9 +438,7 @@ class MATERIAL_PT_povray_iridescence(MaterialButtonsPanel, bpy.types.Panel): layout.active = mat.pov.irid_enable if mat.pov.irid_enable: - split = layout.split() - - col = split.column() + col = layout.column() col.prop(mat.pov, "irid_amount", slider=True) col.prop(mat.pov, "irid_thickness", slider=True) col.prop(mat.pov, "irid_turbulence", slider=True) @@ -478,9 +461,7 @@ class MATERIAL_PT_povray_caustics(MaterialButtonsPanel, bpy.types.Panel): layout.active = mat.pov.caustics_enable if mat.pov.caustics_enable: - split = layout.split() - - col = split.column() + col = layout.column() col.prop(mat.pov, "refraction_type") if mat.pov.refraction_type == "1": @@ -491,14 +472,10 @@ class MATERIAL_PT_povray_caustics(MaterialButtonsPanel, bpy.types.Panel): col.prop(mat.pov, "photons_reflection") if mat.pov.refraction_type == "0" and not mat.pov.photons_reflection: - split = layout.split() - col = split.column() - row = col.row() - row.alignment = 'CENTER' - row.label(text="Caustics override is on, ") - row = col.row() - row.alignment = 'CENTER' - row.label(text="but you didn't chose any !") + col = layout.column() + col.alignment = 'CENTER' + col.label(text="Caustics override is on, ") + col.label(text="but you didn't chose any !") class MATERIAL_PT_povray_replacement_text(MaterialButtonsPanel, bpy.types.Panel): diff --git a/rigify/ui.py b/rigify/ui.py index 741d6dab..f187490b 100644 --- a/rigify/ui.py +++ b/rigify/ui.py @@ -47,8 +47,7 @@ class DATA_PT_rigify_buttons(bpy.types.Panel): id_store = C.window_manager if obj.mode in {'POSE', 'OBJECT'}: - row = layout.row() - row.operator("pose.rigify_generate", text="Generate") + layout.operator("pose.rigify_generate", text="Generate") elif obj.mode == 'EDIT': # Build types list collection_name = str(id_store.rigify_collection).replace(" ", "") @@ -75,8 +74,8 @@ class DATA_PT_rigify_buttons(bpy.types.Panel): # Rig type list row = layout.row() row.template_list(id_store, "rigify_types", id_store, 'rigify_active_type') - row = layout.row() - op = row.operator("armature.metarig_sample_add", text="Add sample") + + op = layout.operator("armature.metarig_sample_add", text="Add sample") op.metarig_type = id_store.rigify_types[id_store.rigify_active_type].name diff --git a/space_view3d_3d_navigation.py b/space_view3d_3d_navigation.py index ba3ba292..46e777d4 100644 --- a/space_view3d_3d_navigation.py +++ b/space_view3d_3d_navigation.py @@ -51,12 +51,9 @@ class VIEW3D_PT_3dnavigationPanel(bpy.types.Panel): # Triple boutons col = layout.column(align=True) - row = col.row() - row.operator("view3d.viewnumpad", text="View Camera", icon='CAMERA_DATA').type='CAMERA' - row = col.row() - row.operator("view3d.localview", text="View Global/Local") - row = col.row() - row.operator("view3d.view_persportho", text="View Persp/Ortho") + col.operator("view3d.viewnumpad", text="View Camera", icon='CAMERA_DATA').type='CAMERA' + col.operator("view3d.localview", text="View Global/Local") + col.operator("view3d.view_persportho", text="View Persp/Ortho") # group of 6 buttons col = layout.column(align=True) @@ -70,21 +67,21 @@ class VIEW3D_PT_3dnavigationPanel(bpy.types.Panel): row = col.row() row.operator("view3d.viewnumpad", text="Top").type='TOP' row.operator("view3d.viewnumpad", text="Bottom").type='BOTTOM' - row = col.row() # group of 2 buttons col = layout.column(align=True) col.label(text="View to Object:") col.prop(view, "lock_object", text="") - row = col.row() - row.operator("view3d.view_selected", text="View to Selected") + col.operator("view3d.view_selected", text="View to Selected") + col = layout.column(align=True) col.label(text="Cursor:") + row = col.row() row.operator("view3d.snap_cursor_to_center", text="Center") row.operator("view3d.view_center_cursor", text="View") - row = col.row() - row.operator("view3d.snap_cursor_to_selected", text="Cursor to Selected") + + col.operator("view3d.snap_cursor_to_selected", text="Cursor to Selected") # register the class def register(): diff --git a/space_view3d_math_vis/__init__.py b/space_view3d_math_vis/__init__.py index 10ba8d4b..3e025fe9 100644 --- a/space_view3d_math_vis/__init__.py +++ b/space_view3d_math_vis/__init__.py @@ -49,10 +49,6 @@ class VIEW3D_PT_math_vis(bpy.types.Panel): bl_label = "Math View" def draw(self, context): - layout = self.layout - - col = layout.column(align=True) - callbacks = draw.callbacks ok = False for region in context.area.regions: @@ -60,7 +56,7 @@ class VIEW3D_PT_math_vis(bpy.types.Panel): ok = True break - col.operator("view3d.math_vis_toggle", emboss=False, icon='CHECKBOX_HLT' if ok else 'CHECKBOX_DEHLT') + self.layout.operator("view3d.math_vis_toggle", emboss=False, icon='CHECKBOX_HLT' if ok else 'CHECKBOX_DEHLT') class SetupMathView(bpy.types.Operator): diff --git a/system_demo_mode/__init__.py b/system_demo_mode/__init__.py index 2d0f8149..2a7863cc 100644 --- a/system_demo_mode/__init__.py +++ b/system_demo_mode/__init__.py @@ -109,8 +109,7 @@ class DemoModeSetup(bpy.types.Operator): box.label("Search *.blend recursively") box.label("Writes: demo.py config text.") - col = layout.column() - col.prop(self, "run") + layout.prop(self, "run") col.label("Generate Settings:") row = col.row() @@ -120,19 +119,19 @@ class DemoModeSetup(bpy.types.Operator): mode = self.mode col.separator() - colsub = col.column() - colsub.active = (mode in ('AUTO', 'PLAY')) - colsub.label("Animate Settings:") - colsub.prop(self, "anim_cycles") - colsub.prop(self, "anim_time_min") - colsub.prop(self, "anim_time_max") - colsub.prop(self, "anim_screen_switch") + sub = col.column() + sub.active = (mode in ('AUTO', 'PLAY')) + sub.label("Animate Settings:") + sub.prop(self, "anim_cycles") + sub.prop(self, "anim_time_min") + sub.prop(self, "anim_time_max") + sub.prop(self, "anim_screen_switch") col.separator() - colsub = col.column() - colsub.active = (mode in ('AUTO', 'RENDER')) - colsub.label("Render Settings:") - colsub.prop(self, "display_render") + sub = col.column() + sub.active = (mode in ('AUTO', 'RENDER')) + sub.label("Render Settings:") + sub.prop(self, "display_render") class DemoModeRun(bpy.types.Operator): diff --git a/texture_paint_layer_manager.py b/texture_paint_layer_manager.py index c3eb8afb..bb05cd90 100644 --- a/texture_paint_layer_manager.py +++ b/texture_paint_layer_manager.py @@ -124,10 +124,9 @@ class OBJECT_PT_LoadBrushes(bpy.types.Panel): def draw(self, context): layout = self.layout - row = layout.row() - row.operator('texture.load_brushes') - row = layout.row() - row.operator('texture.load_single_brush') + + layout.operator('texture.load_brushes') + layout.operator('texture.load_single_brush') #====================================================================== @@ -269,12 +268,9 @@ class OBJECT_PT_Texture_paint_add(bpy.types.Panel): if ob: mat = ob.active_material - if mat: - - #row = layout.row() + if mat: col = layout.column(align =True) - col.operator('object.add_paint_layer', text = "Add Color").ttype = 'COLOR' col.operator('object.add_paint_layer', @@ -309,8 +305,7 @@ class OBJECT_PT_Texture_paint_add(bpy.types.Panel): text = "Add Ambient").ttype = 'AMBIENT' else: - row = layout.row() - row.label(' Add a Material first!', icon = 'ERROR') + layout.label(' Add a Material first!', icon = 'ERROR') @@ -629,9 +624,7 @@ class OBJECT_PT_SavePainted(bpy.types.Panel): return (context.image_paint_object) def draw(self, context): - layout = self.layout - row = layout.row() - row.operator('paint.save_all_generated') + self.layout.operator('paint.save_all_generated') def register(): bpy.utils.register_module(__name__) -- cgit v1.2.3