Commit: aabe6e3b457f1d4f1b860ed510bf2630a818465e Author: Campbell Barton Date: Tue Aug 31 11:46:46 2021 +1000 Branches: master https://developer.blender.org/rBaabe6e3b457f1d4f1b860ed510bf2630a818465e
Context: add "active_nla_track" & "active_nla_strip" context members Selection was already accessible but not active. Add utility functions: - ANIM_nla_context_track to access the active track, following the convention of ANIM_nla_context_strip. - ANIM_nla_context_*_ptr versions of these functions, needed to for creating context members to access the ID pointer. Part of fix for T90723. =================================================================== M doc/python_api/sphinx_doc_gen.py M source/blender/editors/include/ED_anim_api.h M source/blender/editors/screen/screen_context.c M source/blender/editors/space_nla/nla_buttons.c =================================================================== diff --git a/doc/python_api/sphinx_doc_gen.py b/doc/python_api/sphinx_doc_gen.py index 5bd5f660104..99d1828e529 100644 --- a/doc/python_api/sphinx_doc_gen.py +++ b/doc/python_api/sphinx_doc_gen.py @@ -1047,6 +1047,8 @@ context_type_map = { "active_pose_bone": ("PoseBone", False), "active_sequence_strip": ("Sequence", False), "active_editable_fcurve": ("FCurve", False), + "active_nla_strip": ("NlaStrip", False), + "active_nla_track": ("NlaTrack", False), "annotation_data": ("GreasePencil", False), "annotation_data_owner": ("ID", False), "armature": ("Armature", False), diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h index 75c02082bd3..8b954b0fe69 100644 --- a/source/blender/editors/include/ED_anim_api.h +++ b/source/blender/editors/include/ED_anim_api.h @@ -678,6 +678,11 @@ void ANIM_draw_framerange(struct Scene *scene, struct View2D *v2d); /* ------------- UI Panel Drawing -------------- */ + +bool ANIM_nla_context_track_ptr(const struct bContext *C, struct PointerRNA *r_ptr); +bool ANIM_nla_context_strip_ptr(const struct bContext *C, struct PointerRNA *r_ptr); + +struct NlaTrack *ANIM_nla_context_track(const struct bContext *C); struct NlaStrip *ANIM_nla_context_strip(const struct bContext *C); struct FCurve *ANIM_graph_context_fcurve(const struct bContext *C); diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c index 390d1bdf428..6eb404cb801 100644 --- a/source/blender/editors/screen/screen_context.c +++ b/source/blender/editors/screen/screen_context.c @@ -96,7 +96,9 @@ const char *screen_context_dir[] = { "sequences", "selected_sequences", "selected_editable_sequences", /* sequencer */ - "selected_nla_strips", /* nla editor */ + "active_nla_track", + "active_nla_strip", + "selected_nla_strips", /* nla editor */ "gpencil_data", "gpencil_data_owner", /* grease pencil data */ "annotation_data", @@ -664,6 +666,24 @@ static eContextResult screen_ctx_selected_editable_sequences(const bContext *C, } return CTX_RESULT_NO_DATA; } +static eContextResult screen_ctx_active_nla_track(const bContext *C, bContextDataResult *result) +{ + PointerRNA ptr; + if (ANIM_nla_context_track_ptr(C, &ptr)) { + CTX_data_pointer_set(result, ptr.owner_id, ptr.type, ptr.data); + return CTX_RESULT_OK; + } + return CTX_RESULT_NO_DATA; +} +static eContextResult screen_ctx_active_nla_strip(const bContext *C, bContextDataResult *result) +{ + PointerRNA ptr; + if (ANIM_nla_context_strip_ptr(C, &ptr)) { + CTX_data_pointer_set(result, ptr.owner_id, ptr.type, ptr.data); + return CTX_RESULT_OK; + } + return CTX_RESULT_NO_DATA; +} static eContextResult screen_ctx_selected_nla_strips(const bContext *C, bContextDataResult *result) { bAnimContext ac; @@ -1115,6 +1135,8 @@ static void ensure_ed_screen_context_functions(void) register_context_function("sequences", screen_ctx_sequences); register_context_function("selected_sequences", screen_ctx_selected_sequences); register_context_function("selected_editable_sequences", screen_ctx_selected_editable_sequences); + register_context_function("active_nla_track", screen_ctx_active_nla_track); + register_context_function("active_nla_strip", screen_ctx_active_nla_strip); register_context_function("selected_nla_strips", screen_ctx_selected_nla_strips); register_context_function("gpencil_data", screen_ctx_gpencil_data); register_context_function("gpencil_data_owner", screen_ctx_gpencil_data_owner); diff --git a/source/blender/editors/space_nla/nla_buttons.c b/source/blender/editors/space_nla/nla_buttons.c index d019573bf93..215e865d194 100644 --- a/source/blender/editors/space_nla/nla_buttons.c +++ b/source/blender/editors/space_nla/nla_buttons.c @@ -185,10 +185,31 @@ bool nla_panel_context(const bContext *C, return (found != 0); } +bool ANIM_nla_context_track_ptr(const bContext *C, PointerRNA *r_ptr) +{ + return nla_panel_context(C, NULL, r_ptr, NULL); +} + +bool ANIM_nla_context_strip_ptr(const bContext *C, PointerRNA *r_ptr) +{ + return nla_panel_context(C, NULL, NULL, r_ptr); +} + +NlaTrack *ANIM_nla_context_track(const bContext *C) +{ + PointerRNA track_ptr; + if (!ANIM_nla_context_track_ptr(C, &track_ptr)) { + return NULL; + } + NlaTrack *track = track_ptr.data; + + return track; +} + NlaStrip *ANIM_nla_context_strip(const bContext *C) { PointerRNA strip_ptr; - if (!nla_panel_context(C, NULL, NULL, &strip_ptr)) { + if (!ANIM_nla_context_strip_ptr(C, &strip_ptr)) { return NULL; } NlaStrip *strip = strip_ptr.data; _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs