== NLA Editor ==

Strips under an object's strip in the NLA editor can now get collapsed,
like items in the Outliner.

Once an object's strips have been collapsed, it is still possible to add
strips to that object; Other operations will not be possible.
This commit is contained in:
2006-12-10 02:57:17 +00:00
parent 877688129a
commit ab150e8512
3 changed files with 169 additions and 88 deletions

View File

@@ -426,6 +426,7 @@ extern Object workob;
/* ob->nlaflag */ /* ob->nlaflag */
#define OB_NLA_OVERRIDE 1 #define OB_NLA_OVERRIDE 1
#define OB_NLA_COLLAPSED 2
/* ob->protectflag */ /* ob->protectflag */
#define OB_LOCK_LOCX 1 #define OB_LOCK_LOCX 1

View File

@@ -87,6 +87,7 @@
#define TESTBASE_SAFE(base) ((base)->flag & SELECT) #define TESTBASE_SAFE(base) ((base)->flag & SELECT)
/* the left hand side with channels only */ /* the left hand side with channels only */
static void draw_nla_channels(void) static void draw_nla_channels(void)
{ {
@@ -126,32 +127,40 @@ static void draw_nla_channels(void)
BIF_ThemeColor(TH_TEXT_HI); BIF_ThemeColor(TH_TEXT_HI);
else else
BIF_ThemeColor(TH_TEXT); BIF_ThemeColor(TH_TEXT);
glRasterPos2f(x+21, y-4); glRasterPos2f(x+34, y-4);
BMF_DrawString(G.font, ob->id.name+2); BMF_DrawString(G.font, ob->id.name+2);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) ;
/* icon to indicate expanded or collapsed */
if (ob->nlaflag & OB_NLA_COLLAPSED)
BIF_icon_draw(x+1, y-8, ICON_TRIA_RIGHT);
else
BIF_icon_draw(x+1, y-8, ICON_TRIA_DOWN);
/* icon to indicate nla or action */ /* icon to indicate nla or action */
if(ob->nlastrips.first && ob->action) { if(ob->nlastrips.first && ob->action) {
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) ;
if(ob->nlaflag & OB_NLA_OVERRIDE) if(ob->nlaflag & OB_NLA_OVERRIDE)
BIF_icon_draw(x+5, y-8, ICON_NLA); BIF_icon_draw(x+17, y-8, ICON_NLA);
else else
BIF_icon_draw(x+5, y-8, ICON_ACTION); BIF_icon_draw(x+17, y-8, ICON_ACTION);
glDisable(GL_BLEND);
} }
glDisable(GL_BLEND);
y-=NLACHANNELHEIGHT+NLACHANNELSKIP; y-=NLACHANNELHEIGHT+NLACHANNELSKIP;
/* check if object's nla strips are collapsed or not */
if ((ob->nlaflag & OB_NLA_COLLAPSED)==0) {
/* Draw the action timeline */ /* Draw the action timeline */
if (ob->action){ if (ob->action){
BIF_ThemeColorShade(TH_HEADER, -20); BIF_ThemeColorShade(TH_HEADER, -20);
glRectf(x+16, y-NLACHANNELHEIGHT/2, (float)NLAWIDTH, y+NLACHANNELHEIGHT/2); glRectf(x+19, y-NLACHANNELHEIGHT/2, (float)NLAWIDTH, y+NLACHANNELHEIGHT/2);
if (TESTBASE_SAFE(base)) if (TESTBASE_SAFE(base))
BIF_ThemeColor(TH_TEXT_HI); BIF_ThemeColor(TH_TEXT_HI);
else else
BIF_ThemeColor(TH_TEXT); BIF_ThemeColor(TH_TEXT);
glRasterPos2f(x+32, y-4); glRasterPos2f(x+38, y-4);
BMF_DrawString(G.font, ob->action->id.name+2); BMF_DrawString(G.font, ob->action->id.name+2);
/* icon for active action (no strip mapping) */ /* icon for active action (no strip mapping) */
@@ -159,7 +168,7 @@ static void draw_nla_channels(void)
if(strip->flag & ACTSTRIP_ACTIVE) break; if(strip->flag & ACTSTRIP_ACTIVE) break;
if(strip==NULL) { if(strip==NULL) {
glEnable(GL_BLEND); glEnable(GL_BLEND);
BIF_icon_draw(x, y-8, ICON_DOT); BIF_icon_draw(x+5, y-8, ICON_DOT);
glDisable(GL_BLEND); glDisable(GL_BLEND);
} }
@@ -197,6 +206,7 @@ static void draw_nla_channels(void)
} }
} }
} }
}
myortho2(0, NLAWIDTH, 0, ( ofsy+G.v2d->mask.ymax)-( ofsy+G.v2d->mask.ymin)); // Scaling myortho2(0, NLAWIDTH, 0, ( ofsy+G.v2d->mask.ymax)-( ofsy+G.v2d->mask.ymin)); // Scaling
} }
@@ -274,6 +284,10 @@ static void draw_nla_strips_keys(SpaceNla *snla)
y-=NLACHANNELHEIGHT+NLACHANNELSKIP; y-=NLACHANNELHEIGHT+NLACHANNELSKIP;
/* check if object nla-strips expanded or not */
if (ob->nlaflag & OB_NLA_COLLAPSED)
continue;
/* Draw the action strip */ /* Draw the action strip */
if (ob->action) { if (ob->action) {
@@ -430,6 +444,7 @@ bActionStrip *get_active_nlastrip(Object **obpp)
bActionStrip *strip; bActionStrip *strip;
for (base=G.scene->base.first; base; base=base->next){ for (base=G.scene->base.first; base; base=base->next){
if ((base->object->nlaflag & OB_NLA_COLLAPSED)==0) {
for (strip=base->object->nlastrips.first; strip; strip=strip->next){ for (strip=base->object->nlastrips.first; strip; strip=strip->next){
if (strip->flag & ACTSTRIP_SELECT) { if (strip->flag & ACTSTRIP_SELECT) {
*obpp= base->object; *obpp= base->object;
@@ -437,6 +452,7 @@ bActionStrip *get_active_nlastrip(Object **obpp)
} }
} }
} }
}
return NULL; return NULL;
} }
@@ -718,13 +734,15 @@ void drawnlaspace(ScrArea *sa, void *spacedata)
int count_nla_levels(void) int count_nla_levels(void)
{ {
Base *base; Base *base;
int y=0; int y= 0;
for (y=0, base=G.scene->base.first; base; base=base->next) { for (base=G.scene->base.first; base; base=base->next) {
if (nla_filter(base)) { if (nla_filter(base)) {
/* object level */ /* object level */
y++; y++;
/* nla strips for object collapsed? */
if ((base->object->nlaflag & OB_NLA_COLLAPSED)==0) {
if(base->object->action) if(base->object->action)
y++; y++;
@@ -732,6 +750,7 @@ int count_nla_levels(void)
y+= BLI_countlist(&base->object->nlastrips); y+= BLI_countlist(&base->object->nlastrips);
} }
} }
}
return y; return y;
} }

