UI:
* Fix context.cloth, was not being set correct. * Fix errors with context pinning, scripts should not assume context.object to be there. * Always show preview even if e.g. the material is not set, to keep ID buttons from jumping while you're using them.
This commit is contained in:
@@ -14,7 +14,7 @@ class DATA_PT_skeleton(DataButtonsPanel):
|
||||
__label__ = "Skeleton"
|
||||
|
||||
def poll(self, context):
|
||||
return (context.object.type == 'ARMATURE' or context.armature)
|
||||
return ((context.object and context.object.type == 'ARMATURE') or context.armature)
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
@@ -14,7 +14,7 @@ class DATA_PT_camera(DataButtonsPanel):
|
||||
__label__ = "Lens"
|
||||
|
||||
def poll(self, context):
|
||||
return (context.object.type == 'CAMERA')
|
||||
return (context.object and context.object.type == 'CAMERA')
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
@@ -7,14 +7,14 @@ class DataButtonsPanel(bpy.types.Panel):
|
||||
__context__ = "data"
|
||||
|
||||
def poll(self, context):
|
||||
return (context.object.type == 'CURVE' and context.curve)
|
||||
return (context.object and context.object.type == 'CURVE' and context.curve)
|
||||
|
||||
class DATA_PT_shape_curve(DataButtonsPanel):
|
||||
__idname__ = "DATA_PT_shape_curve"
|
||||
__label__ = "Shape"
|
||||
|
||||
def poll(self, context):
|
||||
return (context.object.type == 'CURVE')
|
||||
return (context.object and context.object.type == 'CURVE')
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
@@ -7,7 +7,7 @@ class DataButtonsPanel(bpy.types.Panel):
|
||||
__context__ = "data"
|
||||
|
||||
def poll(self, context):
|
||||
return (context.object.type == 'EMPTY')
|
||||
return (context.object and context.object.type == 'EMPTY')
|
||||
|
||||
class DATA_PT_empty(DataButtonsPanel):
|
||||
__idname__ = "DATA_PT_empty"
|
||||
|
||||
@@ -24,7 +24,7 @@ class DATA_PT_lamp(DataButtonsPanel):
|
||||
__label__ = "Lamp"
|
||||
|
||||
def poll(self, context):
|
||||
return (context.object.type == 'LAMP')
|
||||
return ((context.object and context.object.type == 'LAMP') or context.lamp)
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
@@ -14,7 +14,7 @@ class DATA_PT_lattice(DataButtonsPanel):
|
||||
__label__ = "Lattice"
|
||||
|
||||
def poll(self, context):
|
||||
return (context.object.type == 'LATTICE')
|
||||
return (context.object and context.object.type == 'LATTICE')
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
@@ -14,7 +14,7 @@ class DATA_PT_mesh(DataButtonsPanel):
|
||||
__label__ = "Mesh"
|
||||
|
||||
def poll(self, context):
|
||||
return (context.object.type == 'MESH')
|
||||
return (context.object and context.object.type == 'MESH')
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
@@ -7,7 +7,7 @@ class DataButtonsPanel(bpy.types.Panel):
|
||||
__context__ = "data"
|
||||
|
||||
def poll(self, context):
|
||||
return (context.object.type == 'TEXT' and context.curve)
|
||||
return (context.object and context.object.type == 'TEXT' and context.curve)
|
||||
|
||||
class DATA_PT_shape_text(DataButtonsPanel):
|
||||
__idname__ = "DATA_PT_shape_text"
|
||||
@@ -15,7 +15,7 @@ class DATA_PT_shape_text(DataButtonsPanel):
|
||||
|
||||
def poll(self, context):
|
||||
ob = context.object
|
||||
return (context.object.type == 'TEXT')
|
||||
return (context.object and context.object.type == 'TEXT')
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
@@ -13,6 +13,9 @@ class MATERIAL_PT_preview(MaterialButtonsPanel):
|
||||
__idname__= "MATERIAL_PT_preview"
|
||||
__label__ = "Preview"
|
||||
|
||||
def poll(self, context):
|
||||
return (context.material or context.material_slot)
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
mat = context.material
|
||||
@@ -24,7 +27,7 @@ class MATERIAL_PT_material(MaterialButtonsPanel):
|
||||
__label__ = "Material"
|
||||
|
||||
def poll(self, context):
|
||||
return (context.object != None)
|
||||
return (context.material or context.material_slot)
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
@@ -50,13 +50,13 @@ class Physic_PT_cloth_collision(PhysicButtonsPanel):
|
||||
|
||||
def draw_header(self, context):
|
||||
layout = self.layout
|
||||
cloth = context.cloth.settings
|
||||
cloth = context.cloth.collision_settings
|
||||
|
||||
layout.itemR(cloth, "enable_collision", text="")
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
cloth = context.cloth.settings
|
||||
cloth = context.cloth.collision_settings
|
||||
|
||||
layout.active = cloth.enable_collision
|
||||
|
||||
|
||||
@@ -13,6 +13,9 @@ class TEXTURE_PT_preview(TextureButtonsPanel):
|
||||
__idname__= "TEXTURE_PT_preview"
|
||||
__label__ = "Preview"
|
||||
|
||||
def poll(self, context):
|
||||
return (context.material or context.world or context.lamp or context.texture)
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
tex = context.texture
|
||||
@@ -24,7 +27,7 @@ class TEXTURE_PT_texture(TextureButtonsPanel):
|
||||
__label__ = "Texture"
|
||||
|
||||
def poll(self, context):
|
||||
return (context.material or context.world or context.lamp)
|
||||
return (context.material or context.world or context.lamp or context.texture)
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
@@ -12,6 +12,9 @@ class WorldButtonsPanel(bpy.types.Panel):
|
||||
class WORLD_PT_preview(WorldButtonsPanel):
|
||||
__label__ = "Preview"
|
||||
|
||||
def poll(self, context):
|
||||
return (context.scene or context.world)
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
world = context.world
|
||||
|
||||
@@ -574,9 +574,15 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r
|
||||
return 1;
|
||||
}
|
||||
else if(CTX_data_equals(member, "cloth")) {
|
||||
set_pointer_type(path, result, &RNA_ClothModifier);
|
||||
PointerRNA *ptr= get_pointer_type(path, &RNA_Object);
|
||||
|
||||
if(ptr && ptr->data) {
|
||||
Object *ob= ptr->data;
|
||||
ModifierData *md= modifiers_findByType(ob, eModifierType_Cloth);
|
||||
CTX_data_pointer_set(result, &ob->id, &RNA_ClothModifier, md);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if(CTX_data_equals(member, "soft_body")) {
|
||||
PointerRNA *ptr= get_pointer_type(path, &RNA_Object);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user