Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2021-08-31 04:46:46 +0300
committerCampbell Barton <ideasman42@gmail.com>2021-08-31 05:06:47 +0300
commitaabe6e3b457f1d4f1b860ed510bf2630a818465e (patch)
treeb32fca731f1e3e036de1f0d887b4b86644320512 /source/blender
parent65739ded542728a6dcca892fe42e20ab7da7ad28 (diff)
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.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/editors/include/ED_anim_api.h5
-rw-r--r--source/blender/editors/screen/screen_context.c24
-rw-r--r--source/blender/editors/space_nla/nla_buttons.c23
3 files changed, 50 insertions, 2 deletions
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;