View File

@@ -108,6 +108,9 @@ void shift_nlastrips_up(void) {
bActionStrip *strip, *prevstrip; bActionStrip *strip, *prevstrip;
for (base=G.scene->base.first; base; base=base->next) { for (base=G.scene->base.first; base; base=base->next) {
if (base->object->nlaflag & OB_NLA_COLLAPSED)
continue;
for (strip = base->object->nlastrips.first; for (strip = base->object->nlastrips.first;
strip; strip=strip->next){ strip; strip=strip->next){
if (strip->flag & ACTSTRIP_SELECT) { if (strip->flag & ACTSTRIP_SELECT) {
@@ -145,6 +148,9 @@ void shift_nlastrips_down(void) {
bActionStrip *strip, *nextstrip; bActionStrip *strip, *nextstrip;
for (base=G.scene->base.first; base; base=base->next) { for (base=G.scene->base.first; base; base=base->next) {
if (base->object->nlaflag & OB_NLA_COLLAPSED)
continue;
for (strip = base->object->nlastrips.last; for (strip = base->object->nlastrips.last;
strip; strip=strip->prev){ strip; strip=strip->prev){
if (strip->flag & ACTSTRIP_SELECT) { if (strip->flag & ACTSTRIP_SELECT) {
@@ -209,6 +215,9 @@ void reset_action_strips(int val)
bActionStrip *strip; bActionStrip *strip;
for (base=G.scene->base.first; base; base=base->next) { for (base=G.scene->base.first; base; base=base->next) {
if (base->object->nlaflag & OB_NLA_COLLAPSED)
continue;
for (strip = base->object->nlastrips.last; strip; strip=strip->prev) { for (strip = base->object->nlastrips.last; strip; strip=strip->prev) {
if (strip->flag & ACTSTRIP_SELECT) { if (strip->flag & ACTSTRIP_SELECT) {
if(val==2) { if(val==2) {
@@ -236,6 +245,9 @@ void snap_action_strips(int snap_mode)
bActionStrip *strip; bActionStrip *strip;
for (base=G.scene->base.first; base; base=base->next) { for (base=G.scene->base.first; base; base=base->next) {
if (base->object->nlaflag & OB_NLA_COLLAPSED)
continue;
for (strip = base->object->nlastrips.last; strip; strip=strip->prev) { for (strip = base->object->nlastrips.last; strip; strip=strip->prev) {
if (strip->flag & ACTSTRIP_SELECT) { if (strip->flag & ACTSTRIP_SELECT) {
if (snap_mode==1) { if (snap_mode==1) {
@@ -467,6 +479,7 @@ static void relink_active_strip(void)
char *str; char *str;
if(ob==NULL) return; if(ob==NULL) return;
if(ob->nlaflag & OB_NLA_COLLAPSED) return;
for (strip = ob->nlastrips.first; strip; strip=strip->next) for (strip = ob->nlastrips.first; strip; strip=strip->next)
if(strip->flag & ACTSTRIP_ACTIVE) if(strip->flag & ACTSTRIP_ACTIVE)
@@ -530,6 +543,8 @@ static void mouse_nlachannels(short mval[2])
} }
click--; click--;
/* see if any strips under object */
if ((ob->nlaflag & OB_NLA_COLLAPSED)==0) {
/* See if this is an action */ /* See if this is an action */
if (ob->action){ if (ob->action){
if (click==0) { if (click==0) {
@@ -549,6 +564,7 @@ static void mouse_nlachannels(short mval[2])
} }
} }
} }
}
if (!base) if (!base)
return; return;
@@ -571,9 +587,15 @@ static void mouse_nlachannels(short mval[2])
else if(strip) /* set action */ else if(strip) /* set action */
set_active_strip(ob, strip); set_active_strip(ob, strip);
/* icon toggles beside strip */
if (obclick && mval[0]<20) {
/* collapse option for NLA object strip */
ob->nlaflag ^= OB_NLA_COLLAPSED;
}
else if(obclick && mval[0]<36) {
/* override option for NLA */ /* override option for NLA */
if(obclick && mval[0]<25)
ob->nlaflag ^= OB_NLA_OVERRIDE; ob->nlaflag ^= OB_NLA_OVERRIDE;
}
ob->ctime= -1234567.0f; // eveil! ob->ctime= -1234567.0f; // eveil!
DAG_object_flush_update(G.scene, ob, OB_RECALC_OB|OB_RECALC_DATA); DAG_object_flush_update(G.scene, ob, OB_RECALC_OB|OB_RECALC_DATA);
@@ -596,6 +618,9 @@ void deselect_nlachannel_keys (int test)
/* Determine if this is selection or deselection */ /* Determine if this is selection or deselection */
if (test){ if (test){
for (base=G.scene->base.first; base && sel; base=base->next){ for (base=G.scene->base.first; base && sel; base=base->next){
/* check if collapsed */
if (base->object->nlaflag & OB_NLA_COLLAPSED)
continue;
/* Test object ipos */ /* Test object ipos */
if (is_ipo_key_selected(base->object->ipo)){ if (is_ipo_key_selected(base->object->ipo)){
@@ -652,6 +677,9 @@ void deselect_nlachannel_keys (int test)
/* Set the flags */ /* Set the flags */
for (base=G.scene->base.first; base; base=base->next){ for (base=G.scene->base.first; base; base=base->next){
/* check if collapsed */
if (base->object->nlaflag & OB_NLA_COLLAPSED)
continue;
/* Set the object ipos */ /* Set the object ipos */
set_ipo_key_selection(base->object->ipo, sel); set_ipo_key_selection(base->object->ipo, sel);
@@ -716,6 +744,9 @@ void transform_nlachannel_keys(int mode, int dummy)
/* Ensure that partial selections result in beztriple selections */ /* Ensure that partial selections result in beztriple selections */
for (base=G.scene->base.first; base; base=base->next){ for (base=G.scene->base.first; base; base=base->next){
/* skip if object is collapsed */
if (base->object->nlaflag & OB_NLA_COLLAPSED)
continue;
/* Check object ipos */ /* Check object ipos */
i= fullselect_ipo_keys(base->object->ipo); i= fullselect_ipo_keys(base->object->ipo);
@@ -766,6 +797,10 @@ void transform_nlachannel_keys(int mode, int dummy)
tv = MEM_callocN (sizeof(TransVert) * tvtot, "transVert"); tv = MEM_callocN (sizeof(TransVert) * tvtot, "transVert");
tvtot=0; tvtot=0;
for (base=G.scene->base.first; base; base=base->next){ for (base=G.scene->base.first; base; base=base->next){
/* skip if object collapsed */
if (base->object->nlaflag & OB_NLA_COLLAPSED)
continue;
/* Manipulate object ipos */ /* Manipulate object ipos */
tvtot=add_trans_ipo_keys(base->object->ipo, tv, tvtot); tvtot=add_trans_ipo_keys(base->object->ipo, tv, tvtot);
@@ -973,6 +1008,9 @@ void delete_nlachannel_keys(void)
bActionStrip *strip, *nextstrip; bActionStrip *strip, *nextstrip;
for (base = G.scene->base.first; base; base=base->next){ for (base = G.scene->base.first; base; base=base->next){
/* check if object collapsed */
if (base->object->nlaflag & OB_NLA_COLLAPSED)
continue;
/* Delete object ipos */ /* Delete object ipos */
delete_ipo_keys(base->object->ipo); delete_ipo_keys(base->object->ipo);
@@ -1021,6 +1059,10 @@ void duplicate_nlachannel_keys(void)
/* Find selected items */ /* Find selected items */
for (base = G.scene->base.first; base; base=base->next){ for (base = G.scene->base.first; base; base=base->next){
/* check if object collapsed */
if (base->object->nlaflag & OB_NLA_COLLAPSED)
continue;
/* Duplicate object keys */ /* Duplicate object keys */
duplicate_ipo_keys(base->object->ipo); duplicate_ipo_keys(base->object->ipo);
@@ -1095,6 +1137,10 @@ void borderselect_nla(void)
ymin=ymax-(NLACHANNELHEIGHT+NLACHANNELSKIP); ymin=ymax-(NLACHANNELHEIGHT+NLACHANNELSKIP);
/* check if expanded */
if (base->object->nlaflag & OB_NLA_COLLAPSED)
continue;
/* Check object ipos */ /* Check object ipos */
if (base->object->ipo){ if (base->object->ipo){
if (!((ymax < rectf.ymin) || (ymin > rectf.ymax))) if (!((ymax < rectf.ymin) || (ymin > rectf.ymax)))
@@ -1296,6 +1342,10 @@ static Base *get_nearest_nlastrip (bActionStrip **rstrip, short *sel)
/* Skip object ipos */ /* Skip object ipos */
ymax-=(NLACHANNELHEIGHT+NLACHANNELSKIP); ymax-=(NLACHANNELHEIGHT+NLACHANNELSKIP);
/* check if skip strips if collapsed */
if (base->object->nlaflag & OB_NLA_COLLAPSED)
continue;
/* Skip action ipos */ /* Skip action ipos */
if (base->object->action) if (base->object->action)
ymax-=(NLACHANNELHEIGHT+NLACHANNELSKIP); ymax-=(NLACHANNELHEIGHT+NLACHANNELSKIP);
@@ -1369,6 +1419,10 @@ static Base *get_nearest_nlachannel_ob_key (float *index, short *sel)
ymin=ymax-(NLACHANNELHEIGHT+NLACHANNELSKIP); ymin=ymax-(NLACHANNELHEIGHT+NLACHANNELSKIP);
/* check if skip strips below due to collapsed */
if (base->object->nlaflag & OB_NLA_COLLAPSED)
continue;
/* Handle object ipo selection */ /* Handle object ipo selection */
if (base->object->ipo){ if (base->object->ipo){
if (!((ymax < rectf.ymin) || (ymin > rectf.ymax))){ if (!((ymax < rectf.ymin) || (ymin > rectf.ymax))){
@@ -1478,6 +1532,11 @@ static bAction *get_nearest_nlachannel_ac_key (float *index, short *sel)
/* Skip object ipo and ob-constraint ipo */ /* Skip object ipo and ob-constraint ipo */
ymin=ymax-(NLACHANNELHEIGHT+NLACHANNELSKIP); ymin=ymax-(NLACHANNELHEIGHT+NLACHANNELSKIP);
/* skip this object if it is collapsed */
if (base->object->nlaflag & OB_NLA_COLLAPSED)
continue;
ymax=ymin; ymax=ymin;
/* Handle action ipos */ /* Handle action ipos */
@@ -1598,6 +1657,7 @@ static Object *get_object_from_active_strip(void) {
bActionStrip *strip; bActionStrip *strip;
for (base=G.scene->base.first; base; base=base->next) { for (base=G.scene->base.first; base; base=base->next) {
if ((base->object->nlaflag & OB_NLA_COLLAPSED)==0) {
for (strip = base->object->nlastrips.first; for (strip = base->object->nlastrips.first;
strip; strip=strip->next){ strip; strip=strip->next){
if (strip->flag & ACTSTRIP_SELECT) { if (strip->flag & ACTSTRIP_SELECT) {
@@ -1605,6 +1665,7 @@ static Object *get_object_from_active_strip(void) {
} }
} }
} }
}
return NULL; return NULL;
} }