custom properties panels for most ID types. use subclassing to keep panel UI definiti...
authorCampbell Barton <ideasman42@gmail.com>
Fri, 8 Jan 2010 08:54:41 +0000 (08:54 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 8 Jan 2010 08:54:41 +0000 (08:54 +0000)
15 files changed:
release/scripts/modules/rna_prop_ui.py
release/scripts/ui/properties_data_armature.py
release/scripts/ui/properties_data_bone.py
release/scripts/ui/properties_data_camera.py
release/scripts/ui/properties_data_curve.py
release/scripts/ui/properties_data_lamp.py
release/scripts/ui/properties_data_lattice.py
release/scripts/ui/properties_data_mesh.py
release/scripts/ui/properties_data_metaball.py
release/scripts/ui/properties_material.py
release/scripts/ui/properties_object.py
release/scripts/ui/properties_particle.py
release/scripts/ui/properties_scene.py
release/scripts/ui/properties_texture.py
release/scripts/ui/properties_world.py

index 543a10e47e95622cbe4c920b5305005c282af113..f5b9e518c8fae658e05d7d1518dbda5a2bda3736 100644 (file)
@@ -124,6 +124,18 @@ def draw(layout, context, context_member, use_edit=True):
             assign_props(prop, val_draw, key)
 
 
+class PropertyPanel(bpy.types.Panel):
+    """
+    The subclass should have its own poll function 
+    and the variable '_context_path' MUST be set.
+    """
+    bl_label = "Custom Properties"
+    bl_default_closed = True
+
+    def draw(self, context):
+        draw(self.layout, context, self._context_path)
+
+
 from bpy.props import *
 
 
@@ -257,3 +269,4 @@ class WM_OT_properties_remove(bpy.types.Operator):
         item = eval("context.%s" % self.properties.path)
         del item[self.properties.property]
         return {'FINISHED'}
+
index 0267b2abea481925f91d4e7220a3d76ae3bc9355..bded38ee3ccc673668b6b4ef081fff8867aeff7c 100644 (file)
@@ -18,6 +18,7 @@
 
 # <pep8 compliant>
 import bpy
+from rna_prop_ui import PropertyPanel
 
 narrowui = 180
 
@@ -55,6 +56,10 @@ class DATA_PT_context_arm(DataButtonsPanel):
             layout.template_ID(ob, "data")
 
 
+class DATA_PT_custom_props_arm(DataButtonsPanel, PropertyPanel):
+    _context_path = "object.data"
+
+
 class DATA_PT_skeleton(DataButtonsPanel):
     bl_label = "Skeleton"
 
@@ -293,16 +298,6 @@ class DATA_PT_iksolver_itasc(DataButtonsPanel):
                 row.prop(itasc, "dampeps", text="Eps", slider=True)
 
 
-class DATA_PT_properties(DataButtonsPanel):
-    bl_label = "Properties"
-    bl_default_closed = True
-
-    def draw(self, context):
-        import rna_prop_ui
-
-        rna_prop_ui.draw(self.layout, context, "object.data")
-
-
 bpy.types.register(DATA_PT_context_arm)
 bpy.types.register(DATA_PT_skeleton)
 bpy.types.register(DATA_PT_display)
@@ -310,4 +305,5 @@ bpy.types.register(DATA_PT_bone_groups)
 bpy.types.register(DATA_PT_paths)
 bpy.types.register(DATA_PT_ghost)
 bpy.types.register(DATA_PT_iksolver_itasc)
-bpy.types.register(DATA_PT_properties)
+
+bpy.types.register(DATA_PT_custom_props_arm)
index d064b9a48970ae6452d19a9763314706145d6654..96cf400d738da6afeff90640ac0f9c81b6e891a9 100644 (file)
@@ -18,6 +18,7 @@
 
 # <pep8 compliant>
 import bpy
+from rna_prop_ui import PropertyPanel
 
 narrowui = 180
 
@@ -47,6 +48,17 @@ class BONE_PT_context_bone(BoneButtonsPanel):
         row.prop(bone, "name", text="")
 
 
+class BONE_PT_custom_props(BoneButtonsPanel, PropertyPanel):
+
+    @property
+    def _context_path(self):
+        obj = bpy.context.object
+        if obj and obj.mode == 'POSE':
+            return "active_pose_bone"
+        else:
+            return "active_bone"
+
+
 class BONE_PT_transform(BoneButtonsPanel):
     bl_label = "Transform"
 
@@ -376,21 +388,6 @@ class BONE_PT_deform(BoneButtonsPanel):
         col.prop(bone, "cyclic_offset")
 
 
-class BONE_PT_properties(BoneButtonsPanel):
-    bl_label = "Properties"
-    bl_default_closed = True
-
-    def draw(self, context):
-        import rna_prop_ui
-        # reload(rna_prop_ui)
-        obj = context.object
-        if obj and obj.mode == 'POSE':
-            item = "active_pose_bone"
-        else:
-            item = "active_bone"
-
-        rna_prop_ui.draw(self.layout, context, item)
-
 bpy.types.register(BONE_PT_context_bone)
 bpy.types.register(BONE_PT_transform)
 bpy.types.register(BONE_PT_transform_locks)
@@ -398,4 +395,5 @@ bpy.types.register(BONE_PT_relations)
 bpy.types.register(BONE_PT_display)
 bpy.types.register(BONE_PT_inverse_kinematics)
 bpy.types.register(BONE_PT_deform)
-bpy.types.register(BONE_PT_properties)
+
+bpy.types.register(BONE_PT_custom_props)
index e8cba6be7dfd8ee4b50e825172b24390f4444a79..d2889b6629e26d2219d2fdd5b43c1fa04500d92c 100644 (file)
@@ -18,6 +18,7 @@
 
 # <pep8 compliant>
 import bpy
+from rna_prop_ui import PropertyPanel
 
 narrowui = 180
 
@@ -58,6 +59,10 @@ class DATA_PT_context_camera(DataButtonsPanel):
                 layout.template_ID(space, "pin_id")
 
 
+class DATA_PT_custom_props_camera(DataButtonsPanel, PropertyPanel):
+    _context_path = "object.data"
+
+
 class DATA_PT_camera(DataButtonsPanel):
     bl_label = "Lens"
 
@@ -140,6 +145,9 @@ class DATA_PT_camera_display(DataButtonsPanel):
         sub.active = cam.show_passepartout
         sub.prop(cam, "passepartout_alpha", text="Alpha", slider=True)
 
+
 bpy.types.register(DATA_PT_context_camera)
 bpy.types.register(DATA_PT_camera)
 bpy.types.register(DATA_PT_camera_display)
+
+bpy.types.register(DATA_PT_custom_props_camera)
index 3ee16ad9585d1826e3ba9d4e7a993bba7b8129b2..442590b8946da64a1b5a2a1c922bd7ab869a8281 100644 (file)
@@ -18,6 +18,7 @@
 
 # <pep8 compliant>
 import bpy
+from rna_prop_ui import PropertyPanel
 
 narrowui = 180
 
@@ -72,6 +73,10 @@ class DATA_PT_context_curve(DataButtonsPanel):
             layout.template_ID(ob, "data")
 
 
+class DATA_PT_custom_props_curve(DataButtonsPanel, PropertyPanel):
+    _context_path = "object.data"
+
+
 class DATA_PT_shape_curve(DataButtonsPanel):
     bl_label = "Shape"
 
@@ -377,6 +382,7 @@ class DATA_PT_textboxes(DataButtonsPanel):
             col.prop(box, "x", text="X")
             col.prop(box, "y", text="Y")
 
+
 bpy.types.register(DATA_PT_context_curve)
 bpy.types.register(DATA_PT_shape_curve)
 bpy.types.register(DATA_PT_geometry_curve)
@@ -385,3 +391,5 @@ bpy.types.register(DATA_PT_active_spline)
 bpy.types.register(DATA_PT_font)
 bpy.types.register(DATA_PT_paragraph)
 bpy.types.register(DATA_PT_textboxes)
+
+bpy.types.register(DATA_PT_custom_props_curve)
index d5025983ff3f31137d1e75e67b208a3bb085411d..24f6486cdf6d299c8595a37fc59ec4d3eda57916 100644 (file)
@@ -18,6 +18,7 @@
 
 # <pep8 compliant>
 import bpy
+from rna_prop_ui import PropertyPanel
 
 narrowui = 180
 
@@ -65,6 +66,10 @@ class DATA_PT_context_lamp(DataButtonsPanel):
                 layout.template_ID(space, "pin_id")
 
 
+class DATA_PT_custom_props_lamp(DataButtonsPanel, PropertyPanel):
+    _context_path = "object.data"
+
+
 class DATA_PT_lamp(DataButtonsPanel):
     bl_label = "Lamp"
 
@@ -374,6 +379,7 @@ class DATA_PT_falloff_curve(DataButtonsPanel):
 
         self.layout.template_curve_mapping(lamp, "falloff_curve")
 
+
 bpy.types.register(DATA_PT_context_lamp)
 bpy.types.register(DATA_PT_preview)
 bpy.types.register(DATA_PT_lamp)
@@ -382,3 +388,5 @@ bpy.types.register(DATA_PT_area)
 bpy.types.register(DATA_PT_spot)
 bpy.types.register(DATA_PT_shadow)
 bpy.types.register(DATA_PT_sunsky)
+
+bpy.types.register(DATA_PT_custom_props_lamp)
index 640f625a7defa408ca72191f3c8a398c81e24b91..a6221fa5e63ec8ef8abc18884b06871f911d3d50 100644 (file)
@@ -18,6 +18,7 @@
 
 # <pep8 compliant>
 import bpy
+from rna_prop_ui import PropertyPanel
 
 narrowui = 180
 
@@ -58,6 +59,10 @@ class DATA_PT_context_lattice(DataButtonsPanel):
                 layout.template_ID(space, "pin_id")
 
 
+class DATA_PT_custom_props_lattice(DataButtonsPanel, PropertyPanel):
+    _context_path = "object.data"
+
+
 class DATA_PT_lattice(DataButtonsPanel):
     bl_label = "Lattice"
 
@@ -90,5 +95,8 @@ class DATA_PT_lattice(DataButtonsPanel):
 
         layout.prop(lat, "outside")
 
+
 bpy.types.register(DATA_PT_context_lattice)
 bpy.types.register(DATA_PT_lattice)
+
+bpy.types.register(DATA_PT_custom_props_lattice)
index b8c5438ea78c52c1122c4e8ee5bb2f24c390f773..a03d8d550058dfaa5ea9136cad9291c835cbbbe6 100644 (file)
@@ -18,6 +18,7 @@
 
 # <pep8 compliant>
 import bpy
+from rna_prop_ui import PropertyPanel
 
 narrowui = 180
 
@@ -58,6 +59,10 @@ class DATA_PT_context_mesh(DataButtonsPanel):
                 layout.template_ID(space, "pin_id")
 
 
+class DATA_PT_custom_props_mesh(DataButtonsPanel, PropertyPanel):
+    _context_path = "object.data"
+
+
 class DATA_PT_normals(DataButtonsPanel):
     bl_label = "Normals"
 
@@ -292,3 +297,6 @@ bpy.types.register(DATA_PT_vertex_groups)
 bpy.types.register(DATA_PT_shape_keys)
 bpy.types.register(DATA_PT_uv_texture)
 bpy.types.register(DATA_PT_vertex_colors)
+
+bpy.types.register(DATA_PT_custom_props_mesh)
+
index e36bdc991e179920694af3a0740acb92815d6465..8951693aaacd244e4eb2c43f0e1eb5aa80869914 100644 (file)
@@ -18,6 +18,7 @@
 
 # <pep8 compliant>
 import bpy
+from rna_prop_ui import PropertyPanel
 
 narrowui = 180
 
@@ -58,6 +59,10 @@ class DATA_PT_context_metaball(DataButtonsPanel):
                 layout.template_ID(space, "pin_id")
 
 
+class DATA_PT_custom_props_metaball(DataButtonsPanel, PropertyPanel):
+    _context_path = "object.data"
+
+
 class DATA_PT_metaball(DataButtonsPanel):
     bl_label = "Metaball"
 
@@ -133,3 +138,7 @@ class DATA_PT_metaball_element(DataButtonsPanel):
 bpy.types.register(DATA_PT_context_metaball)
 bpy.types.register(DATA_PT_metaball)
 bpy.types.register(DATA_PT_metaball_element)
+
+bpy.types.register(DATA_PT_custom_props_metaball)
+
+
index a48b3b1a30a8b997916ec1f45cf9f6c3292552dd..dfd4270e97b0036a60a776fc9d4498f844bb3482 100644 (file)
@@ -18,6 +18,7 @@
 
 # <pep8 compliant>
 import bpy
+from rna_prop_ui import PropertyPanel
 
 narrowui = 180
 
@@ -125,6 +126,11 @@ class MATERIAL_PT_context_material(MaterialButtonsPanel):
                 layout.prop(mat, "type", text="")
 
 
+class MATERIAL_PT_custom_props(MaterialButtonsPanel, PropertyPanel):
+    COMPAT_ENGINES = {'BLENDER_RENDER'}
+    _context_path = "material"
+
+
 class MATERIAL_PT_shading(MaterialButtonsPanel):
     bl_label = "Shading"
     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
@@ -880,3 +886,5 @@ bpy.types.register(MATERIAL_PT_volume_shading)
 bpy.types.register(MATERIAL_PT_volume_lighting)
 bpy.types.register(MATERIAL_PT_volume_transp)
 bpy.types.register(MATERIAL_PT_volume_integration)
+
+bpy.types.register(MATERIAL_PT_custom_props)
index 05a48225f82cfcee8e0f7f06dde3d40cd9e81a9b..3b539506552ee43ec72f3adbe6e64c5bee277465 100644 (file)
@@ -18,6 +18,7 @@
 
 # <pep8 compliant>
 import bpy
+from rna_prop_ui import PropertyPanel
 
 narrowui = 180
 
@@ -42,6 +43,10 @@ class OBJECT_PT_context_object(ObjectButtonsPanel):
         row.prop(ob, "name", text="")
 
 
+class OBJECT_PT_custom_props(ObjectButtonsPanel, PropertyPanel):
+    _context_path = "object"
+
+
 class OBJECT_PT_transform(ObjectButtonsPanel):
     bl_label = "Transform"
 
@@ -300,16 +305,6 @@ class OBJECT_PT_animation(ObjectButtonsPanel):
         row.active = (ob.parent is not None)
 
 
-class OBJECT_PT_properties(ObjectButtonsPanel):
-    bl_label = "Properties"
-    bl_default_closed = True
-
-    def draw(self, context):
-        import rna_prop_ui
-        # reload(rna_prop_ui)
-
-        rna_prop_ui.draw(self.layout, context, "object")
-
 bpy.types.register(OBJECT_PT_context_object)
 bpy.types.register(OBJECT_PT_transform)
 bpy.types.register(OBJECT_PT_transform_locks)
@@ -318,4 +313,5 @@ bpy.types.register(OBJECT_PT_groups)
 bpy.types.register(OBJECT_PT_display)
 bpy.types.register(OBJECT_PT_duplication)
 bpy.types.register(OBJECT_PT_animation)
-bpy.types.register(OBJECT_PT_properties)
+
+bpy.types.register(OBJECT_PT_custom_props)
index a33a1a12f1bc405d6386d9bdba4f100d34587f41..14278ea197c32c926122881cff69053c42b9a6de 100644 (file)
@@ -18,6 +18,7 @@
 
 # <pep8 compliant>
 import bpy
+from rna_prop_ui import PropertyPanel
 
 from properties_physics_common import point_cache_ui
 from properties_physics_common import effector_weights_ui
@@ -47,7 +48,7 @@ class ParticleButtonsPanel(bpy.types.Panel):
         return particle_panel_poll(context)
 
 
-class PARTICLE_PT_particles(ParticleButtonsPanel):
+class PARTICLE_PT_context_particles(ParticleButtonsPanel):
     bl_label = ""
     bl_show_header = False
 
@@ -130,6 +131,10 @@ class PARTICLE_PT_particles(ParticleButtonsPanel):
                     split.prop(psys, "reactor_target_particle_system", text="Particle System")
 
 
+class PARTICLE_PT_custom_props(ParticleButtonsPanel, PropertyPanel):
+    _context_path = "particle_system.settings"
+
+
 class PARTICLE_PT_emission(ParticleButtonsPanel):
     bl_label = "Emission"
 
@@ -992,7 +997,7 @@ class PARTICLE_PT_vertexgroups(ParticleButtonsPanel):
         row.prop_object(psys, "vertex_group_field", ob, "vertex_groups", text="Field")
         row.prop(psys, "vertex_group_field_negate", text="")
 
-bpy.types.register(PARTICLE_PT_particles)
+bpy.types.register(PARTICLE_PT_context_particles)
 bpy.types.register(PARTICLE_PT_hair_dynamics)
 bpy.types.register(PARTICLE_PT_cache)
 bpy.types.register(PARTICLE_PT_emission)
@@ -1006,3 +1011,5 @@ bpy.types.register(PARTICLE_PT_children)
 bpy.types.register(PARTICLE_PT_field_weights)
 bpy.types.register(PARTICLE_PT_force_fields)
 bpy.types.register(PARTICLE_PT_vertexgroups)
+
+bpy.types.register(PARTICLE_PT_custom_props)
index c059339c14e123e93c3a63023425f7360d50299d..68936a457596c52a208e33ee86a7c37f97609462 100644 (file)
@@ -18,6 +18,7 @@
 
 # <pep8 compliant>
 import bpy
+from rna_prop_ui import PropertyPanel
 
 narrowui = 180
 
@@ -48,6 +49,10 @@ class SCENE_PT_scene(SceneButtonsPanel):
             layout.prop(scene, "set", text="")
 
 
+class SCENE_PT_custom_props(SceneButtonsPanel, PropertyPanel):
+    _context_path = "scene"
+
+
 class SCENE_PT_unit(SceneButtonsPanel):
     bl_label = "Units"
     COMPAT_ENGINES = {'BLENDER_RENDER'}
@@ -178,3 +183,6 @@ bpy.types.register(SCENE_PT_unit)
 bpy.types.register(SCENE_PT_keying_sets)
 bpy.types.register(SCENE_PT_keying_set_paths)
 bpy.types.register(SCENE_PT_physics)
+
+bpy.types.register(SCENE_PT_custom_props)
+
index 711ba4f8a02dfecb337998ad0ef058260ad52eb2..7b70b35573164eb1ed3bd1f92c11b611916a63c3 100644 (file)
@@ -18,6 +18,7 @@
 
 # <pep8 compliant>
 import bpy
+from rna_prop_ui import PropertyPanel
 
 narrowui = 180
 
@@ -149,6 +150,13 @@ class TEXTURE_PT_context_texture(TextureButtonsPanel):
                     layout.prop(tex, "type", text="")
 
 
+class TEXTURE_PT_custom_props(TextureButtonsPanel, PropertyPanel):
+    _context_path = "texture"
+
+    def poll(self, context): # use alternate poll since NONE texture type is ok
+        return context.texture
+
+
 class TEXTURE_PT_colors(TextureButtonsPanel):
     bl_label = "Colors"
     bl_default_closed = True
@@ -976,3 +984,5 @@ bpy.types.register(TEXTURE_PT_pointdensity_turbulence)
 bpy.types.register(TEXTURE_PT_colors)
 bpy.types.register(TEXTURE_PT_mapping)
 bpy.types.register(TEXTURE_PT_influence)
+
+bpy.types.register(TEXTURE_PT_custom_props)
index b23a0dffbad8954718a76184ef3d78cc09b59f94..e488265d76df49243385d43f267bc8c85a55c41f 100644 (file)
@@ -18,6 +18,7 @@
 
 # <pep8 compliant>
 import bpy
+from rna_prop_ui import PropertyPanel
 
 narrowui = 180
 
@@ -69,6 +70,10 @@ class WORLD_PT_context_world(WorldButtonsPanel):
             layout.template_ID(scene, "world", new="world.new")
 
 
+class WORLD_PT_custom_props(WorldButtonsPanel, PropertyPanel):
+    _context_path = "world"
+
+
 class WORLD_PT_world(WorldButtonsPanel):
     bl_label = "World"
     COMPAT_ENGINES = {'BLENDER_RENDER'}
@@ -232,3 +237,5 @@ bpy.types.register(WORLD_PT_world)
 bpy.types.register(WORLD_PT_ambient_occlusion)
 bpy.types.register(WORLD_PT_mist)
 bpy.types.register(WORLD_PT_stars)
+
+bpy.types.register(WORLD_PT_custom_props)