Saturday merger of bf-blender in orange branch.
[blender.git] / source / blender / src / outliner.c
index 4316c4837cf927c357795f03dd2f54f4336b8f71..b659362d60a4a03b3c0dfb632dec8c2994cc1320 100644 (file)
@@ -2472,93 +2472,84 @@ static void outliner_back(SpaceOops *soops)
        }
 }
 
-static void namebutton_cb(void *soopsp, void *oldnamep)
+static void namebutton_cb(void *tep, void *oldnamep)
 {
-       SpaceOops *soops= soopsp;
+       SpaceOops *soops= curarea->spacedata.first;
        TreeStore *ts= soops->treestore;
-       TreeStoreElem *tselem;
-       int a;
+       TreeElement *te= tep;
        
-       if(ts) {
-               /* only one namebutton can exist */
-               for(a=0, tselem= ts->data; a<ts->usedelem; a++, tselem++) {
-                       if(tselem->flag & TSE_TEXTBUT) {
-                               if(tselem->type==0) {
-                                       test_idbutton(tselem->id->name+2);      // library.c, unique name and alpha sort
-                               }
-                               else {
-                                       TreeElement *te= outliner_find_tree_element(&soops->tree, a);
+       if(ts && te) {
+               TreeStoreElem *tselem= TREESTORE(te);
+
+               if(tselem->type==0) {
+                       test_idbutton(tselem->id->name+2);      // library.c, unique name and alpha sort
+               }
+               else {
+                       switch(tselem->type) {
+                       case TSE_DEFGROUP:
+                               unique_vertexgroup_name(te->directdata, (Object *)tselem->id); //       id = object
+                               break;
+                       case TSE_NLA_ACTION:
+                               test_idbutton(tselem->id->name+2);
+                               break;
+                       case TSE_EBONE:
+                               if(G.obedit && G.obedit->data==(ID *)tselem->id) {
+                                       EditBone *ebone= te->directdata;
+                                       char newname[32];
                                        
-                                       if(te) {
-                                               switch(tselem->type) {
-                                               case TSE_DEFGROUP:
-                                                       unique_vertexgroup_name(te->directdata, (Object *)tselem->id); //       id = object
-                                                       break;
-                                               case TSE_NLA_ACTION:
-                                                       test_idbutton(tselem->id->name+2);
-                                                       break;
-                                               case TSE_EBONE:
-                                                       if(G.obedit && G.obedit->data==(ID *)tselem->id) {
-                                                               EditBone *ebone= te->directdata;
-                                                               char newname[32];
-                                                               
-                                                               /* restore bone name */
-                                                               BLI_strncpy(newname, ebone->name, 32);
-                                                               BLI_strncpy(ebone->name, oldnamep, 32);
-                                                               armature_bone_rename(G.obedit->data, oldnamep, newname);
-                                                       }
-                                                       allqueue(REDRAWOOPS, 0);
-                                                       allqueue(REDRAWVIEW3D, 1);
-                                                       allqueue(REDRAWBUTSEDIT, 0);
-                                                       break;
+                                       /* restore bone name */
+                                       BLI_strncpy(newname, ebone->name, 32);
+                                       BLI_strncpy(ebone->name, oldnamep, 32);
+                                       armature_bone_rename(G.obedit->data, oldnamep, newname);
+                               }
+                               allqueue(REDRAWOOPS, 0);
+                               allqueue(REDRAWVIEW3D, 1);
+                               allqueue(REDRAWBUTSEDIT, 0);
+                               break;
 
-                                               case TSE_BONE:
-                                                       {
-                                                               Bone *bone= te->directdata;
-                                                               Object *ob;
-                                                               char newname[32];
-                                                               
-                                                               // always make current object active
-                                                               tree_element_active_object(soops, te);
-                                                               ob= OBACT;
-                                                               
-                                                               /* restore bone name */
-                                                               BLI_strncpy(newname, bone->name, 32);
-                                                               BLI_strncpy(bone->name, oldnamep, 32);
-                                                               armature_bone_rename(ob->data, oldnamep, newname);
-                                                       }
-                                                       allqueue(REDRAWOOPS, 0);
-                                                       allqueue(REDRAWVIEW3D, 1);
-                                                       allqueue(REDRAWBUTSEDIT, 0);
-                                                       break;
-                                               case TSE_POSE_CHANNEL:
-                                                       {
-                                                               bPoseChannel *pchan= te->directdata;
-                                                               Object *ob;
-                                                               char newname[32];
-                                                               
-                                                               // always make current object active
-                                                               tree_element_active_object(soops, te);
-                                                               ob= OBACT;
-                                                               
-                                                               /* restore bone name */
-                                                               BLI_strncpy(newname, pchan->name, 32);
-                                                               BLI_strncpy(pchan->name, oldnamep, 32);
-                                                               armature_bone_rename(ob->data, oldnamep, newname);
-                                                       }
-                                                       allqueue(REDRAWOOPS, 0);
-                                                       allqueue(REDRAWVIEW3D, 1);
-                                                       allqueue(REDRAWBUTSEDIT, 0);
-                                                       break;
-                                                       
-                                               }
-                                       }
+                       case TSE_BONE:
+                               {
+                                       Bone *bone= te->directdata;
+                                       Object *ob;
+                                       char newname[32];
+                                       
+                                       // always make current object active
+                                       tree_element_active_object(soops, te);
+                                       ob= OBACT;
+                                       
+                                       /* restore bone name */
+                                       BLI_strncpy(newname, bone->name, 32);
+                                       BLI_strncpy(bone->name, oldnamep, 32);
+                                       armature_bone_rename(ob->data, oldnamep, newname);
+                               }
+                               allqueue(REDRAWOOPS, 0);
+                               allqueue(REDRAWVIEW3D, 1);
+                               allqueue(REDRAWBUTSEDIT, 0);
+                               break;
+                       case TSE_POSE_CHANNEL:
+                               {
+                                       bPoseChannel *pchan= te->directdata;
+                                       Object *ob;
+                                       char newname[32];
+                                       
+                                       // always make current object active
+                                       tree_element_active_object(soops, te);
+                                       ob= OBACT;
+                                       
+                                       /* restore bone name */
+                                       BLI_strncpy(newname, pchan->name, 32);
+                                       BLI_strncpy(pchan->name, oldnamep, 32);
+                                       armature_bone_rename(ob->data, oldnamep, newname);
                                }
-                               tselem->flag &= ~TSE_TEXTBUT;
+                               allqueue(REDRAWOOPS, 0);
+                               allqueue(REDRAWVIEW3D, 1);
+                               allqueue(REDRAWBUTSEDIT, 0);
+                               break;
+                               
                        }
                }
-               scrarea_queue_redraw(curarea);
        }
+       scrarea_queue_redraw(curarea);
 }
 
 static void outliner_buttons(uiBlock *block, SpaceOops *soops, ListBase *lb)
@@ -2580,7 +2571,7 @@ static void outliner_buttons(uiBlock *block, SpaceOops *soops, ListBase *lb)
                        if(dx<50) dx= 50;
                        
                        bt= uiDefBut(block, TEX, OL_NAMEBUTTON, "",  te->xs+2*OL_X-4, te->ys, dx+10, OL_H-1, te->name, 1.0, (float)len-1, 0, 0, "");
-                       uiButSetFunc(bt, namebutton_cb, soops, NULL);
+                       uiButSetFunc(bt, namebutton_cb, te, NULL);
 
                        // signal for button to open
                        addqueue(curarea->win, BUT_ACTIVATE, OL_NAMEBUTTON);