Code cleanup: de-triplicate add menu/toolbars, also style edits

This commit is contained in:
Campbell Barton 2014-03-20 01:32:44 +11:00
parent 44d6c686fa
commit cc2cdfb08a
5 changed files with 95 additions and 86 deletions

@ -308,8 +308,8 @@ class MASK_PT_add():
layout = self.layout layout = self.layout
col = layout.column(align=True) col = layout.column(align=True)
col.operator("mask.primitive_circle_add", icon="MESH_CIRCLE") col.operator("mask.primitive_circle_add", icon='MESH_CIRCLE')
col.operator("mask.primitive_square_add", icon="MESH_PLANE") col.operator("mask.primitive_square_add", icon='MESH_PLANE')
class MASK_MT_mask(Menu): class MASK_MT_mask(Menu):

@ -371,10 +371,10 @@ class CLIP_PT_tools_tracking(CLIP_PT_tracking_panel, Panel):
row.label(text="Clear:") row.label(text="Clear:")
row.scale_x = 2.0 row.scale_x = 2.0
props = row.operator("clip.clear_track_path", icon="BACK", text="") props = row.operator("clip.clear_track_path", text="", icon='BACK')
props.action = 'UPTO' props.action = 'UPTO'
props = row.operator("clip.clear_track_path", icon="FORWARD", text="") props = row.operator("clip.clear_track_path", text="", icon='FORWARD')
props.action = 'REMAINED' props.action = 'REMAINED'
col = layout.column() col = layout.column()
@ -382,10 +382,10 @@ class CLIP_PT_tools_tracking(CLIP_PT_tracking_panel, Panel):
row.label(text="Refine:") row.label(text="Refine:")
row.scale_x = 2.0 row.scale_x = 2.0
props = row.operator("clip.refine_markers", icon='LOOP_BACK', text="") props = row.operator("clip.refine_markers", text="", icon='LOOP_BACK')
props.backwards = True props.backwards = True
props = row.operator("clip.refine_markers", icon='LOOP_FORWARDS', text="") props = row.operator("clip.refine_markers", text="", icon='LOOP_FORWARDS')
props.backwards = False props.backwards = False
col = layout.column(align=True) col = layout.column(align=True)
@ -794,7 +794,7 @@ class CLIP_PT_display(CLIP_PT_clip_view_panel, Panel):
row.separator() row.separator()
row.prop(sc, "use_grayscale_preview", text="B/W", toggle=True) row.prop(sc, "use_grayscale_preview", text="B/W", toggle=True)
row.separator() row.separator()
row.prop(sc, "use_mute_footage", text="", icon="VISIBLE_IPO_ON", toggle=True) row.prop(sc, "use_mute_footage", text="", icon='VISIBLE_IPO_ON', toggle=True)
col = layout.column(align=True) col = layout.column(align=True)
col.prop(sc.clip_user, "use_render_undistorted", text="Render Undistorted") col.prop(sc.clip_user, "use_render_undistorted", text="Render Undistorted")

@ -61,7 +61,7 @@ class USERPREF_HT_header(Header):
layout.operator("wm.keyconfig_import") layout.operator("wm.keyconfig_import")
layout.operator("wm.keyconfig_export") layout.operator("wm.keyconfig_export")
elif userpref.active_section == 'ADDONS': elif userpref.active_section == 'ADDONS':
layout.operator("wm.addon_install", icon="FILESEL") layout.operator("wm.addon_install", icon='FILESEL')
layout.operator("wm.addon_refresh", icon='FILE_REFRESH') layout.operator("wm.addon_refresh", icon='FILE_REFRESH')
layout.menu("USERPREF_MT_addons_dev_guides") layout.menu("USERPREF_MT_addons_dev_guides")
elif userpref.active_section == 'THEMES': elif userpref.active_section == 'THEMES':

