diff options
Diffstat (limited to 'source/blender/editors/space_graph/graph_utils.c')
-rw-r--r-- | source/blender/editors/space_graph/graph_utils.c | 74 |
1 files changed, 13 insertions, 61 deletions
diff --git a/source/blender/editors/space_graph/graph_utils.c b/source/blender/editors/space_graph/graph_utils.c index 927149a268d..31c1394f1ae 100644 --- a/source/blender/editors/space_graph/graph_utils.c +++ b/source/blender/editors/space_graph/graph_utils.c @@ -87,57 +87,6 @@ bAnimListElem *get_active_fcurve_channel (bAnimContext *ac) /* ************************************************************** */ /* Operator Polling Callbacks */ -/* check if any FModifiers to draw controls for - fcm is 'active' modifier - * used for the polling callbacks + also for drawing - */ -// TODO: restructure these tests -// TODO: maybe for now, just allow editing always for now... -short fcurve_needs_draw_fmodifier_controls (FCurve *fcu, FModifier *fcm) -{ - /* don't draw if there aren't any modifiers at all */ - if (fcu->modifiers.first == NULL) - return 0; - - /* if only one modifier - * - don't draw if it is muted or disabled - * - set it as the active one if no active one is present - */ - if (fcu->modifiers.first == fcu->modifiers.last) { - fcm= fcu->modifiers.first; - if (fcm->flag & (FMODIFIER_FLAG_DISABLED|FMODIFIER_FLAG_MUTED)) - return 0; - } - - /* if there's an active modifier - don't draw if it doesn't drastically - * alter the curve... - */ - if (fcm) { - switch (fcm->type) { - /* clearly harmless */ - case FMODIFIER_TYPE_CYCLES: - return 0; - case FMODIFIER_TYPE_STEPPED: - return 0; - - /* borderline... */ - case FMODIFIER_TYPE_NOISE: - return 0; - } - } - - /* if only active modifier - don't draw if it is muted or disabled */ - if (fcm) { - if (fcm->flag & (FMODIFIER_FLAG_DISABLED|FMODIFIER_FLAG_MUTED)) - return 0; - } - - /* if we're still here, this means that there are modifiers with controls to be drawn */ - // FIXME: what happens if all the modifiers were muted/disabled - return 1; -} - -/* ------------------- */ - /* Check if there are any visible keyframes (for selection tools) */ int graphop_visible_keyframes_poll (bContext *C) { @@ -167,7 +116,6 @@ int graphop_visible_keyframes_poll (bContext *C) for (ale = anim_data.first; ale; ale= ale->next) { FCurve *fcu= (FCurve *)ale->data; - FModifier *fcm; /* visible curves for selection must fulfull the following criteria: * - it has bezier keyframes @@ -176,10 +124,10 @@ int graphop_visible_keyframes_poll (bContext *C) */ if (fcu->bezt == NULL) continue; - fcm= find_active_fmodifier(&fcu->modifiers); - - found= (fcurve_needs_draw_fmodifier_controls(fcu, fcm) == 0); - if (found) break; + if (fcurve_are_keyframes_usable(fcu)) { + found = 1; + break; + } } /* cleanup and return findings */ @@ -216,7 +164,6 @@ int graphop_editable_keyframes_poll (bContext *C) for (ale = anim_data.first; ale; ale= ale->next) { FCurve *fcu= (FCurve *)ale->data; - FModifier *fcm; /* editable curves must fulfull the following criteria: * - it has bezier keyframes @@ -226,10 +173,10 @@ int graphop_editable_keyframes_poll (bContext *C) */ if (fcu->bezt == NULL) continue; - fcm= find_active_fmodifier(&fcu->modifiers); - - found= (fcurve_needs_draw_fmodifier_controls(fcu, fcm) == 0); - if (found) break; + if (fcurve_is_keyframable(fcu)) { + found = 1; + break; + } } /* cleanup and return findings */ @@ -261,6 +208,11 @@ int graphop_active_fcurve_poll (bContext *C) /* free temp data... */ has_fcurve= ((ale->data) && (ale->type == ANIMTYPE_FCURVE)); + if(has_fcurve) { + FCurve *fcu= (FCurve *)ale->data; + has_fcurve= (fcu->flag & FCURVE_VISIBLE)!=0; + } + MEM_freeN(ale); /* return success */ |