diff options
author | Ton Roosendaal <ton@blender.org> | 2003-06-27 19:26:23 +0400 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2003-06-27 19:26:23 +0400 |
commit | 6a3f419142f441c1238efd9cc1704e9903cd1e9e (patch) | |
tree | ab85b62adef94ae342801a5ca203b9857bd62169 /source/blender/src/editnla.c | |
parent | 6bbf245d1775ad091e1b424677383cc46e28a2c3 (diff) |
- bug #152
databrowse didnt work in NLA editor, for a SHIFT+A "add action"
note: the databrowse is a bit out-focus here. the NLA editor is not yet
well integrated with blender standards. For example, there is no awareness
of an 'active' strip in the editor, which makes a bit clumsy code. It needs
some more work... options in the window header etc.
Diffstat (limited to 'source/blender/src/editnla.c')
-rw-r--r-- | source/blender/src/editnla.c | 95 |
1 files changed, 62 insertions, 33 deletions
diff --git a/source/blender/src/editnla.c b/source/blender/src/editnla.c index fab417ce29e..3f66bd5724d 100644 --- a/source/blender/src/editnla.c +++ b/source/blender/src/editnla.c @@ -75,6 +75,7 @@ #include "BSE_drawipo.h" #include "BSE_trans_types.h" #include "BSE_edit.h" +#include "BSE_filesel.h" #include "BDR_editobject.h" #include "interface.h" @@ -306,19 +307,63 @@ static void convert_nla(short mval[2]) } } +static Base *nla_base=NULL; /* global, bad, bad! put it in nla space later, or recode the 2 functions below (ton) */ + +static void add_nla_block(int val) +{ + /* val is not used, databrowse needs it to optional pass an event */ + bAction *act=NULL; + bActionStrip *strip; + int cur; + short event; + + if(nla_base==NULL) return; + + event= G.snla->menunr; /* set by databrowse or pupmenu */ + + if (event!=-1){ + for (cur = 1, act=G.main->action.first; act; act=act->id.next, cur++){ + if (cur==event){ + break; + } + } + } + + /* Bail out if no action was chosen */ + if (!act){ + return; + } + + /* Initialize the new action block */ + strip = MEM_callocN(sizeof(bActionStrip), "bActionStrip"); + + deselect_nlachannel_keys(0); + + /* Link the action to the strip */ + strip->act = act; + strip->actstart = 1.0; + strip->actend = calc_action_end(act); + strip->start = G.scene->r.cfra; /* Should be mval[0] */ + strip->end = strip->start + (strip->actend-strip->actstart); + strip->flag = ACTSTRIP_SELECT; + strip->repeat = 1.0; + + act->id.us++; + + BLI_addtail(&nla_base->object->nlastrips, strip); + +} + static void add_nlablock(short mval[2]) { /* Make sure we are over an armature */ Base *base; - bAction *act=NULL; - bActionStrip *strip; float ymin, ymax; float x, y; rctf rectf; short event; char *str; short nr; - int cur; areamouseco_to_ipoco(G.v2d, mval, &x, &y); @@ -358,6 +403,9 @@ static void add_nlablock(short mval[2]) } } + /* global... for the call above, because the NLA system seems not to have an 'active strip' stored */ + nla_base= base; + /* Make sure we have an armature */ if (!base){ error ("Not an armature!"); @@ -366,41 +414,22 @@ static void add_nlablock(short mval[2]) /* Popup action menu */ IDnames_to_pupstring(&str, "Add action", NULL, &G.main->action, (ID *)G.scene, &nr); - - event = pupmenu(str); - if (event!=-1){ - for (cur = 1, act=G.main->action.first; act; act=act->id.next, cur++){ - if (cur==event){ - break; - } - } + if(strncmp(str+13, "DataBrow", 8)==0) { + MEM_freeN(str); + + activate_databrowse((ID *)NULL, ID_AC, 0, 0, &G.snla->menunr, add_nla_block ); + + return; } - - MEM_freeN(str); - - /* Bail out if no action was chosen */ - if (!act){ - return; + else { + event = pupmenu(str); + MEM_freeN(str); } - /* Initialize the new action block */ - strip = MEM_callocN(sizeof(bActionStrip), "bActionStrip"); - - deselect_nlachannel_keys(0); - - /* Link the action to the strip */ - strip->act = act; - strip->actstart = 1.0; - strip->actend = calc_action_end(act); - strip->start = G.scene->r.cfra; /* Should be mval[0] */ - strip->end = strip->start + (strip->actend-strip->actstart); - strip->flag = ACTSTRIP_SELECT; - strip->repeat = 1.0; - - act->id.us++; + /* this is a callback for databrowse too */ + add_nla_block(0); - BLI_addtail(&base->object->nlastrips, strip); } static void mouse_nlachannels(short mval[2]) |