diff options
author | Alexander Gavrilov <angavrilov@gmail.com> | 2019-06-16 13:32:50 +0300 |
---|---|---|
committer | Alexander Gavrilov <angavrilov@gmail.com> | 2019-06-16 14:16:05 +0300 |
commit | 3e086af79ceb38345eed1c76472eb6fc8cfc1196 (patch) | |
tree | 19630b47cc3459f49d8313acd2f3b4521f1769c9 /source/blender/editors/screen/screen_context.c | |
parent | 985f33719ce9108d35d5f37b4c7c79d81f708a0d (diff) |
Drivers: fix Variable Copy & Paste in the edit popover.
Without these buttons the functionality of the popover is
incomplete compared to the Graph Editor panel. To support
this the operators have to read the active F-Curve from
the context, instead of directly scanning animation data.
Expanding the context would also help Python operators.
Diffstat (limited to 'source/blender/editors/screen/screen_context.c')
-rw-r--r-- | source/blender/editors/screen/screen_context.c | 48 |
1 files changed, 41 insertions, 7 deletions
diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c index 6a5df8a3776..2eb7f732534 100644 --- a/source/blender/editors/screen/screen_context.c +++ b/source/blender/editors/screen/screen_context.c @@ -104,7 +104,11 @@ const char *screen_context_dir[] = { "active_gpencil_layer", "active_gpencil_frame", "active_operator", + "visible_fcurves", + "editable_fcurves", + "selected_visible_fcurves", "selected_editable_fcurves", + "active_editable_fcurve", NULL, }; @@ -654,23 +658,31 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult return 1; } } - else if (CTX_data_equals(member, "selected_editable_fcurves")) { + else if (CTX_data_equals(member, "editable_fcurves") || + CTX_data_equals(member, "visible_fcurves") || + CTX_data_equals(member, "selected_editable_fcurves") || + CTX_data_equals(member, "selected_visible_fcurves")) { bAnimContext ac; if (ANIM_animdata_get_context(C, &ac) && ELEM(ac.spacetype, SPACE_ACTION, SPACE_GRAPH)) { - bAnimListElem *ale; ListBase anim_data = {NULL, NULL}; - int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS | - ANIMFILTER_SEL) | + int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_NODUPLIS) | (ac.spacetype == SPACE_GRAPH ? ANIMFILTER_CURVE_VISIBLE : ANIMFILTER_LIST_VISIBLE); + if (strstr(member, "editable_")) { + filter |= ANIMFILTER_FOREDIT; + } + if (STRPREFIX(member, "selected_")) { + filter |= ANIMFILTER_SEL; + } + ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - for (ale = anim_data.first; ale; ale = ale->next) { - if (ale->type == ANIMTYPE_FCURVE) { - CTX_data_list_add(result, ale->id, &RNA_FCurve, ale->data); + for (bAnimListElem *ale = anim_data.first; ale; ale = ale->next) { + if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE)) { + CTX_data_list_add(result, ale->fcurve_owner_id, &RNA_FCurve, ale->data); } } @@ -680,6 +692,28 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult return 1; } } + else if (CTX_data_equals(member, "active_editable_fcurve")) { + bAnimContext ac; + + if (ANIM_animdata_get_context(C, &ac) && ELEM(ac.spacetype, SPACE_GRAPH)) { + ListBase anim_data = {NULL, NULL}; + + int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_ACTIVE | ANIMFILTER_FOREDIT | + ANIMFILTER_CURVE_VISIBLE); + + ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); + + for (bAnimListElem *ale = anim_data.first; ale; ale = ale->next) { + if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE)) { + CTX_data_pointer_set(result, ale->fcurve_owner_id, &RNA_FCurve, ale->data); + break; + } + } + + ANIM_animdata_freelist(&anim_data); + return 1; + } + } else { return 0; /* not found */ } |