bugfix [#25240] Custom properties panel on pinned data fail.
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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():
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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():
|
||||
|
||||
@@ -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():
|
||||
|
||||
@@ -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():
|
||||
|
||||
@@ -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():
|
||||
|
||||
@@ -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():
|
||||
|
||||
@@ -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():
|
||||
|
||||
@@ -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():
|
||||
|
||||
@@ -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():
|
||||
|
||||
@@ -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():
|
||||
|
||||
@@ -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 *
|
||||
|
||||
@@ -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():
|
||||
|
||||
@@ -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():
|
||||
|
||||
Reference in New Issue
Block a user