From abda07819627e327023b2d4012e75f433eb02ca4 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Mon, 18 Dec 2006 05:15:17 +0000 Subject: [PATCH] == NLA Editor == 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 | 1 + source/blender/src/editnla.c | 73 +++++----------------------- source/blender/src/header_nla.c | 6 ++- 3 files changed, 18 insertions(+), 62 deletions(-) diff --git a/source/blender/include/BIF_editnla.h b/source/blender/include/BIF_editnla.h index 88abf2f83f1..bc6ea8b9752 100644 --- a/source/blender/include/BIF_editnla.h +++ b/source/blender/include/BIF_editnla.h @@ -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 */ diff --git a/source/blender/src/editnla.c b/source/blender/src/editnla.c index a250e472843..368f4711640 100644 --- a/source/blender/src/editnla.c +++ b/source/blender/src/editnla.c @@ -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 ((ob==NULL)||(ob->action==NULL)) { + error("Need active Object to convert Action to NLA Strip"); + return; } - if (base==0 || base->object->action==NULL) - 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: diff --git a/source/blender/src/header_nla.c b/source/blender/src/header_nla.c index 57cb2431f1a..c14fea48dc6 100644 --- a/source/blender/src/header_nla.c +++ b/source/blender/src/header_nla.c @@ -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);