== NLA Editor ==
authorJoshua Leung <aligorith@gmail.com>
Mon, 18 Dec 2006 05:15:17 +0000 (05:15 +0000)
committerJoshua Leung <aligorith@gmail.com>
Mon, 18 Dec 2006 05:15:17 +0000 (05:15 +0000)
Todo Tracker Item: #4754

Now the 'Convert Action to NLA Strip' command (CKEY) is able to
be found in the NLA editor's header in the Strip Menu. It now tries
to add a convert the active action of the active object (so it is no
longer dependant on mouse location).

source/blender/include/BIF_editnla.h
source/blender/src/editnla.c
source/blender/src/header_nla.c

index 88abf2f83f1b2c33ef671cca93a05d78233061b4..bc6ea8b9752b4b55991d94dc5cb2f33b6a0269da 100644 (file)
@@ -54,6 +54,7 @@ void reset_action_strips(int val);
 void synchronize_action_strips(void);
 void snap_action_strips(int snap_mode);
 void add_nlablock(void);
+void convert_nla(void);
 void copy_action_modifiers(void);
 
 /* Baking */
index a250e472843d7e5e6c71e05307b64a8f89efdf86..368f4711640fb252cf6449272d4631fb3e69b4c4 100644 (file)
@@ -99,7 +99,6 @@ static Base *get_nearest_nlachannel_ob_key (float *index, short *sel);
 static bAction *get_nearest_nlachannel_ac_key (float *index, short *sel);
 static Base *get_nearest_nlastrip (bActionStrip **rstrip, short *sel);
 static void mouse_nlachannels(short mval[2]);
-static void convert_nla(short mval[2]);
 
 /* ******************** SPACE: NLA ********************** */
 
@@ -308,75 +307,29 @@ static void set_active_strip(Object *ob, bActionStrip *act)
        }       
 }
 
-static void convert_nla(short mval[2])
+void convert_nla(void)
 {
-       bActionStrip *strip, *nstrip;
-       Base *base;
-       float x,y;
-       float   ymax, ymin;
-       int sel=0;
-       short event;
+       bActionStrip *strip;
+       Object *ob= OBACT;
        char str[128];
+       short event;
        
-       /* Find out what strip we're over */
-       ymax = count_nla_levels() * (NLACHANNELSKIP+NLACHANNELHEIGHT);
-       ymax+= NLACHANNELHEIGHT/2;
-       
-       areamouseco_to_ipoco(G.v2d, mval, &x, &y);
-       
-       for (base=G.scene->base.first; base; base=base->next){
-               if (nla_filter(base)) {
-                       
-                       /* Area that encloses object name (or ipo) */
-                       ymin=ymax-(NLACHANNELHEIGHT+NLACHANNELSKIP);
-                       
-                       /* skip if object collapsed */
-                       if (base->object->nlaflag & OB_NLA_COLLAPSED)
-                               continue;
-                       
-                       ymax=ymin;
-                       
-                       /* Check action ipo */
-                       if (base->object->action) {
-                               ymin=ymax-(NLACHANNELSKIP+NLACHANNELHEIGHT);
-                               if (y>=ymin && y<=ymax)
-                                       break;
-                               ymax=ymin;
-                       }                       
-                               
-                       /* Check nlastrips */
-                       for (strip=base->object->nlastrips.first; strip; strip=strip->next){
-                               ymin=ymax-(NLACHANNELSKIP+NLACHANNELHEIGHT);
-                               if (y>=ymin && y<=ymax){
-                                       sel = 1;
-                                       break;
-                               }
-                               ymax=ymin;
-                       }
-                       if (sel)
-                               break;
-               }
-       }
-       
-       if (base==0 || base->object->action==NULL)
+       if ((ob==NULL)||(ob->action==NULL)) {
+               error("Need active Object to convert Action to NLA Strip");
                return;
+       }
        
-       sprintf(str, "Convert Action%%t|%s to NLA Strip%%x1", base->object->action->id.name+2);
+       sprintf(str, "Convert Action%%t|%s to NLA Strip%%x1", ob->action->id.name+2);
        event = pupmenu(str);
        
-       switch (event){
-       case 1:
-               if (base->object->action) {
+       if (event==1) {
+               if (ob->action) {
                        deselect_nlachannel_keys(0);
-                       nstrip = convert_action_to_strip(base->object); //creates a new NLA strip from the action in given object
-                       set_active_strip(base->object, nstrip);
+                       strip = convert_action_to_strip(ob); //creates a new NLA strip from the action in given object
+                       set_active_strip(ob, strip);
                        BIF_undo_push("Convert NLA");
                        allqueue (REDRAWNLA, 0);
                }
-
-               break;
-       default:
-               break;
        }
 }
 
@@ -1812,7 +1765,7 @@ void winqreadnlaspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                                        if(okee("Copy Modifiers"))
                                                copy_action_modifiers();
                                }
-                               else convert_nla(mval);
+                               else convert_nla();
                                break;
                                
                        case DKEY:
index 57cb2431f1a897fbce29904da7e3c1ac1611ee20..c14fea48dc6f7ef271fe177df7e58a2776fa3e08 100644 (file)
@@ -304,6 +304,7 @@ static void do_nla_stripmenu(void *arg, int event)
                }
                break;
        case 5: /* Convert Action to NLA Strip */
+               convert_nla();
                break;
        case 6: /* Move Up */
                shift_nlastrips_up();
@@ -337,6 +338,8 @@ static uiBlock *nla_stripmenu(void *arg_unused)
        uiDefBut(block, SEPR, 0, "",        0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
        
        uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Add Action Strip|Shift A", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 1, "");
+       uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Convert Action to NLA Strip|C", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 5, "");
+       
        uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Duplicate|Shift D", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 2, "");
        uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Delete|X", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 3, "");
        
@@ -344,8 +347,7 @@ static uiBlock *nla_stripmenu(void *arg_unused)
 
        uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Move Down|Ctrl Page Down", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 7, "");
        uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Move Up|Ctrl Page Up", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 6, "");
-               
-       // uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Convert Action to NLA Strip|C", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 5, "");
+       
 
        if(curarea->headertype==HEADERTOP) {
                uiBlockSetDirection(block, UI_DOWN);