@ -880,20 +880,13 @@ class INFO_MT_mesh_add(Menu):
bl_label = "Mesh" bl_label = "Mesh"
def draw(self, context): def draw(self, context):
from .space_view3d_toolbar import VIEW3D_PT_tools_add_object
layout = self.layout layout = self.layout
layout.operator_context = 'INVOKE_REGION_WIN' layout.operator_context = 'INVOKE_REGION_WIN'
layout.operator("mesh.primitive_plane_add", icon='MESH_PLANE', text="Plane")
layout.operator("mesh.primitive_cube_add", icon='MESH_CUBE', text="Cube") VIEW3D_PT_tools_add_object.draw_add_mesh(layout)
layout.operator("mesh.primitive_circle_add", icon='MESH_CIRCLE', text="Circle")
layout.operator("mesh.primitive_uv_sphere_add", icon='MESH_UVSPHERE', text="UV Sphere")
layout.operator("mesh.primitive_ico_sphere_add", icon='MESH_ICOSPHERE', text="Icosphere")
layout.operator("mesh.primitive_cylinder_add", icon='MESH_CYLINDER', text="Cylinder")
layout.operator("mesh.primitive_cone_add", icon='MESH_CONE', text="Cone")
layout.separator()
layout.operator("mesh.primitive_grid_add", icon='MESH_GRID', text="Grid")
layout.operator("mesh.primitive_monkey_add", icon='MESH_MONKEY', text="Monkey")
layout.operator("mesh.primitive_torus_add", icon='MESH_TORUS', text="Torus")
class INFO_MT_curve_add(Menu): class INFO_MT_curve_add(Menu):
@ -901,14 +894,13 @@ class INFO_MT_curve_add(Menu):
bl_label = "Curve" bl_label = "Curve"
def draw(self, context): def draw(self, context):
from .space_view3d_toolbar import VIEW3D_PT_tools_add_object
layout = self.layout layout = self.layout
layout.operator_context = 'INVOKE_REGION_WIN' layout.operator_context = 'INVOKE_REGION_WIN'
layout.operator("curve.primitive_bezier_curve_add", icon='CURVE_BEZCURVE', text="Bezier")
layout.operator("curve.primitive_bezier_circle_add", icon='CURVE_BEZCIRCLE', text="Circle") VIEW3D_PT_tools_add_object.draw_add_curve(layout)
layout.operator("curve.primitive_nurbs_curve_add", icon='CURVE_NCURVE', text="Nurbs Curve")
layout.operator("curve.primitive_nurbs_circle_add", icon='CURVE_NCIRCLE', text="Nurbs Circle")
layout.operator("curve.primitive_nurbs_path_add", icon='CURVE_PATH', text="Path")
class INFO_MT_surface_add(Menu): class INFO_MT_surface_add(Menu):
@ -916,15 +908,12 @@ class INFO_MT_surface_add(Menu):
bl_label = "Surface" bl_label = "Surface"
def draw(self, context): def draw(self, context):
from .space_view3d_toolbar import VIEW3D_PT_tools_add_object
layout = self.layout layout = self.layout
layout.operator_context = 'INVOKE_REGION_WIN' layout.operator_context = 'INVOKE_REGION_WIN'
layout.operator("surface.primitive_nurbs_surface_curve_add", icon='SURFACE_NCURVE', text="NURBS Curve")
layout.operator("surface.primitive_nurbs_surface_circle_add", icon='SURFACE_NCIRCLE', text="NURBS Circle") VIEW3D_PT_tools_add_object.draw_add_surface(layout)
layout.operator("surface.primitive_nurbs_surface_surface_add", icon='SURFACE_NSURFACE', text="NURBS Surface")
layout.operator("surface.primitive_nurbs_surface_cylinder_add", icon='SURFACE_NCYLINDER', text="NURBS Cylinder")
layout.operator("surface.primitive_nurbs_surface_sphere_add", icon='SURFACE_NSPHERE', text="NURBS Sphere")
layout.operator("surface.primitive_nurbs_surface_torus_add", icon='SURFACE_NTORUS', text="NURBS Torus")
class INFO_MT_metaball_add(Menu): class INFO_MT_metaball_add(Menu):
@ -3144,7 +3133,7 @@ class VIEW3D_PT_transform_orientations(Panel):
if orientation: if orientation:
row = layout.row(align=True) row = layout.row(align=True)
row.prop(orientation, "name", text="") row.prop(orientation, "name", text="")
row.operator("transform.delete_orientation", text="", icon="X") row.operator("transform.delete_orientation", text="", icon='X')
class VIEW3D_PT_etch_a_ton(Panel): class VIEW3D_PT_etch_a_ton(Panel):

