- decided it made more sense to make a key_get_active function, switched
authorDaniel Dunbar <daniel@zuster.org>
Fri, 15 Jul 2005 17:55:19 +0000 (17:55 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Fri, 15 Jul 2005 17:55:19 +0000 (17:55 +0000)
   to that in editmesh as well as for edit{curve,lattice}
 - added a G.editModeTitleExtra string that gets displayed in header info
   string in editmode. currently used to display "(Key)" when editing a
   key (before there was not UI level display of this info).

source/blender/blenkernel/BKE_global.h
source/blender/blenkernel/BKE_key.h
source/blender/blenkernel/BKE_mesh.h
source/blender/blenkernel/intern/key.c
source/blender/blenkernel/intern/mesh.c
source/blender/src/editcurve.c
source/blender/src/editlattice.c
source/blender/src/editmesh.c
source/blender/src/editobject.c
source/blender/src/header_info.c

index f7160eb1a1317b3a9218305720096ad6b7d96d02..24b555e3ccee3deb5fcb0a07ef3079d291b6a7f8 100644 (file)
@@ -80,6 +80,7 @@ typedef struct Global {
     struct Scene *scene;                               /* denk aan file.c */
     struct bScreen *curscreen;
     struct Object *obedit;
+       char editModeTitleExtra[64];
        
     /* fonts, allocated global data */
     struct BMF_Font *font, *fonts, *fontss;
index 22b20e28b894b95e83a728bfafea5be93d43e48a..59984389f2141c6de9191fe3b3b20ce2324cb8a8 100644 (file)
@@ -60,5 +60,7 @@ void do_spec_key(struct Key *key);
 
 void unlock_all_keys(void);
 
+struct KeyBlock *key_get_active(struct Key *keyData);
+
 #endif
 
index 89f691af5350eaa15f328fba10ba71f8c7721492..c20f0fd3e4e4cdaa43efecc757ea93ecec3c3963 100644 (file)
@@ -80,7 +80,6 @@ void mesh_set_smooth_flag(struct Object *meshOb, int enableSmooth);
 
 struct BoundBox *mesh_get_bb(struct Mesh *me);
 void mesh_get_texspace(struct Mesh *me, float *loc_r, float *rot_r, float *size_r);
-struct KeyBlock *mesh_get_active_key(struct Mesh *me);
 
 void make_edges(struct Mesh *me);
 
index d9218d78a27ff0dddb511233405cb7fc90e3f18c..3425a2ff85d621f946b2d105bc6a011daba49982 100644 (file)
@@ -1206,3 +1206,16 @@ void do_spec_key(Key *key)
        else if(idcode==ID_LT) do_latt_key( (Lattice *)key->from);
        
 }
+
+KeyBlock *key_get_active(Key *keyData) 
+{
+       if (keyData) {
+               KeyBlock *key;
+
+               for (key=keyData->block.first; key; key= key->next)
+                       if (key->flag&SELECT)
+                               return key;
+       }
+
+       return NULL;
+}
index f9737f1e11bddf758a7032bd7af7d076dd8599e0..f9f1285a5bef96c3f094d3b22d1c489133718a4a 100644 (file)
@@ -1287,14 +1287,3 @@ void mesh_set_smooth_flag(Object *meshOb, int enableSmooth) {
 
        DAG_object_flush_update(G.scene, meshOb, OB_RECALC_DATA);
 }
-
-KeyBlock *mesh_get_active_key(Mesh *me) 
-{
-       KeyBlock *key;
-
-       for (key=me->key->block.first; key; key= key->next)
-               if (key->flag&SELECT)
-                       break;
-
-       return key;
-}
index b80e8861e9dfc3f7ce44414bee4ce4675510a51c..04aec0c48c7c875c388f66cfb12db089ea7a5f9b 100644 (file)
@@ -69,6 +69,7 @@
 #include "BKE_global.h"
 #include "BKE_object.h"
 #include "BKE_main.h"
+#include "BKE_key.h"
 
 #include "BIF_editmode_undo.h"
 #include "BIF_gl.h"
@@ -238,7 +239,7 @@ void load_editNurb()
        /* load editNurb in object */
        Curve *cu= 0;
        Nurb *nu, *newnu;
-       KeyBlock *actkey=0;
+       KeyBlock *actkey;
 
        if(G.obedit==0) return;
 
@@ -249,24 +250,17 @@ void load_editNurb()
                cu= G.obedit->data;
 
                /* are there keys? */
-               if(cu->key) {
-                       actkey= cu->key->block.first;
-                       while(actkey) {
-                               if(actkey->flag & SELECT) break;
-                               actkey= actkey->next;
-                       }
-
-                       if(actkey) {
-                               /* active key: the vertices */
-                               
-                               if(G.totvert) {
-                                       if(actkey->data) MEM_freeN(actkey->data);
-                               
-                                       actkey->data= MEM_callocN(cu->key->elemsize*G.totvert, "actkey->data");
-                                       actkey->totelem= G.totvert;
+               actkey = key_get_active(cu->key);
+               if(actkey) {
+                       /* active key: the vertices */
                        
-                                       curve_to_key(cu, actkey, &editNurb);
-                               }
+                       if(G.totvert) {
+                               if(actkey->data) MEM_freeN(actkey->data);
+                       
+                               actkey->data= MEM_callocN(cu->key->elemsize*G.totvert, "actkey->data");
+                               actkey->totelem= G.totvert;
+               
+                               curve_to_key(cu, actkey, &editNurb);
                        }
                }
                
@@ -296,7 +290,6 @@ void load_editNurb()
        }
        
        lastnu= NULL;   /* for selected */
-       
 }
 
 void make_editNurb()
@@ -304,7 +297,7 @@ void make_editNurb()
        /* make copy of baseNurb in editNurb */
        Curve *cu=0;
        Nurb *nu, *newnu;
-       KeyBlock *actkey=0;
+       KeyBlock *actkey;
 
        if(G.obedit==NULL) return;
 
@@ -323,16 +316,10 @@ void make_editNurb()
                        nu= nu->next;
                }
                
