diff options
author | Xiao Xiangquan <xiaoxiangquan@gmail.com> | 2011-09-01 19:08:32 +0400 |
---|---|---|
committer | Xiao Xiangquan <xiaoxiangquan@gmail.com> | 2011-09-01 19:08:32 +0400 |
commit | 981f7fcd0d315abb425bf34dd37f7cd4d9e8d55e (patch) | |
tree | 70800c93ec1a12579c32874e2a72eaf3290eba8e /source/blender/editors/space_nla | |
parent | 5b91a783cf0ec132398a2767d3419d675e5126b5 (diff) | |
parent | 2365c64014b3e067bb212b2061f1d14c1f944090 (diff) |
merge with trunk r39834
Diffstat (limited to 'source/blender/editors/space_nla')
-rw-r--r-- | source/blender/editors/space_nla/nla_buttons.c | 86 | ||||
-rw-r--r-- | source/blender/editors/space_nla/nla_channels.c | 18 | ||||
-rw-r--r-- | source/blender/editors/space_nla/nla_draw.c | 287 | ||||
-rw-r--r-- | source/blender/editors/space_nla/nla_edit.c | 289 | ||||
-rw-r--r-- | source/blender/editors/space_nla/nla_intern.h | 6 | ||||
-rw-r--r-- | source/blender/editors/space_nla/nla_ops.c | 17 | ||||
-rw-r--r-- | source/blender/editors/space_nla/nla_select.c | 19 | ||||
-rw-r--r-- | source/blender/editors/space_nla/space_nla.c | 2 |
8 files changed, 548 insertions, 176 deletions
diff --git a/source/blender/editors/space_nla/nla_buttons.c b/source/blender/editors/space_nla/nla_buttons.c index 4a311d9113f..afb5027c81e 100644 --- a/source/blender/editors/space_nla/nla_buttons.c +++ b/source/blender/editors/space_nla/nla_buttons.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or @@ -105,7 +103,8 @@ static int nla_panel_context(const bContext *C, PointerRNA *adt_ptr, PointerRNA /* extract list of active channel(s), of which we should only take the first one * - we need the channels flag to get the active AnimData block when there are no NLA Tracks */ - filter= (ANIMFILTER_VISIBLE|ANIMFILTER_ACTIVE|ANIMFILTER_CHANNELS); + // XXX: double-check active! + filter= (ANIMFILTER_DATA_VISIBLE|ANIMFILTER_LIST_VISIBLE|ANIMFILTER_ACTIVE|ANIMFILTER_LIST_CHANNELS); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); for (ale= anim_data.first; ale; ale= ale->next) { @@ -147,6 +146,7 @@ static int nla_panel_context(const bContext *C, PointerRNA *adt_ptr, PointerRNA case ANIMTYPE_DSPART: case ANIMTYPE_DSMBALL: case ANIMTYPE_DSARM: + case ANIMTYPE_DSSPK: { /* for these channels, we only do AnimData */ if (ale->id && ale->adt) { @@ -213,6 +213,24 @@ static int nla_strip_actclip_panel_poll(const bContext *C, PanelType *UNUSED(pt) return (strip->type == NLASTRIP_TYPE_CLIP); } +static int nla_strip_eval_panel_poll(const bContext *C, PanelType *UNUSED(pt)) +{ + PointerRNA ptr; + NlaStrip *strip; + + if (!nla_panel_context(C, NULL, NULL, &ptr)) + return 0; + if (ptr.data == NULL) + return 0; + + strip= ptr.data; + + if (strip->type == NLASTRIP_TYPE_SOUND) + return 0; + + return 1; +} + /* -------------- */ /* active AnimData */ @@ -278,6 +296,7 @@ static void nla_panel_properties(const bContext *C, Panel *pa) uiLayout *layout= pa->layout; uiLayout *column, *row, *subcol; uiBlock *block; + short showEvalProps = 1; if (!nla_panel_context(C, NULL, NULL, &strip_ptr)) return; @@ -297,32 +316,41 @@ static void nla_panel_properties(const bContext *C, Panel *pa) uiItemR(column, &strip_ptr, "frame_start", 0, NULL, ICON_NONE); uiItemR(column, &strip_ptr, "frame_end", 0, NULL, ICON_NONE); - /* extrapolation */ - row= uiLayoutRow(layout, 1); - uiItemR(row, &strip_ptr, "extrapolation", 0, NULL, ICON_NONE); + /* Evaluation-Related Strip Properties ------------------ */ - /* blending */ - row= uiLayoutRow(layout, 1); - uiItemR(row, &strip_ptr, "blend_type", 0, NULL, ICON_NONE); - - /* blend in/out + autoblending - * - blend in/out can only be set when autoblending is off - */ - column= uiLayoutColumn(layout, 1); - uiLayoutSetActive(column, RNA_boolean_get(&strip_ptr, "use_animated_influence")==0); - uiItemR(column, &strip_ptr, "use_auto_blend", 0, NULL, ICON_NONE); // XXX as toggle? - - subcol= uiLayoutColumn(column, 1); - uiLayoutSetActive(subcol, RNA_boolean_get(&strip_ptr, "use_auto_blend")==0); - uiItemR(subcol, &strip_ptr, "blend_in", 0, NULL, ICON_NONE); - uiItemR(subcol, &strip_ptr, "blend_out", 0, NULL, ICON_NONE); + /* sound properties strips don't have these settings */ + if (RNA_enum_get(&strip_ptr, "type") == NLASTRIP_TYPE_SOUND) + showEvalProps = 0; + + /* only show if allowed to... */ + if (showEvalProps) { + /* extrapolation */ + row= uiLayoutRow(layout, 1); + uiItemR(row, &strip_ptr, "extrapolation", 0, NULL, ICON_NONE); - /* settings */ - column= uiLayoutColumn(layout, 1); - uiLayoutSetActive(column, !(RNA_boolean_get(&strip_ptr, "use_animated_influence") || RNA_boolean_get(&strip_ptr, "use_animated_time"))); - uiItemL(column, "Playback Settings:", ICON_NONE); - uiItemR(column, &strip_ptr, "mute", 0, NULL, ICON_NONE); - uiItemR(column, &strip_ptr, "use_reverse", 0, NULL, ICON_NONE); + /* blending */ + row= uiLayoutRow(layout, 1); + uiItemR(row, &strip_ptr, "blend_type", 0, NULL, ICON_NONE); + + /* blend in/out + autoblending + * - blend in/out can only be set when autoblending is off + */ + column= uiLayoutColumn(layout, 1); + uiLayoutSetActive(column, RNA_boolean_get(&strip_ptr, "use_animated_influence")==0); + uiItemR(column, &strip_ptr, "use_auto_blend", 0, NULL, ICON_NONE); // XXX as toggle? + + subcol= uiLayoutColumn(column, 1); + uiLayoutSetActive(subcol, RNA_boolean_get(&strip_ptr, "use_auto_blend")==0); + uiItemR(subcol, &strip_ptr, "blend_in", 0, NULL, ICON_NONE); + uiItemR(subcol, &strip_ptr, "blend_out", 0, NULL, ICON_NONE); + + /* settings */ + column= uiLayoutColumn(layout, 1); + uiLayoutSetActive(column, !(RNA_boolean_get(&strip_ptr, "use_animated_influence") || RNA_boolean_get(&strip_ptr, "use_animated_time"))); + uiItemL(column, "Playback Settings:", ICON_NONE); + uiItemR(column, &strip_ptr, "mute", 0, NULL, ICON_NONE); + uiItemR(column, &strip_ptr, "use_reverse", 0, NULL, ICON_NONE); + } } @@ -476,14 +504,14 @@ void nla_buttons_register(ARegionType *art) strcpy(pt->idname, "NLA_PT_evaluation"); strcpy(pt->label, "Evaluation"); pt->draw= nla_panel_evaluation; - pt->poll= nla_strip_panel_poll; + pt->poll= nla_strip_eval_panel_poll; BLI_addtail(&art->paneltypes, pt); pt= MEM_callocN(sizeof(PanelType), "spacetype nla panel modifiers"); strcpy(pt->idname, "NLA_PT_modifiers"); strcpy(pt->label, "Modifiers"); pt->draw= nla_panel_modifiers; - pt->poll= nla_strip_panel_poll; + pt->poll= nla_strip_eval_panel_poll; BLI_addtail(&art->paneltypes, pt); } diff --git a/source/blender/editors/space_nla/nla_channels.c b/source/blender/editors/space_nla/nla_channels.c index f6aebd57149..b10af5b573d 100644 --- a/source/blender/editors/space_nla/nla_channels.c +++ b/source/blender/editors/space_nla/nla_channels.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or @@ -83,13 +81,14 @@ static int mouse_nla_channels (bAnimContext *ac, float x, int channel_index, sho ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; + View2D *v2d= &ac->ar->v2d; int notifierFlags = 0; /* get the channel that was clicked on */ /* filter channels */ - filter= (ANIMFILTER_VISIBLE | ANIMFILTER_CHANNELS); - filter= ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); + filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); + ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* get channel from index */ ale= BLI_findlink(&anim_data, channel_index); @@ -181,6 +180,7 @@ static int mouse_nla_channels (bAnimContext *ac, float x, int channel_index, sho case ANIMTYPE_DSMESH: case ANIMTYPE_DSTEX: case ANIMTYPE_DSLAT: + case ANIMTYPE_DSSPK: { /* sanity checking... */ if (ale->adt) { @@ -303,6 +303,7 @@ static int mouse_nla_channels (bAnimContext *ac, float x, int channel_index, sho static int nlachannels_mouseclick_invoke(bContext *C, wmOperator *op, wmEvent *event) { bAnimContext ac; + SpaceNla *snla; ARegion *ar; View2D *v2d; int channel_index; @@ -315,6 +316,7 @@ static int nlachannels_mouseclick_invoke(bContext *C, wmOperator *op, wmEvent *e return OPERATOR_CANCELLED; /* get useful pointers from animation context data */ + snla= (SpaceNla *)ac.sl; ar= ac.ar; v2d= &ar->v2d; @@ -330,7 +332,7 @@ static int nlachannels_mouseclick_invoke(bContext *C, wmOperator *op, wmEvent *e * NLACHANNEL_HEIGHT_HALF. */ UI_view2d_region_to_view(v2d, event->mval[0], event->mval[1], &x, &y); - UI_view2d_listview_view_to_cell(v2d, NLACHANNEL_NAMEWIDTH, NLACHANNEL_STEP, 0, (float)NLACHANNEL_HEIGHT_HALF, x, y, NULL, &channel_index); + UI_view2d_listview_view_to_cell(v2d, NLACHANNEL_NAMEWIDTH, NLACHANNEL_STEP(snla), 0, (float)NLACHANNEL_HEIGHT_HALF(snla), x, y, NULL, &channel_index); /* handle mouse-click in the relevant channel then */ notifierFlags= mouse_nla_channels(&ac, x, channel_index, selectmode); @@ -381,12 +383,12 @@ static int nlaedit_add_tracks_exec (bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* get a list of the AnimData blocks being shown in the NLA */ - filter= (ANIMFILTER_VISIBLE | ANIMFILTER_NLATRACKS | ANIMFILTER_SEL); + filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* add tracks... */ for (ale= anim_data.first; ale; ale= ale->next) { - if(ale->type == ANIMTYPE_NLATRACK) { + if (ale->type == ANIMTYPE_NLATRACK) { NlaTrack *nlt= (NlaTrack *)ale->data; AnimData *adt= ale->adt; @@ -449,7 +451,7 @@ static int nlaedit_delete_tracks_exec (bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; /* get a list of the AnimData blocks being shown in the NLA */ - filter= (ANIMFILTER_VISIBLE | ANIMFILTER_NLATRACKS | ANIMFILTER_SEL); + filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* delete tracks */ diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c index e830a421a59..0c9c7877ddc 100644 --- a/source/blender/editors/space_nla/nla_draw.c +++ b/source/blender/editors/space_nla/nla_draw.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or @@ -38,6 +36,7 @@ #include <float.h> #include "DNA_anim_types.h" +#include "DNA_node_types.h" #include "DNA_screen_types.h" #include "DNA_space_types.h" #include "DNA_windowmanager_types.h" @@ -80,7 +79,6 @@ */ static void nla_action_get_color (AnimData *adt, bAction *act, float color[4]) { - // TODO: if tweaking some action, use the same color as for the tweaked track (quick hack done for now) if (adt && (adt->flag & ADT_NLA_EDIT_ON)) { // greenish color (same as tweaking strip) - hardcoded for now color[0]= 0.30f; @@ -104,6 +102,10 @@ static void nla_action_get_color (AnimData *adt, bAction *act, float color[4]) color[3]= 0.3f; } } + + /* when an NLA track is tagged "solo", action doesn't contribute, so shouldn't be as prominent */ + if (adt && (adt->flag & ADT_NLA_SOLO_TRACK)) + color[3] *= 0.15f; } /* draw the keyframes in the specified Action */ @@ -124,9 +126,12 @@ static void nla_action_draw_keyframes (AnimData *adt, bAction *act, View2D *v2d, /* draw a darkened region behind the strips * - get and reset the background color, this time without the alpha to stand out better + * (amplified alpha is used instead) */ nla_action_get_color(adt, act, color); - glColor3fv(color); + color[3] *= 2.5f; + + glColor4fv(color); /* - draw a rect from the first to the last frame (no extra overlaps for now) * that is slightly stumpier than the track background (hardcoded 2-units here) */ @@ -191,7 +196,24 @@ static void nla_strip_get_color_inside (AnimData *adt, NlaStrip *strip, float co color[1]= 0.15f; color[2]= 0.26f; } - } + } + else if (strip->type == NLASTRIP_TYPE_SOUND) { + /* Sound Clip */ + if (strip->flag & NLASTRIP_FLAG_SELECT) { + /* selected - use a bright teal color */ + // FIXME: hardcoded temp-hack colors + color[0]= 0.12f; + color[1]= 0.48f; + color[2]= 0.48f; + } + else { + /* normal, unselected strip - use (hardly noticable) teal tinge */ + // FIXME: hardcoded temp-hack colors + color[0]= 0.17f; + color[1]= 0.24f; + color[2]= 0.24f; + } + } else { /* Action Clip (default/normal type of strip) */ if ((strip->flag & NLASTRIP_FLAG_ACTIVE) && (adt && (adt->flag & ADT_NLA_EDIT_ON))) { @@ -285,15 +307,18 @@ static void nla_draw_strip_curves (NlaStrip *strip, float yminc, float ymaxc) } /* main call for drawing a single NLA-strip */ -static void nla_draw_strip (SpaceNla *snla, AnimData *adt, NlaTrack *UNUSED(nlt), NlaStrip *strip, View2D *v2d, float yminc, float ymaxc) +static void nla_draw_strip (SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStrip *strip, View2D *v2d, float yminc, float ymaxc) { + short nonSolo = ((adt && (adt->flag & ADT_NLA_SOLO_TRACK)) && (nlt->flag & NLATRACK_SOLO)==0); float color[3]; /* get color of strip */ nla_strip_get_color_inside(adt, strip, color); - /* draw extrapolation info first (as backdrop) */ - if (strip->extendmode != NLASTRIP_EXTEND_NOTHING) { + /* draw extrapolation info first (as backdrop) + * - but this should only be drawn if track has some contribution + */ + if ((strip->extendmode != NLASTRIP_EXTEND_NOTHING) && (nonSolo == 0)) { /* enable transparency... */ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); @@ -346,10 +371,23 @@ static void nla_draw_strip (SpaceNla *snla, AnimData *adt, NlaTrack *UNUSED(nlt) glDisable(GL_BLEND); } + /* draw 'inside' of strip itself */ - glColor3fv(color); - uiSetRoundBox(15); /* all corners rounded */ - uiDrawBoxShade(GL_POLYGON, strip->start, yminc, strip->end, ymaxc, 0.0, 0.5, 0.1); + if (nonSolo == 0) { + /* strip is in normal track */ + glColor3fv(color); + uiSetRoundBox(15); /* all corners rounded */ + + uiDrawBoxShade(GL_POLYGON, strip->start, yminc, strip->end, ymaxc, 0.0, 0.5, 0.1); + } + else { + /* strip is in disabled track - make less visible */ + glColor4f(color[0], color[1], color[2], 0.1f); + + glEnable(GL_BLEND); + glRectf(strip->start, yminc, strip->end, ymaxc); + glDisable(GL_BLEND); + } /* draw strip's control 'curves' @@ -358,6 +396,7 @@ static void nla_draw_strip (SpaceNla *snla, AnimData *adt, NlaTrack *UNUSED(nlt) if ((snla->flag & SNLA_NOSTRIPCURVES) == 0) nla_draw_strip_curves(strip, yminc, ymaxc); + /* draw strip outline * - color used here is to indicate active vs non-active */ @@ -419,23 +458,21 @@ static void nla_draw_strip (SpaceNla *snla, AnimData *adt, NlaTrack *UNUSED(nlt) } /* add the relevant text to the cache of text-strings to draw in pixelspace */ -static void nla_draw_strip_text (NlaTrack *UNUSED(nlt), NlaStrip *strip, int UNUSED(index), View2D *v2d, float yminc, float ymaxc) +static void nla_draw_strip_text (AnimData *adt, NlaTrack *nlt, NlaStrip *strip, int index, View2D *v2d, float yminc, float ymaxc) { - char str[256], dir[3]; + short notSolo = ((adt && (adt->flag & ADT_NLA_SOLO_TRACK)) && (nlt->flag & NLATRACK_SOLO)==0); + char str[256]; char col[4]; + float xofs; rctf rect; - /* 'dir' - direction that strip is played in */ - if (strip->flag & NLASTRIP_FLAG_REVERSE) - sprintf(dir, "<-"); - else - sprintf(dir, "->"); - /* just print the name and the range */ - if (strip->flag & NLASTRIP_FLAG_TEMP_META) - sprintf(str, "Temp-Meta | %.2f %s %.2f", strip->start, dir, strip->end); - else - sprintf(str, "%s | %.2f %s %.2f", strip->name, strip->start, dir, strip->end); + if (strip->flag & NLASTRIP_FLAG_TEMP_META) { + BLI_snprintf(str, sizeof(str), "%d) Temp-Meta", index); + } + else { + BLI_strncpy(str, strip->name, sizeof(str)); + } /* set text color - if colors (see above) are light, draw black text, otherwise draw white */ if (strip->flag & (NLASTRIP_FLAG_ACTIVE|NLASTRIP_FLAG_SELECT|NLASTRIP_FLAG_TWEAKUSER)) { @@ -444,22 +481,57 @@ static void nla_draw_strip_text (NlaTrack *UNUSED(nlt), NlaStrip *strip, int UNU else { col[0]= col[1]= col[2]= 255; } - col[3]= 1.0; - + + /* text opacity depends on whether if there's a solo'd track, this isn't it */ + if (notSolo == 0) + col[3]= 255; + else + col[3]= 128; + + /* determine the amount of padding required - cannot be constant otherwise looks weird in some cases */ + if ((strip->end - strip->start) <= 5.0f) + xofs = 0.5f; + else + xofs = 1.0f; + /* set bounding-box for text * - padding of 2 'units' on either side */ // TODO: make this centered? - rect.xmin= strip->start + 0.5f; + rect.xmin= strip->start + xofs; rect.ymin= yminc; - rect.xmax= strip->end - 0.5f; + rect.xmax= strip->end - xofs; rect.ymax= ymaxc; - /* add this string to the cache of texts to draw*/ - + /* add this string to the cache of texts to draw */ UI_view2d_text_cache_rectf(v2d, &rect, str, col); } +/* add frame extents to cache of text-strings to draw in pixelspace + * for now, only used when transforming strips + */ +static void nla_draw_strip_frames_text(NlaTrack *UNUSED(nlt), NlaStrip *strip, View2D *v2d, float UNUSED(yminc), float ymaxc) +{ + const float ytol = 1.0f; /* small offset to vertical positioning of text, for legibility */ + const char col[4] = {220, 220, 220, 255}; /* light grey */ + char str[32] = ""; + + + /* Always draw times above the strip, whereas sequencer drew below + above. + * However, we should be fine having everything on top, since these tend to be + * quite spaced out. + * - 1 dp is compromise between lack of precision (ints only, as per sequencer) + * while also preserving some accuracy, since we do use floats + */ + /* start frame */ + BLI_snprintf(str, sizeof(str), "%.1f", strip->start); + UI_view2d_text_cache_add(v2d, strip->start-1.0f, ymaxc+ytol, str, col); + + /* end frame */ + BLI_snprintf(str, sizeof(str), "%.1f", strip->end); + UI_view2d_text_cache_add(v2d, strip->end, ymaxc+ytol, str, col); +} + /* ---------------------- */ void draw_nla_main_data (bAnimContext *ac, SpaceNla *snla, ARegion *ar) @@ -470,10 +542,11 @@ void draw_nla_main_data (bAnimContext *ac, SpaceNla *snla, ARegion *ar) View2D *v2d= &ar->v2d; float y= 0.0f; - int items, height; + size_t items; + int height; /* build list of channels to draw */ - filter= (ANIMFILTER_VISIBLE|ANIMFILTER_CHANNELS); + filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); items= ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* Update max-extent of channels here (taking into account scrollers): @@ -482,18 +555,18 @@ void draw_nla_main_data (bAnimContext *ac, SpaceNla *snla, ARegion *ar) * - offset of NLACHANNEL_HEIGHT*2 is added to the height of the channels, as first is for * start of list offset, and the second is as a correction for the scrollers. */ - height= ((items*NLACHANNEL_STEP) + (NLACHANNEL_HEIGHT*2)); + height= ((items*NLACHANNEL_STEP(snla)) + (NLACHANNEL_HEIGHT(snla)*2)); /* don't use totrect set, as the width stays the same * (NOTE: this is ok here, the configuration is pretty straightforward) */ v2d->tot.ymin= (float)(-height); /* loop through channels, and set up drawing depending on their type */ - y= (float)(-NLACHANNEL_HEIGHT); + y= (float)(-NLACHANNEL_HEIGHT(snla)); for (ale= anim_data.first; ale; ale= ale->next) { - const float yminc= (float)(y - NLACHANNEL_HEIGHT_HALF); - const float ymaxc= (float)(y + NLACHANNEL_HEIGHT_HALF); + const float yminc= (float)(y - NLACHANNEL_HEIGHT_HALF(snla)); + const float ymaxc= (float)(y + NLACHANNEL_HEIGHT_HALF(snla)); /* check if visible */ if ( IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || @@ -515,7 +588,13 @@ void draw_nla_main_data (bAnimContext *ac, SpaceNla *snla, ARegion *ar) nla_draw_strip(snla, adt, nlt, strip, v2d, yminc, ymaxc); /* add the text for this strip to the cache */ - nla_draw_strip_text(nlt, strip, index, v2d, yminc, ymaxc); + nla_draw_strip_text(adt, nlt, strip, index, v2d, yminc, ymaxc); + + /* if transforming strips (only real reason for temp-metas currently), + * add to the cache the frame numbers of the strip's extents + */ + if (strip->flag & NLASTRIP_FLAG_TEMP_META) + nla_draw_strip_frames_text(nlt, strip, v2d, yminc, ymaxc); } } } @@ -564,7 +643,7 @@ void draw_nla_main_data (bAnimContext *ac, SpaceNla *snla, ARegion *ar) } /* adjust y-position for next one */ - y -= NLACHANNEL_STEP; + y -= NLACHANNEL_STEP(snla); } /* free tempolary channels */ @@ -578,20 +657,23 @@ void draw_nla_main_data (bAnimContext *ac, SpaceNla *snla, ARegion *ar) // TODO: depreceate this code... static void draw_nla_channel_list_gl (bAnimContext *ac, ListBase *anim_data, View2D *v2d, float y) { + SpaceNla *snla = (SpaceNla *)ac->sl; bAnimListElem *ale; float x = 0.0f; /* loop through channels, and set up drawing depending on their type */ for (ale= anim_data->first; ale; ale= ale->next) { - const float yminc= (float)(y - NLACHANNEL_HEIGHT_HALF); - const float ymaxc= (float)(y + NLACHANNEL_HEIGHT_HALF); + const float yminc= (float)(y - NLACHANNEL_HEIGHT_HALF(snla)); + const float ymaxc= (float)(y + NLACHANNEL_HEIGHT_HALF(snla)); const float ydatac= (float)(y - 7); /* check if visible */ if ( IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) { - short indent= 0, offset= 0, sel= 0, group= 0; + AnimData *adt = ale->adt; + + short indent= 0, offset= 0, sel= 0, group= 0, nonSolo= 0; int expand= -1, protect = -1, special= -1, mute = -1; char name[128]; short doDraw=0; @@ -602,27 +684,11 @@ static void draw_nla_channel_list_gl (bAnimContext *ac, ListBase *anim_data, Vie { NlaTrack *nlt= (NlaTrack *)ale->data; - indent= 0; - - if (ale->id) { - /* special exception for materials and particles */ - if (ELEM(GS(ale->id->name),ID_MA,ID_PA)) { - offset= 21; - indent= 1; - } - else - offset= 14; - } - else - offset= 0; - - /* FIXME: 'solo' as the 'special' button? - * - need special icons for these - */ + /* 'solo' as the 'special' button? */ if (nlt->flag & NLATRACK_SOLO) - special= ICON_LAYER_ACTIVE; + special= ICON_SOLO_ON; else - special= ICON_LAYER_USED; + special= ICON_SOLO_OFF; /* if this track is active and we're tweaking it, don't draw these toggles */ // TODO: need a special macro for this... @@ -638,6 +704,15 @@ static void draw_nla_channel_list_gl (bAnimContext *ac, ListBase *anim_data, Vie else protect = ICON_LOCKED; } + + /* is track enabled for solo drawing? */ + if ((adt) && (adt->flag & ADT_NLA_SOLO_TRACK)) { + if ((nlt->flag & NLATRACK_SOLO) == 0) { + /* tag for special non-solo handling; also hide the mute toggles */ + nonSolo= 1; + mute = 0; + } + } sel = SEL_NLT(nlt); strcpy(name, nlt->name); @@ -652,24 +727,12 @@ static void draw_nla_channel_list_gl (bAnimContext *ac, ListBase *anim_data, Vie group = 5; - if (ale->id) { - /* special exception for materials and particles */ - if (ELEM(GS(ale->id->name),ID_MA,ID_PA)) { - offset= 21; - indent= 1; - } - else - offset= 14; - } - else - offset= 0; - special = ICON_ACTION; if (act) - sprintf(name, "ActAction: <%s>", act->id.name+2); + BLI_snprintf(name, sizeof(name), "%s", act->id.name+2); else - sprintf(name, "<No Action>"); + BLI_strncpy(name, "<No Action>", sizeof(name)); // draw manually still doDraw= 1; @@ -684,6 +747,45 @@ static void draw_nla_channel_list_gl (bAnimContext *ac, ListBase *anim_data, Vie /* if special types, draw manually for now... */ if (doDraw) { + if (ale->id) { + /* special exception for textures */ + if (GS(ale->id->name) == ID_TE) { + offset= 14; + indent= 1; + } + /* special exception for nodetrees */ + else if (GS(ale->id->name) == ID_NT) { + bNodeTree *ntree = (bNodeTree *)ale->id; + + switch (ntree->type) { + case NTREE_SHADER: + { + /* same as for textures */ + offset= 14; + indent= 1; + } + break; + + case NTREE_TEXTURE: + { + /* even more */ + offset= 21; + indent= 1; + } + break; + + default: + /* normal will do */ + offset= 14; + break; + } + } + else + offset= 14; + } + else + offset= 0; + /* now, start drawing based on this information */ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); @@ -691,18 +793,19 @@ static void draw_nla_channel_list_gl (bAnimContext *ac, ListBase *anim_data, Vie /* draw backing strip behind channel name */ if (group == 5) { /* Action Line */ - AnimData *adt= ale->adt; - // TODO: if tweaking some action, use the same color as for the tweaked track (quick hack done for now) if (adt && (adt->flag & ADT_NLA_EDIT_ON)) { // greenish color (same as tweaking strip) - hardcoded for now glColor3f(0.3f, 0.95f, 0.1f); } else { + /* if a track is being solo'd, action is ignored, so draw less boldly (alpha lower) */ + float alpha = (adt && (adt->flag & ADT_NLA_SOLO_TRACK))? 0.3f : 1.0f; + if (ale->data) - glColor3f(0.8f, 0.2f, 0.0f); // reddish color - hardcoded for now + glColor4f(0.8f, 0.2f, 0.0f, alpha); // reddish color - hardcoded for now else - glColor3f(0.6f, 0.5f, 0.5f); // greyish-red color - hardcoded for now + glColor4f(0.6f, 0.5f, 0.5f, alpha); // greyish-red color - hardcoded for now } offset += 7 * indent; @@ -719,10 +822,8 @@ static void draw_nla_channel_list_gl (bAnimContext *ac, ListBase *anim_data, Vie group = 0; } else { - /* for normal channels - * - use 3 shades of color group/standard color for 3 indention level - */ - UI_ThemeColorShade(TH_HEADER, ((indent==0)?20: (indent==1)?-20: -40)); + /* NLA tracks - darker color if not solo track when we're showing solo */ + UI_ThemeColorShade(TH_HEADER, ((nonSolo == 0)? 20 : -20)); indent += group; offset += 7 * indent; @@ -816,7 +917,7 @@ static void draw_nla_channel_list_gl (bAnimContext *ac, ListBase *anim_data, Vie } /* adjust y-position for next one */ - y -= NLACHANNEL_STEP; + y -= NLACHANNEL_STEP(snla); } } @@ -826,12 +927,14 @@ void draw_nla_channel_list (bContext *C, bAnimContext *ac, ARegion *ar) bAnimListElem *ale; int filter; + SpaceNla *snla = (SpaceNla *)ac->sl; View2D *v2d= &ar->v2d; float y= 0.0f; - int items, height; + size_t items; + int height; /* build list of channels to draw */ - filter= (ANIMFILTER_VISIBLE|ANIMFILTER_CHANNELS); + filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); items= ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* Update max-extent of channels here (taking into account scrollers): @@ -840,7 +943,7 @@ void draw_nla_channel_list (bContext *C, bAnimContext *ac, ARegion *ar) * - offset of NLACHANNEL_HEIGHT*2 is added to the height of the channels, as first is for * start of list offset, and the second is as a correction for the scrollers. */ - height= ((items*NLACHANNEL_STEP) + (NLACHANNEL_HEIGHT*2)); + height= ((items*NLACHANNEL_STEP(snla)) + (NLACHANNEL_HEIGHT(snla)*2)); /* don't use totrect set, as the width stays the same * (NOTE: this is ok here, the configuration is pretty straightforward) */ @@ -850,14 +953,15 @@ void draw_nla_channel_list (bContext *C, bAnimContext *ac, ARegion *ar) /* draw channels */ { /* first pass: backdrops + oldstyle drawing */ - y= (float)(-NLACHANNEL_HEIGHT); + y= (float)(-NLACHANNEL_HEIGHT(snla)); draw_nla_channel_list_gl(ac, &anim_data, v2d, y); } { /* second pass: UI widgets */ uiBlock *block= uiBeginBlock(C, ar, "NLA channel buttons", UI_EMBOSS); + size_t channel_index = 0; - y= (float)(-NLACHANNEL_HEIGHT); + y= (float)(-NLACHANNEL_HEIGHT(snla)); /* set blending again, as may not be set in previous step */ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -865,19 +969,20 @@ void draw_nla_channel_list (bContext *C, bAnimContext *ac, ARegion *ar) /* loop through channels, and set up drawing depending on their type */ for (ale= anim_data.first; ale; ale= ale->next) { - const float yminc= (float)(y - NLACHANNEL_HEIGHT_HALF); - const float ymaxc= (float)(y + NLACHANNEL_HEIGHT_HALF); + const float yminc= (float)(y - NLACHANNEL_HEIGHT_HALF(snla)); + const float ymaxc= (float)(y + NLACHANNEL_HEIGHT_HALF(snla)); /* check if visible */ if ( IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) { /* draw all channels using standard channel-drawing API */ - ANIM_channel_draw_widgets(ac, ale, block, yminc, ymaxc); + ANIM_channel_draw_widgets(C, ac, ale, block, yminc, ymaxc, channel_index); } /* adjust y-position for next one */ - y -= NLACHANNEL_STEP; + y -= NLACHANNEL_STEP(snla); + channel_index++; } uiEndBlock(C, block); diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c index 32cac62c4ce..70333fb00dd 100644 --- a/source/blender/editors/space_nla/nla_edit.c +++ b/source/blender/editors/space_nla/nla_edit.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or @@ -36,6 +34,7 @@ #include <math.h> #include "DNA_anim_types.h" +#include "DNA_object_types.h" #include "DNA_scene_types.h" #include "MEM_guardedalloc.h" @@ -70,6 +69,7 @@ #include "UI_interface.h" #include "UI_resources.h" +#include "UI_view2d.h" #include "nla_intern.h" // own include #include "nla_private.h" // FIXME... maybe this shouldn't be included? @@ -82,7 +82,7 @@ void ED_nla_postop_refresh (bAnimContext *ac) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; - short filter= (ANIMFILTER_VISIBLE | ANIMFILTER_ANIMDATA | ANIMFILTER_FOREDIT); + short filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_ANIMDATA | ANIMFILTER_FOREDIT); /* get blocks to work on */ ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); @@ -118,7 +118,7 @@ static int nlaedit_enable_tweakmode_exec (bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* get a list of the AnimData blocks being shown in the NLA */ - filter= (ANIMFILTER_VISIBLE | ANIMFILTER_ANIMDATA); + filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_ANIMDATA); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* if no blocks, popup error? */ @@ -187,7 +187,7 @@ static int nlaedit_disable_tweakmode_exec (bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* get a list of the AnimData blocks being shown in the NLA */ - filter= (ANIMFILTER_VISIBLE | ANIMFILTER_ANIMDATA); + filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_ANIMDATA); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* if no blocks, popup error? */ @@ -238,6 +238,136 @@ void NLA_OT_tweakmode_exit (wmOperatorType *ot) } /* *********************************************** */ +/* NLA Strips Range Stuff */ + +/* *************************** Calculate Range ************************** */ + +/* Get the min/max strip extents */ +static void get_nlastrip_extents (bAnimContext *ac, float *min, float *max, const short onlySel) +{ + ListBase anim_data = {NULL, NULL}; + bAnimListElem *ale; + int filter; + + /* get data to filter */ + filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_NODUPLIS); + ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); + + /* set large values to try to override */ + *min= 999999999.0f; + *max= -999999999.0f; + + /* check if any channels to set range with */ + if (anim_data.first) { + /* go through channels, finding max extents */ + for (ale= anim_data.first; ale; ale= ale->next) { + NlaTrack *nlt = (NlaTrack *)ale->data; + NlaStrip *strip; + + for (strip = nlt->strips.first; strip; strip = strip->next) { + /* only consider selected strips? */ + if ((onlySel == 0) || (strip->flag & NLASTRIP_FLAG_SELECT)) { + /* extend range if appropriate */ + *min = MIN2(*min, strip->start); + *max = MAX2(*max, strip->end); + } + } + } + + /* free memory */ + BLI_freelistN(&anim_data); + } + else { + /* set default range */ + if (ac->scene) { + *min= (float)ac->scene->r.sfra; + *max= (float)ac->scene->r.efra; + } + else { + *min= -5; + *max= 100; + } + } +} + +/* ****************** View-All Operator ****************** */ + +static int nlaedit_viewall(bContext *C, const short onlySel) +{ + bAnimContext ac; + View2D *v2d; + float extra; + + /* get editor data */ + if (ANIM_animdata_get_context(C, &ac) == 0) + return OPERATOR_CANCELLED; + v2d= &ac.ar->v2d; + + /* set the horizontal range, with an extra offset so that the extreme keys will be in view */ + get_nlastrip_extents(&ac, &v2d->cur.xmin, &v2d->cur.xmax, onlySel); + + extra= 0.1f * (v2d->cur.xmax - v2d->cur.xmin); + v2d->cur.xmin -= extra; + v2d->cur.xmax += extra; + + /* set vertical range */ + v2d->cur.ymax= 0.0f; + v2d->cur.ymin= (float)-(v2d->mask.ymax - v2d->mask.ymin); + + /* do View2D syncing */ + UI_view2d_sync(CTX_wm_screen(C), CTX_wm_area(C), v2d, V2D_LOCK_COPY); + + /* just redraw this view */ + ED_area_tag_redraw(CTX_wm_area(C)); + + return OPERATOR_FINISHED; +} + +/* ......... */ + +static int nlaedit_viewall_exec(bContext *C, wmOperator *UNUSED(op)) +{ + /* whole range */ + return nlaedit_viewall(C, FALSE); +} + +static int nlaedit_viewsel_exec(bContext *C, wmOperator *UNUSED(op)) +{ + /* only selected */ + return nlaedit_viewall(C, TRUE); +} + +void NLA_OT_view_all (wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "View All"; + ot->idname= "NLA_OT_view_all"; + ot->description= "Reset viewable area to show full strips range"; + + /* api callbacks */ + ot->exec= nlaedit_viewall_exec; + ot->poll= ED_operator_nla_active; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + +void NLA_OT_view_selected (wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "View Selected"; + ot->idname= "NLA_OT_view_selected"; + ot->description= "Reset viewable area to show selected strips range"; + + /* api callbacks */ + ot->exec= nlaedit_viewsel_exec; + ot->poll= ED_operator_nla_active; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + +/* *********************************************** */ /* NLA Editing Operations (Constructive/Destructive) */ /* ******************** Add Action-Clip Operator ***************************** */ @@ -252,7 +382,8 @@ static int nlaedit_add_actionclip_exec (bContext *C, wmOperator *op) ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; - int filter, items; + size_t items; + int filter; bAction *act; @@ -283,7 +414,7 @@ static int nlaedit_add_actionclip_exec (bContext *C, wmOperator *op) /* get a list of the editable tracks being shown in the NLA * - this is limited to active ones for now, but could be expanded to */ - filter= (ANIMFILTER_VISIBLE | ANIMFILTER_ACTIVE | ANIMFILTER_NLATRACKS | ANIMFILTER_FOREDIT); + filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_ACTIVE | ANIMFILTER_FOREDIT); items= ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); if (items == 0) { @@ -381,7 +512,7 @@ static int nlaedit_add_transition_exec (bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* get a list of the editable tracks being shown in the NLA */ - filter= (ANIMFILTER_VISIBLE | ANIMFILTER_NLATRACKS | ANIMFILTER_FOREDIT); + filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* for each track, find pairs of strips to add transitions to */ @@ -404,14 +535,17 @@ static int nlaedit_add_transition_exec (bContext *C, wmOperator *op) if ELEM(0, (s1->flag & NLASTRIP_FLAG_SELECT), (s2->flag & NLASTRIP_FLAG_SELECT)) continue; /* check if there's space between the two */ - if (IS_EQ(s1->end, s2->start)) + if (IS_EQF(s1->end, s2->start)) continue; - /* make neither one is a transition + /* make sure neither one is a transition * - although this is impossible to create with the standard tools, * the user may have altered the settings */ if (ELEM(NLASTRIP_TYPE_TRANSITION, s1->type, s2->type)) continue; + /* also make sure neither one is a soundclip */ + if (ELEM(NLASTRIP_TYPE_SOUND, s1->type, s2->type)) + continue; /* allocate new strip */ strip= MEM_callocN(sizeof(NlaStrip), "NlaStrip"); @@ -478,6 +612,91 @@ void NLA_OT_transition_add (wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } +/* ******************** Add Sound Clip Operator ***************************** */ +/* Add a new sound clip */ + +static int nlaedit_add_sound_exec (bContext *C, wmOperator *UNUSED(op)) +{ + bAnimContext ac; + + ListBase anim_data = {NULL, NULL}; + bAnimListElem *ale; + int filter; + + Scene *scene; + int cfra; + + /* get editor data */ + if (ANIM_animdata_get_context(C, &ac) == 0) + return OPERATOR_CANCELLED; + + scene = ac.scene; + cfra = CFRA; + + /* get a list of the editable tracks being shown in the NLA */ + filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT); + ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); + + /* for each track, add sound clips if it belongs to a speaker */ + // TODO: what happens if there aren't any tracks... well that's a more general problem for later + for (ale= anim_data.first; ale; ale= ale->next) { + Object *ob = (Object *)ale->id; /* may not be object until we actually check! */ + + AnimData *adt = ale->adt; + NlaTrack *nlt= (NlaTrack *)ale->data; + NlaStrip *strip; + + /* does this belong to speaker - assumed to live on Object level only */ + if ((GS(ale->id->name) != ID_OB) || (ob->type != OB_SPEAKER)) + continue; + + /* create a new strip, and offset it to start on the current frame */ + strip= add_nla_soundstrip(ac.scene, ob->data); + + strip->start += cfra; + strip->end += cfra; + + /* firstly try adding strip to our current track, but if that fails, add to a new track */ + if (BKE_nlatrack_add_strip(nlt, strip) == 0) { + /* trying to add to the current failed (no space), + * so add a new track to the stack, and add to that... + */ + nlt= add_nlatrack(adt, NULL); + BKE_nlatrack_add_strip(nlt, strip); + } + + /* auto-name it */ + BKE_nlastrip_validate_name(adt, strip); + } + + /* free temp data */ + BLI_freelistN(&anim_data); + + /* refresh auto strip properties */ + ED_nla_postop_refresh(&ac); + + /* set notifier that things have changed */ + WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_EDITED, NULL); + + /* done */ + return OPERATOR_FINISHED; +} + +void NLA_OT_soundclip_add (wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Add Sound Clip"; + ot->idname= "NLA_OT_soundclip_add"; + ot->description= "Add a strip for controlling when speaker plays its sound clip"; + + /* api callbacks */ + ot->exec= nlaedit_add_sound_exec; + ot->poll= nlaop_poll_tweakmode_off; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + /* ******************** Add Meta-Strip Operator ***************************** */ /* Add new meta-strips incorporating the selected strips */ @@ -495,7 +714,7 @@ static int nlaedit_add_meta_exec (bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; /* get a list of the editable tracks being shown in the NLA */ - filter= (ANIMFILTER_VISIBLE | ANIMFILTER_NLATRACKS | ANIMFILTER_FOREDIT); + filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* for each track, find pairs of strips to add transitions to */ @@ -556,7 +775,7 @@ static int nlaedit_remove_meta_exec (bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; /* get a list of the editable tracks being shown in the NLA */ - filter= (ANIMFILTER_VISIBLE | ANIMFILTER_NLATRACKS | ANIMFILTER_FOREDIT); + filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* for each track, find pairs of strips to add transitions to */ @@ -612,7 +831,7 @@ static int nlaedit_duplicate_exec (bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; /* get a list of editable tracks being shown in the NLA */ - filter= (ANIMFILTER_VISIBLE | ANIMFILTER_NLATRACKS | ANIMFILTER_FOREDIT); + filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* duplicate strips in tracks starting from the last one so that we're @@ -715,7 +934,7 @@ static int nlaedit_delete_exec (bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; /* get a list of the editable tracks being shown in the NLA */ - filter= (ANIMFILTER_VISIBLE | ANIMFILTER_NLATRACKS | ANIMFILTER_FOREDIT); + filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* for each NLA-Track, delete all selected strips */ @@ -796,14 +1015,14 @@ static void nlaedit_split_strip_actclip (AnimData *adt, NlaTrack *nlt, NlaStrip /* strip extents */ len= strip->end - strip->start; - if (IS_EQ(len, 0.0f)) + if (IS_EQF(len, 0.0f)) return; else splitframe= strip->start + (len / 2.0f); /* action range */ len= strip->actend - strip->actstart; - if (IS_EQ(len, 0.0f)) + if (IS_EQF(len, 0.0f)) splitaframe= strip->actend; else splitaframe= strip->actstart + (len / 2.0f); @@ -856,7 +1075,7 @@ static int nlaedit_split_exec (bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; /* get a list of editable tracks being shown in the NLA */ - filter= (ANIMFILTER_VISIBLE | ANIMFILTER_NLATRACKS | ANIMFILTER_FOREDIT); + filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* for each NLA-Track, split all selected strips into two strips */ @@ -932,7 +1151,7 @@ static int nlaedit_bake_exec (bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; /* get a list of the editable tracks being shown in the NLA */ - filter= (ANIMFILTER_VISIBLE | ANIMFILTER_ANIMDATA | ANIMFILTER_FOREDIT); + filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_ANIMDATA | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* for each AnimData block, bake strips to animdata... */ @@ -953,7 +1172,7 @@ static int nlaedit_bake_exec (bContext *C, wmOperator *UNUSED(op)) return OPERATOR_FINISHED; } -static void NLA_OT_bake (wmOperatorType *ot) +void NLA_OT_bake (wmOperatorType *ot) { /* identifiers */ ot->name= _("Bake Strips"); @@ -987,7 +1206,7 @@ static int nlaedit_toggle_mute_exec (bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; /* get a list of the editable tracks being shown in the NLA */ - filter= (ANIMFILTER_VISIBLE | ANIMFILTER_NLATRACKS | ANIMFILTER_FOREDIT); + filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* go over all selected strips */ @@ -1046,7 +1265,7 @@ static int nlaedit_swap_exec (bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* get a list of the editable tracks being shown in the NLA */ - filter= (ANIMFILTER_VISIBLE | ANIMFILTER_NLATRACKS | ANIMFILTER_FOREDIT); + filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* consider each track in turn */ @@ -1204,7 +1423,7 @@ static int nlaedit_move_up_exec (bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; /* get a list of the editable tracks being shown in the NLA */ - filter= (ANIMFILTER_VISIBLE | ANIMFILTER_NLATRACKS | ANIMFILTER_FOREDIT); + filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* since we're potentially moving strips from lower tracks to higher tracks, we should @@ -1278,7 +1497,7 @@ static int nlaedit_move_down_exec (bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; /* get a list of the editable tracks being shown in the NLA */ - filter= (ANIMFILTER_VISIBLE | ANIMFILTER_NLATRACKS | ANIMFILTER_FOREDIT); + filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* loop through the tracks in normal order, since we're pushing strips down, @@ -1353,7 +1572,7 @@ static int nlaedit_sync_actlen_exec (bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* get a list of the editable tracks being shown in the NLA */ - filter= (ANIMFILTER_VISIBLE | ANIMFILTER_NLATRACKS | ANIMFILTER_FOREDIT); + filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); if (active_only) filter |= ANIMFILTER_ACTIVE; ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); @@ -1448,7 +1667,7 @@ static int nlaedit_apply_scale_exec (bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; /* get a list of the editable tracks being shown in the NLA */ - filter= (ANIMFILTER_VISIBLE | ANIMFILTER_NLATRACKS | ANIMFILTER_FOREDIT); + filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* init the editing data */ @@ -1475,7 +1694,7 @@ static int nlaedit_apply_scale_exec (bContext *C, wmOperator *UNUSED(op)) /* setup iterator, and iterate over all the keyframes in the action, applying this scaling */ ked.data= strip; - ANIM_animchanneldata_keyframes_loop(&ked, strip->act, ALE_ACT, NULL, bezt_apply_nlamapping, calchandles_fcurve, 0); + ANIM_animchanneldata_keyframes_loop(&ked, ac.ads, strip->act, ALE_ACT, NULL, bezt_apply_nlamapping, calchandles_fcurve); /* clear scale of strip now that it has been applied, * and recalculate the extents of the action now that it has been scaled @@ -1528,7 +1747,7 @@ static int nlaedit_clear_scale_exec (bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; /* get a list of the editable tracks being shown in the NLA */ - filter= (ANIMFILTER_VISIBLE | ANIMFILTER_NLATRACKS | ANIMFILTER_FOREDIT); + filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* for each NLA-Track, reset scale of all selected strips */ @@ -1604,7 +1823,7 @@ static int nlaedit_snap_exec (bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* get a list of the editable tracks being shown in the NLA */ - filter= (ANIMFILTER_VISIBLE | ANIMFILTER_NLATRACKS | ANIMFILTER_FOREDIT); + filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* get some necessary vars */ @@ -1641,10 +1860,10 @@ static int nlaedit_snap_exec (bContext *C, wmOperator *op) strip->start= (float)CFRA; break; case NLAEDIT_SNAP_NEAREST_FRAME: /* to nearest frame */ - strip->start= (float)(floor(start+0.5)); + strip->start= floorf(start+0.5f); break; case NLAEDIT_SNAP_NEAREST_SECOND: /* to nearest second */ - strip->start= ((float)floor(start/secf + 0.5f) * secf); + strip->start= floorf(start/secf + 0.5f) * secf; break; case NLAEDIT_SNAP_NEAREST_MARKER: /* to nearest marker */ strip->start= (float)ED_markers_find_nearest_marker_time(ac.markers, start); @@ -1772,7 +1991,7 @@ static int nla_fmodifier_add_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* get a list of the editable tracks being shown in the NLA */ - filter= (ANIMFILTER_VISIBLE | ANIMFILTER_NLATRACKS | ANIMFILTER_FOREDIT); + filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* for each NLA-Track, add the specified modifier to all selected strips */ @@ -1793,6 +2012,10 @@ static int nla_fmodifier_add_exec(bContext *C, wmOperator *op) continue; } + /* sound clips are not affected by FModifiers */ + if (strip->type == NLASTRIP_TYPE_SOUND) + continue; + /* add F-Modifier of specified type to selected, and make it the active one */ fcm= add_fmodifier(&strip->modifiers, type); @@ -1853,7 +2076,7 @@ static int nla_fmodifier_copy_exec(bContext *C, wmOperator *op) free_fmodifiers_copybuf(); /* get a list of the editable tracks being shown in the NLA */ - filter= (ANIMFILTER_VISIBLE | ANIMFILTER_NLATRACKS | ANIMFILTER_FOREDIT); + filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* for each NLA-Track, add the specified modifier to all selected strips */ @@ -1912,7 +2135,7 @@ static int nla_fmodifier_paste_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* get a list of the editable tracks being shown in the NLA */ - filter= (ANIMFILTER_VISIBLE | ANIMFILTER_NLATRACKS | ANIMFILTER_SEL | ANIMFILTER_FOREDIT); + filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* for each NLA-Track, add the specified modifier to all selected strips */ diff --git a/source/blender/editors/space_nla/nla_intern.h b/source/blender/editors/space_nla/nla_intern.h index dba7fca8d0f..ec2e22e65fa 100644 --- a/source/blender/editors/space_nla/nla_intern.h +++ b/source/blender/editors/space_nla/nla_intern.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or @@ -94,8 +92,12 @@ void NLA_OT_tweakmode_exit(wmOperatorType *ot); /* --- */ +void NLA_OT_view_all(wmOperatorType *ot); +void NLA_OT_view_selected(wmOperatorType *ot); + void NLA_OT_actionclip_add(wmOperatorType *ot); void NLA_OT_transition_add(wmOperatorType *ot); +void NLA_OT_soundclip_add(wmOperatorType *ot); void NLA_OT_meta_add(wmOperatorType *ot); void NLA_OT_meta_remove(wmOperatorType *ot); diff --git a/source/blender/editors/space_nla/nla_ops.c b/source/blender/editors/space_nla/nla_ops.c index 85dcf14adac..821e302c13d 100644 --- a/source/blender/editors/space_nla/nla_ops.c +++ b/source/blender/editors/space_nla/nla_ops.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or @@ -45,6 +43,7 @@ #include "BKE_screen.h" #include "ED_anim_api.h" +#include "ED_markers.h" #include "ED_screen.h" #include "ED_transform.h" @@ -129,12 +128,17 @@ void nla_operatortypes(void) WM_operatortype_append(NLA_OT_select_all_toggle); WM_operatortype_append(NLA_OT_select_leftright); + /* view */ + WM_operatortype_append(NLA_OT_view_all); + WM_operatortype_append(NLA_OT_view_selected); + /* edit */ WM_operatortype_append(NLA_OT_tweakmode_enter); WM_operatortype_append(NLA_OT_tweakmode_exit); WM_operatortype_append(NLA_OT_actionclip_add); WM_operatortype_append(NLA_OT_transition_add); + WM_operatortype_append(NLA_OT_soundclip_add); WM_operatortype_append(NLA_OT_meta_add); WM_operatortype_append(NLA_OT_meta_remove); @@ -211,6 +215,11 @@ static void nla_keymap_main (wmKeyConfig *keyconf, wmKeyMap *keymap) WM_keymap_add_item(keymap, "NLA_OT_select_border", BKEY, KM_PRESS, 0, 0); RNA_boolean_set(WM_keymap_add_item(keymap, "NLA_OT_select_border", BKEY, KM_PRESS, KM_ALT, 0)->ptr, "axis_range", 1); + /* view*/ + /* auto-set range */ + //WM_keymap_add_item(keymap, "NLA_OT_previewrange_set", PKEY, KM_PRESS, KM_CTRL|KM_ALT, 0); + WM_keymap_add_item(keymap, "NLA_OT_view_all", HOMEKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "NLA_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0); /* editing */ /* tweakmode @@ -223,6 +232,7 @@ static void nla_keymap_main (wmKeyConfig *keyconf, wmKeyMap *keymap) /* add strips */ WM_keymap_add_item(keymap, "NLA_OT_actionclip_add", AKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "NLA_OT_transition_add", TKEY, KM_PRESS, KM_SHIFT, 0); + WM_keymap_add_item(keymap, "NLA_OT_soundclip_add", KKEY, KM_PRESS, KM_SHIFT, 0); /* meta-strips */ WM_keymap_add_item(keymap, "NLA_OT_meta_add", GKEY, KM_PRESS, KM_SHIFT, 0); @@ -262,6 +272,9 @@ static void nla_keymap_main (wmKeyConfig *keyconf, wmKeyMap *keymap) /* transform system */ transform_keymap_for_space(keyconf, keymap, SPACE_NLA); + + /* special markers hotkeys for anim editors: see note in definition of this function */ + ED_marker_keymap_animedit_conflictfree(keymap); } /* --------------- */ diff --git a/source/blender/editors/space_nla/nla_select.c b/source/blender/editors/space_nla/nla_select.c index d8f27c9399b..2de762f28bc 100644 --- a/source/blender/editors/space_nla/nla_select.c +++ b/source/blender/editors/space_nla/nla_select.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or @@ -116,7 +114,8 @@ static void deselect_nla_strips (bAnimContext *ac, short test, short sel) short smode; /* determine type-based settings */ - filter= (ANIMFILTER_VISIBLE | ANIMFILTER_NLATRACKS); + // FIXME: double check whether ANIMFILTER_LIST_VISIBLE is needed! + filter= (ANIMFILTER_DATA_VISIBLE); /* filter data */ ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); @@ -226,16 +225,17 @@ static void borderselect_nla_strips (bAnimContext *ac, rcti rect, short mode, sh bAnimListElem *ale; int filter; + SpaceNla *snla = (SpaceNla *)ac->sl; View2D *v2d= &ac->ar->v2d; rctf rectf; - float ymin=(float)(-NLACHANNEL_HEIGHT), ymax=0; + float ymin=(float)(-NLACHANNEL_HEIGHT(snla)), ymax=0; /* convert border-region to view coordinates */ UI_view2d_region_to_view(v2d, rect.xmin, rect.ymin+2, &rectf.xmin, &rectf.ymin); UI_view2d_region_to_view(v2d, rect.xmax, rect.ymax-2, &rectf.xmax, &rectf.ymax); /* filter data */ - filter= (ANIMFILTER_VISIBLE | ANIMFILTER_CHANNELS); + filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* convert selection modes to selection modes */ @@ -243,7 +243,7 @@ static void borderselect_nla_strips (bAnimContext *ac, rcti rect, short mode, sh /* loop over data, doing border select */ for (ale= anim_data.first; ale; ale= ale->next) { - ymin= ymax - NLACHANNEL_STEP; + ymin= ymax - NLACHANNEL_STEP(snla); /* perform vertical suitability check (if applicable) */ if ( (mode == NLA_BORDERSEL_FRAMERANGE) || @@ -397,7 +397,7 @@ static void nlaedit_select_leftright (bContext *C, bAnimContext *ac, short leftr /* filter data */ - filter= (ANIMFILTER_VISIBLE | ANIMFILTER_NLATRACKS); + filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* select strips on the side where most data occurs */ @@ -506,6 +506,7 @@ static void mouse_nla_strips (bContext *C, bAnimContext *ac, const int mval[2], bAnimListElem *ale = NULL; int filter; + SpaceNla *snla = (SpaceNla *)ac->sl; View2D *v2d= &ac->ar->v2d; Scene *scene= ac->scene; NlaStrip *strip = NULL; @@ -516,7 +517,7 @@ static void mouse_nla_strips (bContext *C, bAnimContext *ac, const int mval[2], /* use View2D to determine the index of the channel (i.e a row in the list) where keyframe was */ UI_view2d_region_to_view(v2d, mval[0], mval[1], &x, &y); - UI_view2d_listview_view_to_cell(v2d, 0, NLACHANNEL_STEP, 0, (float)NLACHANNEL_HEIGHT_HALF, x, y, NULL, &channel_index); + UI_view2d_listview_view_to_cell(v2d, 0, NLACHANNEL_STEP(snla), 0, (float)NLACHANNEL_HEIGHT_HALF(snla), x, y, NULL, &channel_index); /* x-range to check is +/- 7 (in screen/region-space) on either side of mouse click * (that is the size of keyframe icons, so user should be expecting similar tolerances) @@ -525,7 +526,7 @@ static void mouse_nla_strips (bContext *C, bAnimContext *ac, const int mval[2], UI_view2d_region_to_view(v2d, mval[0]+7, mval[1], &xmax, &dummy); /* filter data */ - filter= (ANIMFILTER_VISIBLE | ANIMFILTER_CHANNELS); + filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* try to get channel */ diff --git a/source/blender/editors/space_nla/space_nla.c b/source/blender/editors/space_nla/space_nla.c index f2e0abe1e60..48859acff6a 100644 --- a/source/blender/editors/space_nla/space_nla.c +++ b/source/blender/editors/space_nla/space_nla.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or |