UI:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Wed, 3 Jun 2009 23:33:56 +0000 (23:33 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Wed, 3 Jun 2009 23:33:56 +0000 (23:33 +0000)
* First step for buttons context browsing, read-only still.
* Drawn in a panel now, though this should become a separate region.
* Path of the context is constructed as an array of RNA pointers and
  then used for drawing and context lookups from python.

source/blender/blenloader/intern/readfile.c
source/blender/editors/interface/interface_panel.c
source/blender/editors/preview/previewrender.c
source/blender/editors/screen/area.c
source/blender/editors/space_buttons/buttons_context.c
source/blender/editors/space_buttons/buttons_intern.h
source/blender/editors/space_buttons/space_buttons.c
source/blender/editors/space_outliner/outliner.c
source/blender/makesdna/DNA_space_types.h
source/blender/makesrna/intern/rna_texture.c

index f8657125014c888a9263ed164d04c3232397bc8a..78a156559ff17e6229e4882360a322f18fde5259 100644 (file)
@@ -4190,6 +4190,7 @@ static void lib_link_screen(FileData *fd, Main *main)
                                                SpaceButs *sbuts= (SpaceButs *)sl;
                                                sbuts->lockpoin= NULL;
                                                sbuts->ri= NULL;
+                                               sbuts->pinid= newlibadr(fd, sc->id.lib, sbuts->pinid);
                                                if(main->versionfile<132)
                                                        butspace_version_132(sbuts);
                                        }
@@ -4391,6 +4392,7 @@ void lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *curscene)
                                else if(sl->spacetype==SPACE_BUTS) {
                                        SpaceButs *sbuts= (SpaceButs *)sl;
                                        sbuts->lockpoin= NULL;
+                                       sbuts->pinid = restore_pointer_by_name(newmain, sbuts->pinid, 0);
                                        //XXX if (sbuts->ri) sbuts->ri->curtile = 0;
                                }
                                else if(sl->spacetype==SPACE_FILE) {
@@ -4674,6 +4676,10 @@ static void direct_link_screen(FileData *fd, bScreen *sc)
                                        direct_link_gpencil(fd, sseq->gpd);
                                }
                        }
+                       else if(sl->spacetype==SPACE_BUTS) {
+                               SpaceButs *sbuts= (SpaceButs *)sl;
+                               sbuts->path= NULL;
+                       }
                }
                
                sa->actionzones.first= sa->actionzones.last= NULL;
@@ -6744,26 +6750,26 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                                        
                                                if(sbuts->mainb==BUTS_LAMP) {
                                                        sbuts->mainb= CONTEXT_SHADING;
-                                                       sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_LAMP;
+                                                       //sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_LAMP;
                                                }
                                                else if(sbuts->mainb==BUTS_MAT) {
                                                        sbuts->mainb= CONTEXT_SHADING;
-                                                       sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_MAT;
+                                                       //sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_MAT;
                                                }
                                                else if(sbuts->mainb==BUTS_TEX) {
                                                        sbuts->mainb= CONTEXT_SHADING;
-                                                       sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_TEX;
+                                                       //sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_TEX;
                                                }
                                                else if(sbuts->mainb==BUTS_ANIM) {
                                                        sbuts->mainb= CONTEXT_OBJECT;
                                                }
                                                else if(sbuts->mainb==BUTS_WORLD) {
                                                        sbuts->mainb= CONTEXT_SCENE;
-                                                       sbuts->tab[CONTEXT_SCENE]= TAB_SCENE_WORLD;
+                                                       //sbuts->tab[CONTEXT_SCENE]= TAB_SCENE_WORLD;
                                                }
                                                else if(sbuts->mainb==BUTS_RENDER) {
                                                        sbuts->mainb= CONTEXT_SCENE;
-                                                       sbuts->tab[CONTEXT_SCENE]= TAB_SCENE_RENDER;
+                                                       //sbuts->tab[CONTEXT_SCENE]= TAB_SCENE_RENDER;
                                                }
                                                else if(sbuts->mainb==BUTS_GAME) {
                                                        sbuts->mainb= CONTEXT_LOGIC;
@@ -6773,7 +6779,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                                                }
                                                else if(sbuts->mainb==BUTS_RADIO) {
                                                        sbuts->mainb= CONTEXT_SHADING;
-                                                       sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_RAD;
+                                                       //sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_RAD;
                                                }
                                                else if(sbuts->mainb==BUTS_CONSTRAINT) {
                                                        sbuts->mainb= CONTEXT_OBJECT;
index 539f18c2cd81693821e53478d10fcb158d3a2762..a141e58fbe9802ef4fb9b9806fb1f58634c9e7ad 100644 (file)
@@ -119,7 +119,7 @@ static int panels_re_align(ScrArea *sa, ARegion *ar, Panel **r_pa)
                SpaceButs *sbuts= sa->spacedata.first;
 
                if(sbuts->align)
-                       if(sbuts->re_align || sbuts->mainbo!=sbuts->mainb || sbuts->tabo!=sbuts->tab[sbuts->mainb])
+                       if(sbuts->re_align || sbuts->mainbo!=sbuts->mainb)
                                return 1;
        }
        else if(ar->regiontype==RGN_TYPE_UI)