-               if(cu->key) {
-                       actkey= cu->key->block.first;
-                       while(actkey) {
-                               if(actkey->flag & SELECT) break;
-                               actkey= actkey->next;
-                       }
-               
-                       if(actkey) {
-                               key_to_curve(actkey, cu, &editNurb);
-                       }
+               actkey = key_get_active(cu->key);
+               if(actkey) {
+                       strcpy(G.editModeTitleExtra, "(Key) ");
+                       key_to_curve(actkey, cu, &editNurb);
                }
        }
        else G.obedit= NULL;
index 9566c0cb40a6f4dc3f7153beab4e5e47ace4ea65..10cdda7eeb701d664b47028dfc10c84f53f77aca 100644 (file)
@@ -108,22 +108,15 @@ static void setflagsLatt(int flag)
 void make_editLatt(void)
 {
        Lattice *lt;
-       KeyBlock *actkey=0;
+       KeyBlock *actkey;
        
        free_editLatt();
        
        lt= G.obedit->data;
 
-       /* keys? */
-       if(lt->key) {
-               actkey= lt->key->block.first;
-               while(actkey) {
-                       if(actkey->flag & SELECT) break;
-                       actkey= actkey->next;
-               }
-       }
-
+       actkey = key_get_active(lt->key);
        if(actkey) {
+               strcpy(G.editModeTitleExtra, "(Key) ");
                key_to_latt(actkey, lt);
        }
 
@@ -138,22 +131,14 @@ void make_editLatt(void)
 void load_editLatt(void)
 {
        Lattice *lt;
-       KeyBlock *actkey=0;
+       KeyBlock *actkey;
        BPoint *bp;
        float *fp;
        int tot;
        
        lt= G.obedit->data;
        
-       /* are there keys? */
-       if(lt->key) {
-               actkey= lt->key->block.first;
-               while(actkey) {
-                       if(actkey->flag & SELECT) break;
-                       actkey= actkey->next;
-               }
-       }
-
+       actkey = key_get_active(lt->key);
        if(actkey) {
                /* active key: vertices */
                tot= editLatt->pntsu*editLatt->pntsv*editLatt->pntsw;
@@ -170,7 +155,7 @@ void load_editLatt(void)
                        bp++;
                }
                
-               if(actkey) showkeypos(lt->key, actkey);
+               showkeypos(lt->key, actkey);
        }
        else {
 
index 7efa55af693662e1a99f1596809055e6f3328176..8ec5f75d6c18ca114529115e991ac4ca70ad2674 100644 (file)
@@ -660,9 +660,9 @@ void make_editMesh()
        /* initialize fastmalloc for editmesh */
        init_editmesh_fastmalloc(G.editMesh, me->totvert, me->totedge, me->totface);
 
-       actkey = mesh_get_active_key(me);
-
+       actkey = key_get_active(me->key);
        if(actkey) {
+               strcpy(G.editModeTitleExtra, "(Key) ");
                key_to_mesh(actkey, me);
                tot= actkey->totelem;
        }
@@ -1168,7 +1168,7 @@ void load_editMesh(void)
 
        /* are there keys? */
        if(me->key) {
-               KeyBlock *currkey, *actkey = mesh_get_active_key(me);
+               KeyBlock *currkey, *actkey = key_get_active(me->key);
 
                /* Lets reorder the key data so that things line up roughly
                 * with the way things were before editmode */
index e25350046ba87a0c23c01c7400f23fba63111233..2510af89e0826a444472c3e7b34599cf0771d5eb 100644 (file)
@@ -1366,6 +1366,8 @@ void enter_editmode(void)
        if(base==0) return;
        if((G.vd==NULL || (base->lay & G.vd->lay))==0) return;
        
+       strcpy(G.editModeTitleExtra, "");
+
        ob= base->object;
        if(ob->data==0) return;
        
index d2c41417f88d8af808f2134b7ebb11d573bfa4a3..bfc9c8517ba949dea652fe4aa41e1b80235e459e 100644 (file)
@@ -1775,25 +1775,27 @@ static void info_text(int x, int y)
        int hsize;
 
        if(G.obedit) {
+               char *s = infostr;
+
+               s+= sprintf(s, "%s", G.editModeTitleExtra);
                if(G.obedit->type==OB_MESH) {
                        if(G.scene->selectmode & SCE_SELECT_VERTEX)
-                               sprintf(infostr,"Ve:%d-%d | Ed:%d-%d | Fa:%d-%d | Mem:%.2fM ",
-                                               G.totvertsel, G.totvert, G.totedgesel, G.totedge, G.totfacesel, G.totface, (mem_in_use>>10)/1024.0);
+                               s+= sprintf(s,"Ve:%d-%d | Ed:%d-%d | Fa:%d-%d",
+                                               G.totvertsel, G.totvert, G.totedgesel, G.totedge, G.totfacesel, G.totface);
                        else if(G.scene->selectmode & SCE_SELECT_EDGE)
-                               sprintf(infostr,"Ed:%d-%d | Fa:%d-%d | Mem:%.2fM ",
-                                               G.totedgesel, G.totedge, G.totfacesel, G.totface, (mem_in_use>>10)/1024.0);
+                               s+= sprintf(s,"Ed:%d-%d | Fa:%d-%d",
+                                               G.totedgesel, G.totedge, G.totfacesel, G.totface);
                        else 
-                               sprintf(infostr,"Fa:%d-%d | Mem:%.2fM ",
-                                               G.totfacesel, G.totface, (mem_in_use>>10)/1024.0);
+                               s+= sprintf(s,"Fa:%d-%d", G.totfacesel, G.totface);
                }
                else if(G.obedit->type==OB_ARMATURE) {
-                       sprintf(infostr,"Ve:%d-%d | Bo:%d-%d | Mem:%.2fM ",
-                                       G.totvertsel, G.totvert, G.totbonesel, G.totbone, (mem_in_use>>10)/1024.0);
+                       s+= sprintf(s,"Ve:%d-%d | Bo:%d-%d", G.totvertsel, G.totvert, G.totbonesel, G.totbone);
                }
                else {
-                       sprintf(infostr,"Ve:%d-%d | Mem:%.2fM ",
-                                       G.totvertsel, G.totvert, (mem_in_use>>10)/1024.0);
+                       s+= sprintf(s,"Ve:%d-%d", G.totvertsel, G.totvert);
                }
+
+               sprintf(s," | Mem:%.2fM", (mem_in_use>>10)/1024.0);
        }
        else if(G.obpose) {
                sprintf(infostr,"Bo:%d-%d | Mem:%.2fM ",