@ -123,45 +123,93 @@ class VIEW3D_PT_tools_objectmode(View3DPanel, Panel):
draw_repeat_tools(context, layout) draw_repeat_tools(context, layout)
class VIEW3D_PT_tools_add_mesh(View3DPanel, Panel): class VIEW3D_PT_tools_add_object(View3DPanel, Panel):
bl_category = "Create" bl_category = "Create"
bl_context = "objectmode" bl_context = "objectmode"
bl_label = "Add Primitive" bl_label = "Add Primitive"
@staticmethod
def draw_add_mesh(layout, label=False):
if label:
layout.label(text="Primitives:")
layout.operator("mesh.primitive_plane_add", text="Plane", icon='MESH_PLANE')
layout.operator("mesh.primitive_cube_add", text="Cube", icon='MESH_CUBE')
layout.operator("mesh.primitive_circle_add", text="Circle", icon='MESH_CIRCLE')
layout.operator("mesh.primitive_uv_sphere_add", text="UV Sphere", icon='MESH_UVSPHERE')
layout.operator("mesh.primitive_ico_sphere_add", text="Ico Sphere", icon='MESH_ICOSPHERE')
layout.operator("mesh.primitive_cylinder_add", text="Cylinder", icon='MESH_CYLINDER')
layout.operator("mesh.primitive_cone_add", text="Cone", icon='MESH_CONE')
layout.operator("mesh.primitive_torus_add", text="Torus", icon='MESH_TORUS')
if label:
layout.label(text="Special:")
else:
layout.separator()
layout.operator("mesh.primitive_grid_add", text="Grid", icon='MESH_GRID')
layout.operator("mesh.primitive_monkey_add", text="Monkey", icon='MESH_MONKEY')
@staticmethod
def draw_add_curve(layout, label=False):
if label:
layout.label(text="Bezier:")
layout.operator("curve.primitive_bezier_curve_add", text="Bezier", icon='CURVE_BEZCURVE')
layout.operator("curve.primitive_bezier_circle_add", text="Circle", icon='CURVE_BEZCIRCLE')
if label:
layout.label(text="Nurbs:")
else:
layout.separator()
layout.operator("curve.primitive_nurbs_curve_add", text="Nurbs Curve", icon='CURVE_NCURVE')
layout.operator("curve.primitive_nurbs_circle_add", text="Nurbs Circle", icon='CURVE_NCIRCLE')
layout.operator("curve.primitive_nurbs_path_add", text="Path", icon='CURVE_PATH')
@staticmethod
def draw_add_surface(layout):
layout.operator("surface.primitive_nurbs_surface_curve_add", text="Nurbs Curve", icon='SURFACE_NCURVE')
layout.operator("surface.primitive_nurbs_surface_circle_add", text="Nurbs Circle", icon='SURFACE_NCIRCLE')
layout.operator("surface.primitive_nurbs_surface_surface_add", text="Nurbs Surface", icon='SURFACE_NSURFACE')
layout.operator("surface.primitive_nurbs_surface_cylinder_add", text="Nurbs Cylinder", icon='SURFACE_NCYLINDER')
layout.operator("surface.primitive_nurbs_surface_sphere_add", text="Nurbs Sphere", icon='SURFACE_NSPHERE')
layout.operator("surface.primitive_nurbs_surface_torus_add", text="Nurbs Torus", icon='SURFACE_NTORUS')
@staticmethod
def draw_add_mball(layout):
layout.operator_enum("object.metaball_add", "type")
@staticmethod
def draw_add_lamp(layout):
layout.operator_enum("object.lamp_add", "type")
@staticmethod
def draw_add_other(layout):
layout.operator("object.text_add", text="Text", icon='OUTLINER_OB_FONT')
layout.operator("object.armature_add", text="Armature", icon='OUTLINER_OB_ARMATURE')
layout.operator("object.add", text="Lattice", icon='OUTLINER_OB_LATTICE').type = 'LATTICE'
layout.operator("object.empty_add", text="Empty", icon='OUTLINER_OB_EMPTY').type = 'PLAIN_AXES'
layout.operator("object.camera_add", text="Camera", icon='OUTLINER_OB_CAMERA')
def draw(self, context): def draw(self, context):
layout = self.layout layout = self.layout
col = layout.column(align=True) col = layout.column(align=True)
col.label(text="Mesh:") col.label(text="Mesh:")
col.operator("mesh.primitive_plane_add", text="Plane", icon="MESH_PLANE") self.draw_add_mesh(col)
col.operator("mesh.primitive_cube_add", text="Cube", icon="MESH_CUBE")
col.operator("mesh.primitive_circle_add", text="Circle", icon="MESH_CIRCLE")
col.operator("mesh.primitive_uv_sphere_add", text="UV Sphere", icon="MESH_UVSPHERE")
col.operator("mesh.primitive_ico_sphere_add", text="Ico Sphere", icon="MESH_ICOSPHERE")
col.operator("mesh.primitive_cylinder_add", text="Cylinder", icon="MESH_CYLINDER")
col.operator("mesh.primitive_cone_add", text="Cone", icon="MESH_CONE")
col.operator("mesh.primitive_torus_add", text="Torus", icon="MESH_TORUS")
col.operator("mesh.primitive_monkey_add", text="Monkey", icon="MESH_MONKEY")
col = layout.column(align=True) col = layout.column(align=True)
col.label(text="Curve:") col.label(text="Curve:")
col.operator("curve.primitive_bezier_curve_add", text="Curve", icon="CURVE_BEZCURVE") self.draw_add_curve(col)
col.operator("curve.primitive_bezier_circle_add", text="Circle", icon="CURVE_BEZCIRCLE")
col.operator("curve.primitive_nurbs_path_add", text="Path", icon="CURVE_PATH")
# not used here:
# draw_add_surface
# draw_add_mball
col = layout.column(align=True)
col.label(text="Lamp:") col.label(text="Lamp:")
col.operator("object.lamp_add", text="Point", icon="LAMP_POINT").type = 'POINT' self.draw_add_lamp(col)
col.operator("object.lamp_add", text="Sun", icon="LAMP_SUN").type = 'SUN'
col.operator("object.lamp_add", text="Spot", icon="LAMP_SPOT").type = 'SPOT'
col.operator("object.lamp_add", text="Hemi", icon="LAMP_HEMI").type = 'HEMI'
col.operator("object.lamp_add", text="Area", icon="LAMP_AREA").type = 'AREA'
col = layout.column(align=True)
col.label(text="Other:") col.label(text="Other:")
col.operator("object.text_add", text="Text", icon="OUTLINER_OB_FONT") self.draw_add_other(col)
col.operator("object.armature_add", text="Armature", icon="OUTLINER_OB_ARMATURE")
col.operator("object.add", text="Lattice", icon="OUTLINER_OB_LATTICE").type = 'LATTICE'
col.operator("object.empty_add", text="Empty", icon="OUTLINER_OB_EMPTY").type = 'PLAIN_AXES'
col.operator("object.camera_add", text="Camera", icon="OUTLINER_OB_CAMERA")
class VIEW3D_PT_tools_relations(View3DPanel, Panel): class VIEW3D_PT_tools_relations(View3DPanel, Panel):
@ -323,20 +371,8 @@ class VIEW3D_PT_tools_add_mesh_edit(View3DPanel, Panel):
layout = self.layout layout = self.layout
col = layout.column(align=True) col = layout.column(align=True)
col.label(text="Primitives:")
col.operator("mesh.primitive_plane_add", text="Plane", icon="MESH_PLANE")
col.operator("mesh.primitive_cube_add", text="Cube", icon="MESH_CUBE")
col.operator("mesh.primitive_circle_add", text="Circle", icon="MESH_CIRCLE")
col.operator("mesh.primitive_uv_sphere_add", text="UV Sphere", icon="MESH_UVSPHERE")
col.operator("mesh.primitive_ico_sphere_add", text="Ico Sphere", icon="MESH_ICOSPHERE")
col.operator("mesh.primitive_cylinder_add", text="Cylinder", icon="MESH_CYLINDER")
col.operator("mesh.primitive_cone_add", text="Cone", icon="MESH_CONE")
col.operator("mesh.primitive_torus_add", text="Torus", icon="MESH_TORUS")
col = layout.column(align=True) VIEW3D_PT_tools_add_object.draw_add_mesh(col, label=True)
col.label(text="Special:")
col.operator("mesh.primitive_grid_add", text="Grid", icon="MESH_GRID")
col.operator("mesh.primitive_monkey_add", text="Monkey", icon="MESH_MONKEY")
class VIEW3D_PT_tools_shading(View3DPanel, Panel): class VIEW3D_PT_tools_shading(View3DPanel, Panel):
@ -478,14 +514,7 @@ class VIEW3D_PT_tools_add_curve_edit(View3DPanel, Panel):
col = layout.column(align=True) col = layout.column(align=True)
col.label(text="Bezier:") VIEW3D_PT_tools_add_object.draw_add_curve(col, label=True)
col.operator("curve.primitive_bezier_curve_add", text="Bezier Curve", icon="CURVE_BEZCURVE")
col.operator("curve.primitive_bezier_circle_add", text="Bezier Circle", icon="CURVE_BEZCIRCLE")
col.label(text="Nurbs:")
col.operator("curve.primitive_nurbs_curve_add", text="Nurbs Curve", icon="CURVE_NCURVE")
col.operator("curve.primitive_nurbs_circle_add", text="Nurbs Circle", icon="CURVE_NCIRCLE")
col.operator("curve.primitive_nurbs_path_add", text="Nurbs Path", icon="CURVE_PATH")
# ********** default tools for editmode_surface **************** # ********** default tools for editmode_surface ****************
@ -537,12 +566,7 @@ class VIEW3D_PT_tools_add_surface_edit(View3DPanel, Panel):
col = layout.column(align=True) col = layout.column(align=True)
col.operator("surface.primitive_nurbs_surface_curve_add", text="Nurbs Curve", icon="SURFACE_NCURVE") VIEW3D_PT_tools_add_object.draw_add_surface(col)
col.operator("surface.primitive_nurbs_surface_circle_add", text="Nurbs Circle", icon="SURFACE_NCIRCLE")
col.operator("surface.primitive_nurbs_surface_surface_add", text="Nurbs Surface", icon="SURFACE_NSURFACE")
col.operator("surface.primitive_nurbs_surface_cylinder_add", text="Nurbs Cylinder", icon="SURFACE_NCYLINDER")
col.operator("surface.primitive_nurbs_surface_sphere_add", text="Nurbs Sphere", icon="SURFACE_NSPHERE")
col.operator("surface.primitive_nurbs_surface_torus_add", text="Nurbs Torus", icon="SURFACE_NTORUS")
# ********** default tools for editmode_text **************** # ********** default tools for editmode_text ****************
@ -639,11 +663,7 @@ class VIEW3D_PT_tools_add_mball_edit(View3DPanel, Panel):
col = layout.column(align=True) col = layout.column(align=True)
col.operator("object.metaball_add", text="Ball", icon="META_BALL").type = 'BALL' VIEW3D_PT_tools_add_object.draw_add_mball(col)
col.operator("object.metaball_add", text="Capsule", icon="META_CAPSULE").type = 'CAPSULE'
col.operator("object.metaball_add", text="Plane", icon="META_PLANE").type = 'PLANE'
col.operator("object.metaball_add", text="Ellipsoid", icon="META_ELLIPSOID").type = 'ELLIPSOID'
col.operator("object.metaball_add", text="Cube", icon="META_CUBE").type = 'CUBE'
# ********** default tools for editmode_lattice **************** # ********** default tools for editmode_lattice ****************