poll() as a python '@staticmethod' was too limiting and didnt allow useful base class poll functions in many cases.

now rna functions that dont have a 'self' are automatically assumed '@classmethods'.

de-duplicated poll functions and made some minor tweaks too.
This commit is contained in:
Campbell Barton
2010-08-09 01:37:09 +00:00
parent 7fcbbad5a4
commit a6f13f9d7b
54 changed files with 596 additions and 815 deletions

View File

@@ -47,22 +47,22 @@ class MESH_MT_shape_key_specials(bpy.types.Menu):
layout.operator("object.shape_key_mirror", icon='ARROW_LEFTRIGHT')
class DataButtonsPanel():
class MeshButtonsPanel():
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "data"
@classmethod
def poll(cls, context):
engine = context.scene.render.engine
return context.mesh and (engine in cls.COMPAT_ENGINES)
class DATA_PT_context_mesh(DataButtonsPanel, bpy.types.Panel):
class DATA_PT_context_mesh(MeshButtonsPanel, bpy.types.Panel):
bl_label = ""
bl_show_header = False
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
@staticmethod
def poll(context):
engine = context.scene.render.engine
return context.mesh and (engine in __class__.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
@@ -79,25 +79,15 @@ class DATA_PT_context_mesh(DataButtonsPanel, bpy.types.Panel):
split.separator()
class DATA_PT_custom_props_mesh(DataButtonsPanel, PropertyPanel, bpy.types.Panel):
_context_path = "object.data"
class DATA_PT_custom_props_mesh(MeshButtonsPanel, PropertyPanel, bpy.types.Panel):
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
@staticmethod
def poll(context):
engine = context.scene.render.engine
return context.mesh and (engine in __class__.COMPAT_ENGINES)
_context_path = "object.data"
class DATA_PT_normals(DataButtonsPanel, bpy.types.Panel):
class DATA_PT_normals(MeshButtonsPanel, bpy.types.Panel):
bl_label = "Normals"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
@staticmethod
def poll(context):
engine = context.scene.render.engine
return context.mesh and (engine in __class__.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
@@ -116,15 +106,10 @@ class DATA_PT_normals(DataButtonsPanel, bpy.types.Panel):
col.prop(mesh, "double_sided")
class DATA_PT_settings(DataButtonsPanel, bpy.types.Panel):
class DATA_PT_settings(MeshButtonsPanel, bpy.types.Panel):
bl_label = "Settings"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
@staticmethod
def poll(context):
engine = context.scene.render.engine
return context.mesh and (engine in __class__.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
@@ -133,15 +118,15 @@ class DATA_PT_settings(DataButtonsPanel, bpy.types.Panel):
layout.prop(mesh, "texture_mesh")
class DATA_PT_vertex_groups(DataButtonsPanel, bpy.types.Panel):
class DATA_PT_vertex_groups(MeshButtonsPanel, bpy.types.Panel):
bl_label = "Vertex Groups"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
@staticmethod
def poll(context):
@classmethod
def poll(cls, context):
engine = context.scene.render.engine
obj = context.object
return (obj and obj.type in ('MESH', 'LATTICE') and (engine in __class__.COMPAT_ENGINES))
return (obj and obj.type in ('MESH', 'LATTICE') and (engine in cls.COMPAT_ENGINES))
def draw(self, context):
layout = self.layout
@@ -182,15 +167,15 @@ class DATA_PT_vertex_groups(DataButtonsPanel, bpy.types.Panel):
layout.prop(context.tool_settings, "vertex_group_weight", text="Weight")
class DATA_PT_shape_keys(DataButtonsPanel, bpy.types.Panel):
class DATA_PT_shape_keys(MeshButtonsPanel, bpy.types.Panel):
bl_label = "Shape Keys"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
@staticmethod
def poll(context):
@classmethod
def poll(cls, context):
engine = context.scene.render.engine
obj = context.object
return (obj and obj.type in ('MESH', 'LATTICE', 'CURVE', 'SURFACE') and (engine in __class__.COMPAT_ENGINES))
return (obj and obj.type in ('MESH', 'LATTICE', 'CURVE', 'SURFACE') and (engine in cls.COMPAT_ENGINES))
def draw(self, context):
layout = self.layout
@@ -274,15 +259,10 @@ class DATA_PT_shape_keys(DataButtonsPanel, bpy.types.Panel):
row.prop(key, "slurph")
class DATA_PT_uv_texture(DataButtonsPanel, bpy.types.Panel):
class DATA_PT_uv_texture(MeshButtonsPanel, bpy.types.Panel):
bl_label = "UV Texture"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
@staticmethod
def poll(context):
engine = context.scene.render.engine
return context.mesh and (engine in __class__.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
@@ -302,12 +282,12 @@ class DATA_PT_uv_texture(DataButtonsPanel, bpy.types.Panel):
layout.prop(lay, "name")
class DATA_PT_texface(DataButtonsPanel, bpy.types.Panel):
class DATA_PT_texface(MeshButtonsPanel, bpy.types.Panel):
bl_label = "Texture Face"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
@staticmethod
def poll(context):
@classmethod
def poll(cls, context):
ob = context.active_object
rd = context.scene.render
@@ -348,15 +328,10 @@ class DATA_PT_texface(DataButtonsPanel, bpy.types.Panel):
col.label(text="No UV Texture")
class DATA_PT_vertex_colors(DataButtonsPanel, bpy.types.Panel):
class DATA_PT_vertex_colors(MeshButtonsPanel, bpy.types.Panel):
bl_label = "Vertex Colors"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
@staticmethod
def poll(context):
engine = context.scene.render.engine
return context.mesh and (engine in __class__.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout