diff options
author | Joshua Leung <aligorith@gmail.com> | 2011-07-01 16:21:13 +0400 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2011-07-01 16:21:13 +0400 |
commit | 52784d7e30d79765912d92ac2f09c35fa3705372 (patch) | |
tree | 59ddfdc2c34039ad54b2550ed9f8badb8f142d11 /source | |
parent | 3eec91f4d7864366b0cb05fead395d8fbfa711c6 (diff) |
NLA Strip Drawing Tweaks
* Removed frame-number display from NLA strips. Indeed doing so makes
things look cleaner/easier to identify.
* When transforming NLA strips, the "temp-metas" (purple strips) get
their frame extents drawn on either end, like in the sequencer, which
seems to be easier to read than the ones inside the strips.
---
The downside of this tweak is that there is no longer any visual
feedback for which strips run reversed instead of forwards, as that
used to be shown using the frame extents stuff.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/animation/keyframes_edit.c | 26 | ||||
-rw-r--r-- | source/blender/editors/space_nla/nla_draw.c | 72 |
2 files changed, 54 insertions, 44 deletions
diff --git a/source/blender/editors/animation/keyframes_edit.c b/source/blender/editors/animation/keyframes_edit.c index a0b1b4a6ede..9f3d40a5709 100644 --- a/source/blender/editors/animation/keyframes_edit.c +++ b/source/blender/editors/animation/keyframes_edit.c @@ -197,32 +197,6 @@ static short act_keyframes_loop(KeyframeEditData *ked, bAction *act, KeyframeEdi return 0; } -/* This function is used to loop over the keyframe data of an AnimData block */ -static short adt_keyframes_loop(KeyframeEditData *ked, AnimData *adt, KeyframeEditFunc key_ok, KeyframeEditFunc key_cb, FcuEditFunc fcu_cb, int filterflag) -{ - /* sanity check */ - if (adt == NULL) - return 0; - - /* drivers or actions? */ - if (filterflag & ADS_FILTER_ONLYDRIVERS) { - FCurve *fcu; - - /* just loop through all F-Curves acting as Drivers */ - for (fcu= adt->drivers.first; fcu; fcu= fcu->next) { - if (ANIM_fcurve_keyframes_loop(ked, fcu, key_ok, key_cb, fcu_cb)) - return 1; - } - } - else if (adt->action) { - /* call the function for actions */ - if (act_keyframes_loop(ked, adt->action, key_ok, key_cb, fcu_cb)) - return 1; - } - - return 0; -} - /* This function is used to loop over the keyframe data in an Object */ static short ob_keyframes_loop(KeyframeEditData *ked, bDopeSheet *ads, Object *ob, KeyframeEditFunc key_ok, KeyframeEditFunc key_cb, FcuEditFunc fcu_cb) { diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c index 4c6740818dc..53d174169e5 100644 --- a/source/blender/editors/space_nla/nla_draw.c +++ b/source/blender/editors/space_nla/nla_draw.c @@ -420,23 +420,23 @@ 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 (NlaTrack *UNUSED(nlt), NlaStrip *strip, int index, View2D *v2d, float yminc, float ymaxc) { - char str[256], dir[3]; + 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) { + sprintf(str, "%d) Temp-Meta", index); + } + else { + if (strip->flag & NLASTRIP_FLAG_REVERSE) + sprintf(str, "%s", strip->name); + else + sprintf(str, "%s", strip->name); + } /* 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)) { @@ -445,22 +445,52 @@ 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; - + col[3]= 255; + + /* 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[16] = ""; + + + /* 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 */ + sprintf(str, "%.1f", strip->start); + UI_view2d_text_cache_add(v2d, strip->start-1.0f, ymaxc+ytol, str, col); + + /* end frame */ + sprintf(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) @@ -518,6 +548,12 @@ void draw_nla_main_data (bAnimContext *ac, SpaceNla *snla, ARegion *ar) /* add the text for this strip to the cache */ nla_draw_strip_text(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); } } } |