diff options
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/animation/keyframing.c | 41 | ||||
-rw-r--r-- | source/blender/editors/include/ED_keyframing.h | 5 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_anim.c | 4 | ||||
-rw-r--r-- | source/blender/editors/space_nla/nla_draw.c | 15 |
4 files changed, 43 insertions, 22 deletions
diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index ac195f42f03..dd4c4c23f1e 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -1430,6 +1430,31 @@ void ANIM_OT_delete_keyframe_button (wmOperatorType *ot) /* --------------- API/Per-Datablock Handling ------------------- */ +/* Checks if some F-Curve has a keyframe for a given frame */ +short fcurve_frame_has_keyframe (FCurve *fcu, float frame, short filter) +{ + /* quick sanity check */ + if (fcu == NULL) + return 0; + + /* we either include all regardless of muting, or only non-muted */ + if ((filter & ANIMFILTER_KEYS_MUTED) || (fcu->flag & FCURVE_MUTED)==0) { + short replace = -1; + int i = binarysearch_bezt_index(fcu->bezt, frame, fcu->totvert, &replace); + + /* binarysearch_bezt_index will set replace to be 0 or 1 + * - obviously, 1 represents a match + */ + if (replace) { + /* sanity check: 'i' may in rare cases exceed arraylen */ + if ((i >= 0) && (i < fcu->totvert)) + return 1; + } + } + + return 0; +} + /* Checks whether an Action has a keyframe for a given frame * Since we're only concerned whether a keyframe exists, we can simply loop until a match is found... */ @@ -1451,20 +1476,8 @@ short action_frame_has_keyframe (bAction *act, float frame, short filter) for (fcu= act->curves.first; fcu; fcu= fcu->next) { /* only check if there are keyframes (currently only of type BezTriple) */ if (fcu->bezt && fcu->totvert) { - /* we either include all regardless of muting, or only non-muted */ - if ((filter & ANIMFILTER_KEYS_MUTED) || (fcu->flag & FCURVE_MUTED)==0) { - short replace = -1; - int i = binarysearch_bezt_index(fcu->bezt, frame, fcu->totvert, &replace); - - /* binarysearch_bezt_index will set replace to be 0 or 1 - * - obviously, 1 represents a match - */ - if (replace) { - /* sanity check: 'i' may in rare cases exceed arraylen */ - if ((i >= 0) && (i < fcu->totvert)) - return 1; - } - } + if (fcurve_frame_has_keyframe(fcu, frame, filter)) + return 1; } } diff --git a/source/blender/editors/include/ED_keyframing.h b/source/blender/editors/include/ED_keyframing.h index ffebb42ce99..503d71b0d3e 100644 --- a/source/blender/editors/include/ED_keyframing.h +++ b/source/blender/editors/include/ED_keyframing.h @@ -199,6 +199,11 @@ void ANIM_OT_remove_driver_button(struct wmOperatorType *ot); /* ************ Keyframe Checking ******************** */ +/* Lesser Keyframe Checking API call: + * - Used for the buttons to check for keyframes... + */ +short fcurve_frame_has_keyframe(struct FCurve *fcu, float frame, short filter); + /* Main Keyframe Checking API call: * Checks whether a keyframe exists for the given ID-block one the given frame. * - It is recommended to call this method over the other keyframe-checkers directly, diff --git a/source/blender/editors/interface/interface_anim.c b/source/blender/editors/interface/interface_anim.c index 4a26db29160..be4087de525 100644 --- a/source/blender/editors/interface/interface_anim.c +++ b/source/blender/editors/interface/interface_anim.c @@ -18,6 +18,8 @@ #include "RNA_access.h" #include "RNA_types.h" +#include "ED_keyframing.h" + #include "UI_interface.h" #include "WM_api.h" @@ -47,7 +49,7 @@ void ui_but_anim_flag(uiBut *but, float cfra) if (fcu) { but->flag |= UI_BUT_ANIMATED; - if (on_keyframe_fcurve(fcu, cfra)) + if (fcurve_frame_has_keyframe(fcu, cfra, 0)) but->flag |= UI_BUT_ANIMATED_KEY; } } diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c index 7b9f2faf08a..bbb666d01cc 100644 --- a/source/blender/editors/space_nla/nla_draw.c +++ b/source/blender/editors/space_nla/nla_draw.c @@ -291,6 +291,9 @@ static void nla_draw_strip (AnimData *adt, NlaTrack *nlt, NlaStrip *strip, View2 gl_round_box_shade(GL_POLYGON, strip->start, yminc, strip->end, ymaxc, 0.0, 0.5, 0.1); + /* draw influence 'curve' */ + // TODO: + /* draw strip outline * - color used here is to indicate active vs non-active */ @@ -378,11 +381,9 @@ static void nla_draw_strip_text (NlaTrack *nlt, NlaStrip *strip, int index, View case NLASTRIP_TYPE_CLIP: /* Action-Clip (default) */ default: - if (strip->act) - sprintf(str, "%d | Act: %s | %.2f %s %.2f", - index, strip->act->id.name+2, strip->start, dir, strip->end); - else - sprintf(str, "%d | Act: <NONE>", index); // xxx... need a better format? + sprintf(str, "%d | Act: %s | %.2f %s %.2f", + index, ((strip->act)?strip->act->id.name+2:"<NONE>"), + strip->start, dir, strip->end); break; } @@ -396,9 +397,9 @@ static void nla_draw_strip_text (NlaTrack *nlt, NlaStrip *strip, int index, View * - padding of 2 'units' on either side */ // TODO: make this centered? - rect.xmin= strip->start + 2; + rect.xmin= strip->start + 0.5f; rect.ymin= yminc; - rect.xmax= strip->end - 2; + rect.xmax= strip->end - 0.5f; rect.ymax= ymaxc; /* add this string to the cache of texts to draw*/ |