index 1d5d809a9ee5c7a82523663d7c79c7d4dfac25b0..85cb1e4e1bf9d2057e0b1ff13ae46762ea03e4d5 100644 (file)
@@ -586,7 +586,7 @@ void BIF_previewrender_buts(Scene *scene, SpaceButs *sbuts)
        sbuts->lockpoin= id;
        
        if(sbuts->mainb==CONTEXT_SHADING) {
-               int tab= sbuts->tab[CONTEXT_SHADING];
+               int tab= TAB_SHADING_MAT; // XXX sbuts->tab[CONTEXT_SHADING];
                
                if(tab==TAB_SHADING_MAT) 
                        idshow = sbuts->lockpoin;
index 7d9cc748d0571622cc1518ec52d02cef67e095d3..81b63b694ba1366bed5dc175ac7b3497a6b45921 100644 (file)
@@ -1137,7 +1137,7 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, char *contex
        for(pt= ar->type->paneltypes.first; pt; pt= pt->next) {
                /* verify context */
                if(context)
-                       if(!pt->context || strcmp(context, pt->context) != 0)
+                       if(pt->context[0] && strcmp(context, pt->context) != 0)
                                continue;
 
                /* draw panel */
index 642aab52e9d210c527b2575424f6b65a0d90de8f..3e6fa9c6cffbab2e78e8316605203b20b5c921fe 100644 (file)
  */
 
 #include <stdlib.h>
+#include <string.h>
+
+#include "MEM_guardedalloc.h"
 
 #include "DNA_armature_types.h"
-#include "DNA_object_types.h"
+#include "DNA_lamp_types.h"
 #include "DNA_material_types.h"
 #include "DNA_modifier_types.h"
+#include "DNA_object_types.h"
 #include "DNA_scene_types.h"
+#include "DNA_screen_types.h"
+#include "DNA_space_types.h"
 #include "DNA_particle_types.h"
 #include "DNA_texture_types.h"
 #include "DNA_world_types.h"
 
+#include "BLI_listbase.h"
+
 #include "BKE_context.h"
 #include "BKE_material.h"
 #include "BKE_modifier.h"
 #include "BKE_particle.h"
+#include "BKE_screen.h"
+#include "BKE_utildefines.h"
 
 #include "RNA_access.h"
 
+#include "UI_interface.h"
+#include "UI_resources.h"
+
 #include "buttons_intern.h"    // own include
 
-int buttons_context(const bContext *C, const char *member, bContextDataResult *result)
+typedef struct ButsContextPath {
+       PointerRNA ptr[8];
+       int len;
+} ButsContextPath;
+
+/************************* Creating the Path ************************/
+
+static int buttons_context_path_scene(ButsContextPath *path)
+{
+       PointerRNA *ptr= &path->ptr[path->len-1];
+
+       /* this one just verifies */
+       return RNA_struct_is_a(ptr->type, &RNA_Scene);
+}
+
+static int buttons_context_path_world(ButsContextPath *path)
 {
-       Scene *scene= CTX_data_scene(C);
-       Object *ob= (scene->basact)? scene->basact->object: NULL;
+       Scene *scene;
+       PointerRNA *ptr= &path->ptr[path->len-1];
 
-       if(CTX_data_equals(member, "scene")) {
-               CTX_data_pointer_set(result, &scene->id, &RNA_Scene, scene);
+       /* if we already have a (pinned) world, we're done */
+       if(RNA_struct_is_a(ptr->type, &RNA_World)) {
                return 1;
        }
-       else if(CTX_data_equals(member, "world")) {
-               CTX_data_pointer_set(result, &scene->world->id, &RNA_World, scene->world);
+       /* if we have a scene, use the scene's world */
+       else if(buttons_context_path_scene(path)) {
+               scene= path->ptr[path->len-1].data;
+
+               RNA_id_pointer_create(&scene->world->id, &path->ptr[path->len]);
+               path->len++;
+
                return 1;
        }
-       else if(CTX_data_equals(member, "object")) {
-               CTX_data_pointer_set(result, &ob->id, &RNA_Object, ob);
+
+       /* no path to a world possible */
+       return 0;
+}
+
+static int buttons_context_path_object(ButsContextPath *path)
+{
+       Scene *scene;
+       Object *ob;
+       PointerRNA *ptr= &path->ptr[path->len-1];
+
+       /* if we already have a (pinned) object, we're done */
+       if(RNA_struct_is_a(ptr->type, &RNA_Object)) {
                return 1;
        }
-       else if(CTX_data_equals(member, "mesh")) {
-               if(ob && ob->type == OB_MESH) {
-                       CTX_data_pointer_set(result, ob->data, &RNA_Mesh, ob->data);
+       /* if we have a scene, use the scene's active object */
+       else if(buttons_context_path_scene(path)) {
+               scene= path->ptr[path->len-1].data;
+               ob= (scene->basact)? scene->basact->object: NULL;
+
+               if(ob) {
+                       RNA_id_pointer_create(&ob->id, &path->ptr[path->len]);
+                       path->len++;
+
                        return 1;
                }
        }
-       else if(CTX_data_equals(member, "armature")) {
-               if(ob && ob->type == OB_ARMATURE) {
-                       CTX_data_pointer_set(result, ob->data, &RNA_Armature, ob->data);
+
+       /* no path to a object possible */
+       return 0;
+}
+
+static int buttons_context_path_data(ButsContextPath *path, int type)
+{
+       Object *ob;
+
+       /* try to get an object in the path, no pinning supported here */
+       if(buttons_context_path_object(path)) {
+               ob= path->ptr[path->len-1].data;
+
+               if(type == -1 || type == ob->type) {
+                       RNA_id_pointer_create(ob->data, &path->ptr[path->len]);
+                       path->len++;
+
                        return 1;
                }
        }
-       else if(CTX_data_equals(member, "lattice")) {
-               if(ob && ob->type == OB_LATTICE) {
-                       CTX_data_pointer_set(result, ob->data, &RNA_Lattice, ob->data);
+
+       /* no path to data possible */
+       return 0;
+}
+
+static int buttons_context_path_material(ButsContextPath *path)
+{
+       Object *ob;
+       PointerRNA *ptr= &path->ptr[path->len-1];
+
+       /* if we already have a (pinned) material, we're done */
+       if(RNA_struct_is_a(ptr->type, &RNA_Material)) {
+               return 1;
+       }
+       /* if we have an object, use the object material slot */
+       else if(buttons_context_path_object(path)) {
+               ob= path->ptr[path->len-1].data;
+
+               if(ob && ob->type && (ob->type<OB_LAMP)) {
+                       RNA_pointer_create(&ob->id, &RNA_MaterialSlot, ob->mat+ob->actcol-1, &path->ptr[path->len]);
+                       path->len++;
                        return 1;
                }
        }
-       else if(CTX_data_equals(member, "curve")) {
-               if(ob && ob->type == OB_CURVE) {
-                       CTX_data_pointer_set(result, ob->data, &RNA_Curve, ob->data);
+
+       /* no path to a material possible */
+       return 0;
+}
+
+static Bone *find_active_bone(Bone *bone)
+{
+       Bone *active;
+
+       for(; bone; bone=bone->next) {
+               if(bone->flag & BONE_ACTIVE)
+                       return bone;
+
+               active= find_active_bone(bone->childbase.first);
+               if(active)
+                       return active;
+       }
+
+       return NULL;
+}
+
+static int buttons_context_path_bone(ButsContextPath *path)
+{
+       bArmature *arm;
+       Bone *bone;
+
+       /* if we have an armature, get the active bone */
+       if(buttons_context_path_data(path, OB_ARMATURE)) {
+               arm= path->ptr[path->len-1].data;
+               bone= find_active_bone(arm->bonebase.first);
+
+               if(bone) {
+                       RNA_pointer_create(&arm->id, &RNA_Bone, bone, &path->ptr[path->len]);
+                       path->len++;
                        return 1;
                }
        }
-       else if(CTX_data_equals(member, "meta_ball")) {
-               if(ob && ob->type == OB_MBALL) {
-                       CTX_data_pointer_set(result, ob->data, &RNA_MetaBall, ob->data);
+
+       /* no path to a bone possible */
+       return 0;
+}
+
+static int buttons_context_path_particle(ButsContextPath *path)
+{
+       Object *ob;
+       ParticleSystem *psys;
+
+       /* if we have an object, get the active particle system */
+       if(buttons_context_path_object(path)) {
+               ob= path->ptr[path->len-1].data;
+               psys= psys_get_current(ob);
+
+               RNA_pointer_create(&ob->id, &RNA_ParticleSystem, psys, &path->ptr[path->len]);
+               path->len++;
+               return 1;
+       }
+
+       /* no path to a particle system possible */
+       return 0;
+}
+
+static int buttons_context_path_texture(ButsContextPath *path)
+{
+       Object *ob;
+       Lamp *la;
+       Material *ma;
+       PointerRNA *ptr= &path->ptr[path->len-1];
+
+       /* if we already have a (pinned) texture, we're done */
+       if(RNA_struct_is_a(ptr->type, &RNA_Texture)) {
+               return 1;
+       }
+       /* try to get the active material */
+       else if(buttons_context_path_material(path)) {
+               ptr= &path->ptr[path->len-1];
+
+               if(RNA_struct_is_a(ptr->type, &RNA_Material)) {
+                       ma= ptr->data;
+               }
+               else if(RNA_struct_is_a(ptr->type, &RNA_MaterialSlot)) {
+                       ob= ptr->id.data;
+                       ma= give_current_material(ob, (Material**)ptr->data - ob->mat);
+               }
+               else
+                       ma= NULL;
+
+               if(ma) {
+                       RNA_pointer_create(&ma->id, &RNA_TextureSlot, ma->mtex[(int)ma->texact], &path->ptr[path->len]);
+                       path->len++;
                        return 1;
                }
        }
-       else if(CTX_data_equals(member, "lamp")) {
-               if(ob && ob->type == OB_LAMP) {
-                       CTX_data_pointer_set(result, ob->data, &RNA_Lamp, ob->data);
+       /* try to get the active lamp */
+       else if(buttons_context_path_data(path, OB_LAMP)) {
+               la= path->ptr[path->len-1].data;
+
+               if(la) {
+                       RNA_pointer_create(&la->id, &RNA_TextureSlot, la->mtex[(int)la->texact], &path->ptr[path->len]);
+                       path->len++;
                        return 1;
                }
        }
-       else if(CTX_data_equals(member, "camera")) {
-               if(ob && ob->type == OB_CAMERA) {
-                       CTX_data_pointer_set(result, ob->data, &RNA_Camera, ob->data);
+       /* TODO: world, brush */
+
+       /* no path to a particle system possible */
+       return 0;
+}
+
+static int buttons_context_path(const bContext *C, ButsContextPath *path)
+{
+       SpaceButs *sbuts= (SpaceButs*)CTX_wm_space_data(C);
+       ID *id;
+       int found;
+
+       memset(path, 0, sizeof(*path));
+
+       /* if some ID datablock is pinned, set the root pointer */
+       if(sbuts->pinid) {
+               id= sbuts->pinid;
+
+               RNA_id_pointer_create(id, &path->ptr[0]);
+               path->len++;
+       }
+
+       /* no pinned root, use scene as root */
+       if(path->len == 0) {
+               id= (ID*)CTX_data_scene(C);
+               RNA_id_pointer_create(id, &path->ptr[0]);
+               path->len++;
+       }
+
+       /* now for each buttons context type, we try to construct a path,
+        * tracing back recursively */
+       switch(sbuts->mainb) {
+               case BCONTEXT_SCENE:
+                       found= buttons_context_path_scene(path);
+                       break;
+               case BCONTEXT_WORLD:
+                       found= buttons_context_path_world(path);
+                       break;
+               case BCONTEXT_OBJECT:
+               case BCONTEXT_PHYSICS:
+               case BCONTEXT_MODIFIER:
+                       found= buttons_context_path_object(path);
+                       break;
+               case BCONTEXT_DATA:
+                       found= buttons_context_path_data(path, -1);
+                       break;
+               case BCONTEXT_PARTICLE:
+                       found= buttons_context_path_particle(path);
+                       break;
+               case BCONTEXT_MATERIAL:
+                       found= buttons_context_path_material(path);
+                       break;
+               case BCONTEXT_TEXTURE:
+                       found= buttons_context_path_texture(path);
+                       break;
+               case BCONTEXT_BONE:
+                       found= buttons_context_path_bone(path);
+                       break;
+               default:
+                       found= 0;
+                       break;
+       }
+
+       return found;
+}
+
+void buttons_context_compute(const bContext *C, SpaceButs *sbuts)
+{
+       if(!sbuts->path)
+               sbuts->path= MEM_callocN(sizeof(ButsContextPath), "ButsContextPath");
+       
+       buttons_context_path(C, sbuts->path);
+}
+
+/************************* Context Callback ************************/
+
+static int set_pointer_type(ButsContextPath *path, bContextDataResult *result, StructRNA *type)
+{
+       PointerRNA *ptr;
+       int a;
+
+       for(a=0; a<path->len; a++) {
+               ptr= &path->ptr[a];
+
+               if(RNA_struct_is_a(ptr->type, type)) {
+                       CTX_data_pointer_set(result, ptr->id.data, ptr->type, ptr->data);
                        return 1;
                }
        }
+
+       return 0;
+}
+
+static PointerRNA *get_pointer_type(ButsContextPath *path, StructRNA *type)
+{
+       PointerRNA *ptr;
+       int a;
+
+       for(a=0; a<path->len; a++) {
+               ptr= &path->ptr[a];
+
+               if(RNA_struct_is_a(ptr->type, type))
+                       return ptr;
+       }
+
+       return NULL;
+}
+
+int buttons_context(const bContext *C, const char *member, bContextDataResult *result)
+{
+       SpaceButs *sbuts= (SpaceButs*)CTX_wm_space_data(C);
+       ButsContextPath *path= sbuts->path;
+
+       if(!path)
+               return 0;
+
+       /* here we handle context, getting data from precomputed path */
+
+       if(CTX_data_equals(member, "world")) {
+               set_pointer_type(path, result, &RNA_World);
+               return 1;
+       }
+       else if(CTX_data_equals(member, "object")) {
+               set_pointer_type(path, result, &RNA_Object);
+               return 1;
+       }
+       else if(CTX_data_equals(member, "mesh")) {
+               set_pointer_type(path, result, &RNA_Mesh);
+               return 1;
+       }
+       else if(CTX_data_equals(member, "armature")) {
+               set_pointer_type(path, result, &RNA_Armature);
+               return 1;
+       }
+       else if(CTX_data_equals(member, "lattice")) {
+               set_pointer_type(path, result, &RNA_Lattice);
+               return 1;
+       }
+       else if(CTX_data_equals(member, "curve")) {
+               set_pointer_type(path, result, &RNA_Curve);
+               return 1;
+       }
+       else if(CTX_data_equals(member, "meta_ball")) {
+               set_pointer_type(path, result, &RNA_MetaBall);
+               return 1;
+       }
+       else if(CTX_data_equals(member, "lamp")) {
+               set_pointer_type(path, result, &RNA_Lamp);
+               return 1;
+       }
+       else if(CTX_data_equals(member, "camera")) {
+               set_pointer_type(path, result, &RNA_Camera);
+               return 1;
+       }
        else if(CTX_data_equals(member, "material")) {
-               if(ob && ob->type && (ob->type<OB_LAMP)) {
-                       Material *ma= give_current_material(ob, ob->actcol);
-                       CTX_data_pointer_set(result, &ma->id, &RNA_Material, ma);
-                       return 1;
+               if(!set_pointer_type(path, result, &RNA_Material)) {
+                       PointerRNA *ptr= get_pointer_type(path, &RNA_MaterialSlot);
+
+                       if(ptr && ptr->data) {
+                               Object *ob= ptr->id.data;
+                               Material *ma= give_current_material(ob, (Material**)ptr->data - ob->mat);
+                               CTX_data_id_pointer_set(result, &ma->id);
+                       }
                }
+
+               return 1;
        }
        else if(CTX_data_equals(member, "texture")) {
-               if(ob && ob->type && (ob->type<OB_LAMP)) {
-                       Material *ma= give_current_material(ob, ob->actcol);
-
-                       if(ma) {
-                               MTex *mtex= ma->mtex[(int)ma->texact];
-                               
-                               if(mtex->tex) {
-                                       CTX_data_pointer_set(result, &mtex->tex->id, &RNA_Texture, mtex->tex);
-                                       return 1;
-                               }
-                       }
+               if(!set_pointer_type(path, result, &RNA_Texture)) {
+                       PointerRNA *ptr= get_pointer_type(path, &RNA_TextureSlot);
+
+                       if(ptr && ptr->data)
+                               CTX_data_id_pointer_set(result, &((MTex*)ptr->data)->tex->id);
                }
+
+               return 1;
        }
        else if(CTX_data_equals(member, "material_slot")) {
+               set_pointer_type(path, result, &RNA_MaterialSlot);
+               return 1;
        }
        else if(CTX_data_equals(member, "texture_slot")) {
-               if(ob && ob->type && (ob->type<OB_LAMP)) {
-                       Material *ma= give_current_material(ob, ob->actcol);
-
-                       if(ma) {
-                               MTex *mtex= ma->mtex[(int)ma->texact];
-                               
-                               CTX_data_pointer_set(result, &ma->id, &RNA_TextureSlot, mtex);
-                               return 1;
-                       }
-               }
+               set_pointer_type(path, result, &RNA_TextureSlot);
+               return 1;
        }
        else if(CTX_data_equals(member, "bone")) {
-               if(ob && ob->type == OB_ARMATURE) {
-                       bArmature *arm= ob->data;
-                       Bone *bone;
-
-                       for(bone=arm->bonebase.first; bone; bone=bone->next) {
-                               if(bone->flag & BONE_ACTIVE) {
-                                       CTX_data_pointer_set(result, &arm->id, &RNA_Bone, bone);
-                                       return 1;
-                               }
-                       }
-               }
+               set_pointer_type(path, result, &RNA_Bone);
+               return 1;
        }
        else if(CTX_data_equals(member, "particle_system")) {
-               if(ob) {
-                       ParticleSystem *psys= psys_get_current(ob);
-                       CTX_data_pointer_set(result, &ob->id, &RNA_ParticleSystem, psys);
-                       return 1;
-               }
+               set_pointer_type(path, result, &RNA_ParticleSystem);
+               return 1;
        }
        else if(CTX_data_equals(member, "cloth")) {
-               if(ob) {
-                       ModifierData *md= modifiers_findByType(ob, eModifierType_Cloth);
-                       CTX_data_pointer_set(result, &ob->id, &RNA_ClothModifier, md);
-                       return 1;
-               }
+               set_pointer_type(path, result, &RNA_ClothModifier);
+               return 1;
        }
        else if(CTX_data_equals(member, "soft_body")) {
-               if(ob) {
+               PointerRNA *ptr= get_pointer_type(path, &RNA_Object);
+
+               if(ptr && ptr->data) {
+                       Object *ob= ptr->data;
                        CTX_data_pointer_set(result, &ob->id, &RNA_SoftBodySettings, ob->soft);
                        return 1;
                }
        }
        else if(CTX_data_equals(member, "fluid")) {
-               if(ob) {
+               PointerRNA *ptr= get_pointer_type(path, &RNA_Object);
+
+               if(ptr && ptr->data) {
+                       Object *ob= ptr->data;
                        ModifierData *md= modifiers_findByType(ob, eModifierType_Fluidsim);
                        CTX_data_pointer_set(result, &ob->id, &RNA_FluidSimulationModifier, md);
                        return 1;
@@ -183,3 +484,53 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r
        return 0;
 }
 
+/************************* Drawing the Path ************************/
+
+static void buttons_panel_context(const bContext *C, Panel *pa)
+{
+       SpaceButs *sbuts= (SpaceButs*)CTX_wm_space_data(C);
+       ButsContextPath *path= sbuts->path;
+       uiLayout *row;
+       PointerRNA *ptr;
+       PropertyRNA *nameprop;
+       char namebuf[128], *name;
+       int a, icon;
+
+       if(!path)
+               return;
+
+       row= uiLayoutRow(pa->layout, 0);
+       uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_LEFT);
+
+       for(a=0; a<path->len; a++) {
+               ptr= &path->ptr[a];
+
+               if(ptr->data) {
+                       icon= RNA_struct_ui_icon(ptr->type);
+                       nameprop= RNA_struct_name_property(ptr->type);
+
+                       if(nameprop) {
+                               name= RNA_property_string_get_alloc(ptr, nameprop, namebuf, sizeof(namebuf));
+
+                               uiItemL(row, name, icon);
+
+                               if(name != namebuf)
+                                       MEM_freeN(name);
+                       }
+                       else
+                               uiItemL(row, "", icon);
+               }
+       }
+}
+
+void buttons_context_register(ARegionType *art)
+{
+       PanelType *pt;
+
+       pt= MEM_callocN(sizeof(PanelType), "spacetype buttons panel context");
+       strcpy(pt->idname, "BUTTONS_PT_context");
+       strcpy(pt->label, "Context");
+       pt->draw= buttons_panel_context;
+       BLI_addtail(&art->paneltypes, pt);
+}
+
index ea1fe7db29ed84b3c9b2f66e2838a9aeddfbf085..04c7241c4654fc29f8b00e33433bbefd8e5f49e3 100644 (file)
@@ -52,7 +52,9 @@ struct bContextDataResult;
 void buttons_header_buttons(const struct bContext *C, struct ARegion *ar);
 
 /* buttons_context.c */
+void buttons_context_compute(const struct bContext *C, SpaceButs *sbuts);
 int buttons_context(const struct bContext *C, const char *member, struct bContextDataResult *result);
+void buttons_context_register(struct ARegionType *art);
 
 #endif /* ED_BUTTONS_INTERN_H */
 
index 838316fd4af864433a905be6772f9127e8e23b99..57ca7cc23d82603a3a77153953ba6c82c04e21ef 100644 (file)
@@ -122,9 +122,10 @@ static void buttons_free(SpaceLink *sl)
                if (sbuts->ri->rect) MEM_freeN(sbuts->ri->rect);
                MEM_freeN(sbuts->ri);
        }
-       
-}
 
+       if(sbuts->path)
+               MEM_freeN(sbuts->path);
+}
 
 /* spacetype; init callback */
 static void buttons_init(struct wmWindowManager *wm, ScrArea *sa)
@@ -146,6 +147,7 @@ static SpaceLink *buttons_duplicate(SpaceLink *sl)
        
        /* clear or remove stuff from old */
        sbutsn->ri= NULL;
+       sbutsn->path= NULL;
        
        return (SpaceLink *)sbutsn;
 }
@@ -168,6 +170,8 @@ static void buttons_main_area_draw(const bContext *C, ARegion *ar)
        SpaceButs *sbuts= (SpaceButs*)CTX_wm_space_data(C);
        int vertical= (sbuts->align == BUT_VERTICAL);
 
+       buttons_context_compute(C, sbuts);
+
        if(sbuts->mainb == BCONTEXT_SCENE)
                ED_region_panels(C, ar, vertical, "scene");
        else if(sbuts->mainb == BCONTEXT_WORLD)
@@ -191,7 +195,6 @@ static void buttons_main_area_draw(const bContext *C, ARegion *ar)
 
     sbuts->re_align= 0;
        sbuts->mainbo= sbuts->mainb;
-       sbuts->tabo= sbuts->tab[sbuts->mainb];
 }
 
 void buttons_operatortypes(void)
@@ -282,6 +285,8 @@ void ED_spacetype_buttons(void)
        art->listener= buttons_area_listener;
        art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_FRAMES;
        BLI_addhead(&st->regiontypes, art);
+
+       buttons_context_register(art);
        
        /* regions: header */
        art= MEM_callocN(sizeof(ARegionType), "spacetype buttons region");
index cde0683318f7d2da76325d7617922b570aa05c2e..16748af39d5967ca043a4f9798226bff5bc19fff 100644 (file)
@@ -1750,7 +1750,7 @@ static int tree_element_active_texture(Scene *scene, SpaceOops *soops, TreeEleme
 
                if(set) {
                        if(sbuts) {
-                               sbuts->tabo= TAB_SHADING_TEX;   // hack from header_buttonswin.c
+                               // XXX sbuts->tabo= TAB_SHADING_TEX;    // hack from header_buttonswin.c
                                sbuts->texfrom= 1;
                        }
 // XXX                 extern_set_butspace(F6KEY, 0);  // force shading buttons texture
@@ -1764,7 +1764,7 @@ static int tree_element_active_texture(Scene *scene, SpaceOops *soops, TreeEleme
                Lamp *la= (Lamp *)tselemp->id;
                if(set) {
                        if(sbuts) {
-                               sbuts->tabo= TAB_SHADING_TEX;   // hack from header_buttonswin.c
+                               // XXX sbuts->tabo= TAB_SHADING_TEX;    // hack from header_buttonswin.c
                                sbuts->texfrom= 2;
                        }
 // XXX                 extern_set_butspace(F6KEY, 0);  // force shading buttons texture
index ad07237fdc5ce386075329231bee18921cb5196f..b2c5121c1eda9d46ff7101c23316f0cb37f64473 100644 (file)
@@ -121,7 +121,7 @@ typedef struct SpaceButs {
        struct RenderInfo *ri;
 
        short cursens, curact;
-       short align, tabo;              /* align for panels, tab is old tab */
+       short align, pad;               /* align for panels */
        View2D v2d; /* depricated, copied to region */
        
        short mainb, menunr;    /* texnr and menunr have to remain shorts */
@@ -139,8 +139,8 @@ typedef struct SpaceButs {
        short oldkeypress;              /* for keeping track of the sub tab key cycling */
        char flag, texact;
        
-       char tab[8];    /* storing tabs for each context */
-               
+       void *path;             /* runtime */
+       ID *pinid;
 } SpaceButs;
 
 typedef struct SpaceSeq {
index 1d8a63bf83adfd28f5a731ef951761a271a72fe0..55336b5e8b4e40571a479c35a80ad453b43775b2 100644 (file)
@@ -231,6 +231,7 @@ static void rna_def_mtex(BlenderRNA *brna)
        srna= RNA_def_struct(brna, "TextureSlot", NULL);
        RNA_def_struct_sdna(srna, "MTex");
        RNA_def_struct_ui_text(srna, "Texture Slot", "Texture slot defining the mapping and influence of a texture.");
+       RNA_def_struct_ui_icon(srna, ICON_TEXTURE_DATA);
 
        prop= RNA_def_property(srna, "texture", PROP_POINTER, PROP_NONE);
        RNA_def_property_pointer_sdna(prop, NULL, "tex");