UI:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Thu, 18 Jun 2009 14:20:25 +0000 (14:20 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Thu, 18 Jun 2009 14:20:25 +0000 (14:20 +0000)
* 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.

13 files changed:
release/ui/buttons_data_armature.py
release/ui/buttons_data_camera.py
release/ui/buttons_data_curve.py
release/ui/buttons_data_empty.py
release/ui/buttons_data_lamp.py
release/ui/buttons_data_lattice.py
release/ui/buttons_data_mesh.py
release/ui/buttons_data_text.py
release/ui/buttons_material.py
release/ui/buttons_physic_cloth.py
release/ui/buttons_texture.py
release/ui/buttons_world.py
source/blender/editors/space_buttons/buttons_context.c

index 1086e77c3f79ac7fbbc47b952fff246476eab4f7..c536f6bb87d481fd69ae81a125bdf3c0bd593cb2 100644 (file)
@@ -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
@@ -127,4 +127,4 @@ class DATA_PT_ghost(DataButtonsPanel):
 bpy.types.register(DATA_PT_skeleton)
 bpy.types.register(DATA_PT_display)
 bpy.types.register(DATA_PT_paths)
-bpy.types.register(DATA_PT_ghost)
\ No newline at end of file
+bpy.types.register(DATA_PT_ghost)
index 57abafb95c85e02b7b8b45ff56a2b44bc918c795..db2a1f9db25c60e149d2d8df3c08e5e07d9b3278 100644 (file)
@@ -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
@@ -87,4 +87,4 @@ class DATA_PT_camera_display(DataButtonsPanel):
                col.itemR(cam, "draw_size", text="Size")
                
 bpy.types.register(DATA_PT_camera)
-bpy.types.register(DATA_PT_camera_display)
\ No newline at end of file
+bpy.types.register(DATA_PT_camera_display)
index f42c991a36fbc619d48ed7f7a0c69951f77f3476..869d29802e1d8e8ce1020790511bf717eefe7a2b 100644 (file)
@@ -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
@@ -144,4 +144,4 @@ class DATA_PT_current_curve(DataButtonsPanel):
 bpy.types.register(DATA_PT_shape_curve)
 bpy.types.register(DATA_PT_geometry)
 bpy.types.register(DATA_PT_pathanim)
-bpy.types.register(DATA_PT_current_curve)
\ No newline at end of file
+bpy.types.register(DATA_PT_current_curve)
index 7eed54d1db6346e5eaa8464a83024c4cb30e7f03..f97dedcf6cf1080cba57abdd9c887759067faf7d 100644 (file)
@@ -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"
@@ -20,4 +20,4 @@ class DATA_PT_empty(DataButtonsPanel):
                layout.itemR(ob, "empty_draw_type")
                layout.itemR(ob, "empty_draw_size")
                
-bpy.types.register(DATA_PT_empty)
\ No newline at end of file
+bpy.types.register(DATA_PT_empty)
index 7328abc7c35f90476cb5c8e3d014f3c185916941..52a60ce617e99c7a4a035b96122ad2ee00f53171 100644 (file)
@@ -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
@@ -249,4 +249,4 @@ bpy.types.register(DATA_PT_lamp)
 bpy.types.register(DATA_PT_shadow)
 bpy.types.register(DATA_PT_sunsky)
 bpy.types.register(DATA_PT_spot)
-bpy.types.register(DATA_PT_falloff_curve)
\ No newline at end of file
+bpy.types.register(DATA_PT_falloff_curve)
index 9382ee3525cb9d5eb57469ef748a367f7b2fa7b1..ad9b1b518b8eafea8c96e1d200ce020e29883be1 100644 (file)
@@ -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
@@ -51,4 +51,4 @@ class DATA_PT_lattice(DataButtonsPanel):
                        row.itemR(lat, "outside")
                        row.itemR(lat, "shape_keys")
 
-bpy.types.register(DATA_PT_lattice)
\ No newline at end of file
+bpy.types.register(DATA_PT_lattice)
index 5e4fb203944c9fd1bc7e0142352e9eeefbe77cb5..c103a0f70557cbb2e028ac222620b25aa4da6a2d 100644 (file)
@@ -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
@@ -48,4 +48,4 @@ class DATA_PT_mesh(DataButtonsPanel):
                        
                        layout.itemR(mesh, "texco_mesh")                        
                                        
-bpy.types.register(DATA_PT_mesh)
\ No newline at end of file
+bpy.types.register(DATA_PT_mesh)
index d6f6feaa389cac799d07b6493bcea156b52a2fdf..bce16e78a40a59d834834f0089523c5e88268b62 100644 (file)
@@ -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
index b7703bca94eaa4c76674ba8ffa004faf58d97c09..124fba83608c9ea136fa9292200eda4ac92463c3 100644 (file)
@@ -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
@@ -419,4 +422,4 @@ bpy.types.register(MATERIAL_PT_raytransp)
 bpy.types.register(MATERIAL_PT_sss)
 bpy.types.register(MATERIAL_PT_halo)
 bpy.types.register(MATERIAL_PT_strand)
-bpy.types.register(MATERIAL_PT_options)
\ No newline at end of file
+bpy.types.register(MATERIAL_PT_options)
index 09c21b4eb641d3e5714ce612cdafdd092f990fff..bd65392ad63426d5d2350b74d84b73bf95f66d6e 100644 (file)
@@ -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  
                
@@ -103,4 +103,4 @@ class Physic_PT_cloth_stiffness(PhysicButtonsPanel):
                
 bpy.types.register(Physic_PT_cloth)
 bpy.types.register(Physic_PT_cloth_collision)
-bpy.types.register(Physic_PT_cloth_stiffness)
\ No newline at end of file
+bpy.types.register(Physic_PT_cloth_stiffness)
index 286c1240d0ea011335e4c9848082964af2a91a0d..de166cef796b880e64a765aa1253a13d038ae232 100644 (file)
@@ -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
index 647ef8aa65ed1cd70c5949fb37d9dcd76241e048..d9516cb7900519979ad48e4131d9c6887b3b7705 100644 (file)
@@ -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
@@ -176,4 +179,4 @@ 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_color_correction)
\ No newline at end of file
+bpy.types.register(WORLD_PT_color_correction)
index 255bee1bf5a7089e0daeb8d13a226998a766792d..42180e7902f409a2dff8ad01e9dab155c498bd78 100644 (file)
@@ -574,8 +574,14 @@ 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);
-               return 1;
+               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);