2.5 Interface:
authorThomas Dinges <blender@dingto.org>
Mon, 25 Apr 2011 13:47:15 +0000 (13:47 +0000)
committerThomas Dinges <blender@dingto.org>
Mon, 25 Apr 2011 13:47:15 +0000 (13:47 +0000)
* Implemented a new operator "WM_OT_properties_context_change" to switch to a different tab inside the properties window.
* This is used now inside the Modifier tab for Simulation Modifiers. Based on a mockup by Janne Karhu:
http://www.pasteall.org/pic/11261
http://www.pasteall.org/pic/11262

Rather than having a delete button there anymore, the button changes the context to Physics/Particles, where you can edit the settings and delete the actual simulation.

release/scripts/startup/bl_operators/wm.py
source/blender/editors/interface/interface_templates.c
source/blender/makesrna/intern/rna_space.c

index adcd9c7c45a9f6e5c50b1b0dd208d9e4210ede27..6161aa4aa1959454da6b3fb0b58cabe35edf686c 100644 (file)
@@ -837,6 +837,18 @@ class WM_OT_properties_add(bpy.types.Operator):
         item[property] = 1.0
         return {'FINISHED'}
 
+class WM_OT_properties_context_change(bpy.types.Operator):
+    "Change the context tab in a Properties Window"
+    bl_idname = "wm.properties_context_change"
+    bl_label = ""
+
+    context = StringProperty(name="Context", maxlen=32)
+
+    def execute(self, context):
+        context.space_data.context = (self.context)
+               
+        return {'FINISHED'}
+
 
 class WM_OT_properties_remove(bpy.types.Operator):
     '''Internal use (edit a property data_path)'''
index 01e785ef88cbbbd028b93ed928df0e4721e2ff67..94f12911d337ce7db2315a32f9035d2445ccd776 100644 (file)
@@ -673,6 +673,22 @@ static int modifier_can_delete(ModifierData *md)
        return 1;
 }
 
+// Check wheter Modifier is a simulation or not, this is used for switching to the physics/particles context tab
+static int modifier_is_simulation(ModifierData *md)
+{
+       // Physic Tab
+       if(ELEM6(md->type, eModifierType_Cloth, eModifierType_Collision, eModifierType_Fluidsim, eModifierType_Smoke, eModifierType_Softbody, eModifierType_Surface)) {
+               return 1;
+       }
+       // Particle Tab
+       else if (md->type == eModifierType_ParticleSystem) {
+               return 2;
+       }
+       else {
+               return 0;
+       }
+}
+
 static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob, ModifierData *md, int index, int cageIndex, int lastCageIndex)
 {
        ModifierTypeInfo *mti = modifierType_getInfo(md->type);
@@ -765,8 +781,13 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob, Modif
                uiBlockEndAlign(block);
                
                uiBlockSetEmboss(block, UI_EMBOSSN);
-               if (modifier_can_delete(md))
+               // When Modifier is a simulation, show button to switch to context rather than the delete button. 
+               if (modifier_can_delete(md) && !modifier_is_simulation(md))
                        uiItemO(row, "", ICON_X, "OBJECT_OT_modifier_remove");
+               if (modifier_is_simulation(md) == 1)
+                       uiItemStringO(row, "", ICON_BUTS, "WM_OT_properties_context_change", "context", "PHYSICS");
+               else if (modifier_is_simulation(md) == 2)
+                       uiItemStringO(row, "", ICON_BUTS, "WM_OT_properties_context_change", "context", "PARTICLES");
                uiBlockSetEmboss(block, UI_EMBOSS);
        }
 
index 6fad664943da964e8bd2f3ea0acd6858e5187bf0..ba33fc7feda93ee5d0b466be7907323ccc370f56 100644 (file)
@@ -1436,7 +1436,7 @@ static void rna_def_space_buttons(BlenderRNA *brna)
                {BCONTEXT_BONE_CONSTRAINT, "BONE_CONSTRAINT", ICON_CONSTRAINT, "Bone Constraints", "Bone Constraints"},
                {BCONTEXT_MATERIAL, "MATERIAL", ICON_MATERIAL, "Material", "Material"},
                {BCONTEXT_TEXTURE, "TEXTURE", ICON_TEXTURE, "Texture", "Texture"},
-               {BCONTEXT_PARTICLE, "PARTICLE", ICON_PARTICLES, "Particle", "Particle"},
+               {BCONTEXT_PARTICLE, "PARTICLES", ICON_PARTICLES, "Particles", "Particle"},
                {BCONTEXT_PHYSICS, "PHYSICS", ICON_PHYSICS, "Physics", "Physics"},
                {0, NULL, 0, NULL, NULL}};