bugfix [#25240] Custom properties panel on pinned data fail.
authorCampbell Barton <ideasman42@gmail.com>
Fri, 17 Dec 2010 10:33:28 +0000 (10:33 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 17 Dec 2010 10:33:28 +0000 (10:33 +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 cbe0b668e7731b6b2daf15b80a4146e8c64a1749..7c77a01d646a8b4a68d3cfbf798b1273441781ad 100644 (file)
@@ -58,7 +58,20 @@ def rna_idprop_ui_prop_clear(item, prop):
         pass
 
 
-def draw(layout, context, context_member, use_edit=True):
+def rna_idprop_context_value(context, context_member, property_type):
+    space = context.space_data
+    pin_id = space.pin_id
+
+    if pin_id and isinstance(pin_id, property_type):
+        rna_item = pin_id
+        context_member = "space_data.pin_id"
+    else:
+        rna_item = eval("context." + context_member)
+
+    return rna_item, context_member
+
+
+def draw(layout, context, context_member, property_type, use_edit=True):
 
     def assign_props(prop, val, key):
         prop.data_path = context_member
@@ -69,12 +82,14 @@ def draw(layout, context, context_member, use_edit=True):
         except:
             pass
 
-    rna_item = eval("context." + context_member)
+    rna_item, context_member = rna_idprop_context_value(context, context_member, property_type)
 
     # poll should really get this...
     if not rna_item:
         return
 
+    assert(isinstance(rna_item, property_type))
+
     items = rna_item.items()
     items.sort()
 
@@ -139,7 +154,16 @@ class PropertyPanel():
 
     @classmethod
     def poll(cls, context):
-        return bool(eval("context.%s" % cls._context_path))
+        rna_item, context_member = rna_idprop_context_value(context, cls._context_path, cls._property_type)
+        return bool(rna_item)
+
+    """
+    def draw_header(self, context):
+        rna_item, context_member = rna_idprop_context_value(context, self._context_path, self._property_type)
+        tot = len(rna_item.keys())
+        if tot:
+            self.layout().label("%d:" % tot)
+    """
 
     def draw(self, context):
-        draw(self.layout, context, self._context_path)
+        draw(self.layout, context, self._context_path, self._property_type)
index 5cb7016a90874031cf151879479e513bb2671447..5e13560136bad9b7a284ecd0644a12beb3fec4b2 100644 (file)
@@ -101,7 +101,8 @@ class DATA_PT_display(ArmatureButtonsPanel, bpy.types.Panel):
 
         col = split.column()
         col.prop(arm, "show_group_colors", text="Colors")
-        col.prop(ob, "show_x_ray", text="X-Ray")
+        if ob:
+            col.prop(ob, "show_x_ray", text="X-Ray")
         col.prop(arm, "use_deform_delay", text="Delay Refresh")
 
 
@@ -287,6 +288,7 @@ class DATA_PT_onion_skinning(OnionSkinButtonsPanel):  # , bpy.types.Panel): # in
 class DATA_PT_custom_props_arm(ArmatureButtonsPanel, PropertyPanel, bpy.types.Panel):
     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
     _context_path = "object.data"
+    _property_type = bpy.types.Armature
 
 
 def register():
index 488aa01a47515b52565cffcdaefbd58d55c6c3b9..30a4c635f6f0230965b269237d8150d4e7fecbba 100644 (file)
@@ -135,7 +135,7 @@ class BONE_PT_relations(BoneButtonsPanel, bpy.types.Panel):
         bone = context.bone
         arm = context.armature
 
-        if bone:
+        if ob and bone:
             pchan = ob.pose.bones[bone.name]
         else:
             bone = context.edit_bone
@@ -185,7 +185,7 @@ class BONE_PT_display(BoneButtonsPanel, bpy.types.Panel):
         ob = context.object
         bone = context.bone
 
-        if bone:
+        if ob and bone:
             pchan = ob.pose.bones[bone.name]
         else:
             bone = context.edit_bone
@@ -348,6 +348,7 @@ class BONE_PT_deform(BoneButtonsPanel, bpy.types.Panel):
 
 class BONE_PT_custom_props(BoneButtonsPanel, PropertyPanel, bpy.types.Panel):
     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
+    _property_type = bpy.types.Bone, bpy.types.EditBone, bpy.types.PoseBone
 
     @property
     def _context_path(self):
index ce8f9f7ef59f47db3640d7cd06ceedb3410de129..9c4f19b4c51630c8c5b28498b9061b9fe6ef486e 100644 (file)
@@ -135,6 +135,7 @@ class DATA_PT_camera_display(CameraButtonsPanel, bpy.types.Panel):
 class DATA_PT_custom_props_camera(CameraButtonsPanel, PropertyPanel, bpy.types.Panel):
     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
     _context_path = "object.data"
+    _property_type = bpy.types.Camera
 
 
 def register():
index 821f815ed5e52a494f75b1fc590dd5c617ac08b9..33dcd8d4c7c5760e877efd274434468cb6c343e2 100644 (file)
@@ -396,6 +396,7 @@ class DATA_PT_textboxes(CurveButtonsPanel, bpy.types.Panel):
 class DATA_PT_custom_props_curve(CurveButtonsPanel, PropertyPanel, bpy.types.Panel):
     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
     _context_path = "object.data"
+    _property_type = bpy.types.Curve
 
 
 def register():
index 72e95989b069fd4688eb32e1f56b5d0e7fb4cf9b..9961bf1e77fb1dd598c95c5816f80cd2eea7a13c 100644 (file)
@@ -390,6 +390,7 @@ class DATA_PT_falloff_curve(DataButtonsPanel, bpy.types.Panel):
 class DATA_PT_custom_props_lamp(DataButtonsPanel, PropertyPanel, bpy.types.Panel):
     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
     _context_path = "object.data"
+    _property_type = bpy.types.Lamp
 
 
 def register():
index 469bd07b69170733731114bfc20826ac39743d1a..ae9e9e6f3a89571bef4ce1447b252f6e51f7f2e5 100644 (file)
@@ -85,6 +85,7 @@ class DATA_PT_lattice(DataButtonsPanel, bpy.types.Panel):
 class DATA_PT_custom_props_lattice(DataButtonsPanel, PropertyPanel, bpy.types.Panel):
     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
     _context_path = "object.data"
+    _property_type = bpy.types.Lattice
 
 
 def register():
index c26a36d8ef51eeb27499cc510faf07ea8cfd55d3..4814d06743650f3b3889ff942bf8d98f3443b331 100644 (file)
@@ -302,7 +302,7 @@ class DATA_PT_texface(MeshButtonsPanel, bpy.types.Panel):
 
             split = layout.split()
             col = split.column()
-                       
+
             col.prop(tf, "use_image")
             col.prop(tf, "use_light")
             col.prop(tf, "hide")
@@ -352,6 +352,7 @@ class DATA_PT_vertex_colors(MeshButtonsPanel, bpy.types.Panel):
 class DATA_PT_custom_props_mesh(MeshButtonsPanel, PropertyPanel, bpy.types.Panel):
     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
     _context_path = "object.data"
+    _property_type = bpy.types.Mesh
 
 
 def register():
index 051841562e0545b2526fd25a2d3b45562694fa9e..6cb58cb49390ce11311a78732cbed4def6354778 100644 (file)
@@ -115,9 +115,10 @@ class DATA_PT_metaball_element(DataButtonsPanel, bpy.types.Panel):
             col.prop(metaelem, "size_y", text="Y")
 
 
-class DATA_PT_custom_props_metaball(PropertyPanel, DataButtonsPanel, bpy.types.Panel):
+class DATA_PT_custom_props_metaball(DataButtonsPanel, PropertyPanel, bpy.types.Panel):
     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
     _context_path = "object.data"
+    _property_type = bpy.types.MetaBall
 
 
 def register():
index 6877d5da43a766e627d8b02d927d61d5d002427e..6bfebc444b9369596bccd76b4c287667f80e8b9e 100644 (file)
@@ -892,6 +892,7 @@ class MATERIAL_PT_volume_options(VolumeButtonsPanel, bpy.types.Panel):
 class MATERIAL_PT_custom_props(MaterialButtonsPanel, PropertyPanel, bpy.types.Panel):
     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
     _context_path = "material"
+    _property_type = bpy.types.Material
 
 
 def register():
index 6390f13b668a9833cdf4d8d5a7dd67c87d2b9d38..d0184c2d0af516c3dcd7cb8173ca8d550cc75c48 100644 (file)
@@ -335,9 +335,10 @@ class OBJECT_PT_onion_skinning(OnionSkinButtonsPanel):  # , bpy.types.Panel): #
         self.draw_settings(context, ob.animation_visualisation)
 
 
-class OBJECT_PT_custom_props(bpy.types.Panel, PropertyPanel, ObjectButtonsPanel):
+class OBJECT_PT_custom_props(ObjectButtonsPanel, PropertyPanel, bpy.types.Panel):
     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
     _context_path = "object"
+    _property_type = bpy.types.Object
 
 
 def register():
index af60c5fd784ffe8ae0f7b78c65378a93f45d37b8..e8bfdf913f115fcb2654241de895aa24cb1406f0 100644 (file)
@@ -1093,6 +1093,7 @@ class PARTICLE_PT_vertexgroups(ParticleButtonsPanel, bpy.types.Panel):
 class PARTICLE_PT_custom_props(ParticleButtonsPanel, PropertyPanel, bpy.types.Panel):
     COMPAT_ENGINES = {'BLENDER_RENDER'}
     _context_path = "particle_system.settings"
+    _property_type = bpy.types.ParticleSettings
 
 
 def register():
index 4855b309bf443980a6e66cb5aae14c5eac53ee32..bc735e574934e04de063e478f3abf2f272646c48 100644 (file)
@@ -197,6 +197,7 @@ class SCENE_PT_simplify(SceneButtonsPanel, bpy.types.Panel):
 class SCENE_PT_custom_props(SceneButtonsPanel, PropertyPanel, bpy.types.Panel):
     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
     _context_path = "scene"
+    _property_type = bpy.types.Scene
 
 
 from bpy.props import *
index b343035b29aea9429b8879e8e9ff8cca3978fb92..c6fa942eb2d356c559ce14548bc587d4e73fd686 100644 (file)
@@ -1003,6 +1003,7 @@ class TEXTURE_PT_influence(TextureSlotPanel, bpy.types.Panel):
 class TEXTURE_PT_custom_props(TextureButtonsPanel, PropertyPanel, bpy.types.Panel):
     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
     _context_path = "texture"
+    _property_type = bpy.types.Texture
 
 
 def register():
index 76fb70f47d1c1332c55c016b33fec3034d0f9762..8b6ad827c1d6d3da27e6857978753c14ffa3a7af 100644 (file)
@@ -264,6 +264,7 @@ class WORLD_PT_stars(WorldButtonsPanel, bpy.types.Panel):
 class WORLD_PT_custom_props(WorldButtonsPanel, PropertyPanel, bpy.types.Panel):
     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
     _context_path = "world"
+    _property_type = bpy.types.World
 
 
 def register():