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:
Diffstat (limited to 'source/blender/editors/screen/screen_context.c')
-rw-r--r--source/blender/editors/screen/screen_context.c88
1 files changed, 88 insertions, 0 deletions
diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c
index a8c63027254..2dc79a0e335 100644
--- a/source/blender/editors/screen/screen_context.c
+++ b/source/blender/editors/screen/screen_context.c
@@ -113,6 +113,8 @@ const char *screen_context_dir[] = {
"active_gpencil_frame",
"active_annotation_layer",
"active_operator",
+ "selected_visible_actions",
+ "selected_editable_actions",
"visible_fcurves",
"editable_fcurves",
"selected_visible_fcurves",
@@ -975,6 +977,90 @@ static eContextResult screen_ctx_active_operator(const bContext *C, bContextData
}
return CTX_RESULT_NO_DATA;
}
+static eContextResult screen_ctx_sel_actions_impl(const bContext *C,
+ bContextDataResult *result,
+ bool editable)
+{
+ bAnimContext ac;
+ if (ANIM_animdata_get_context(C, &ac) && ELEM(ac.spacetype, SPACE_ACTION, SPACE_GRAPH)) {
+ /* In the Action and Shape Key editor always use the action field at the top. */
+ if (ac.spacetype == SPACE_ACTION) {
+ SpaceAction *saction = (SpaceAction *)ac.sl;
+
+ if (ELEM(saction->mode, SACTCONT_ACTION, SACTCONT_SHAPEKEY)) {
+ if (saction->action && !(editable && ID_IS_LINKED(saction->action))) {
+ CTX_data_id_list_add(result, &saction->action->id);
+ }
+
+ CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
+ return CTX_RESULT_OK;
+ }
+ }
+
+ /* Search for selected animation data items. */
+ ListBase anim_data = {NULL, NULL};
+
+ int filter = ANIMFILTER_DATA_VISIBLE;
+ bool check_selected = false;
+
+ switch (ac.spacetype) {
+ case SPACE_GRAPH:
+ filter |= ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_SEL;
+ break;
+
+ case SPACE_ACTION:
+ filter |= ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS;
+ check_selected = true;
+ break;
+ }
+
+ ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
+
+ GSet *seen_set = BLI_gset_ptr_new("seen actions");
+
+ LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
+ /* In dopesheet check selection status of individual items, skipping
+ * if not selected or has no selection flag. This is needed so that
+ * selecting action or group rows without any channels works. */
+ if (check_selected && ANIM_channel_setting_get(&ac, ale, ACHANNEL_SETTING_SELECT) <= 0) {
+ continue;
+ }
+
+ bAction *action = ANIM_channel_action_get(ale);
+
+ if (action) {
+ if (editable && ID_IS_LINKED(action)) {
+ continue;
+ }
+
+ /* Add the action to the output list if not already added. */
+ if (!BLI_gset_haskey(seen_set, action)) {
+ CTX_data_id_list_add(result, &action->id);
+ BLI_gset_add(seen_set, action);
+ }
+ }
+ }
+
+ BLI_gset_free(seen_set, NULL);
+
+ ANIM_animdata_freelist(&anim_data);
+
+ CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
+ return CTX_RESULT_OK;
+ }
+ return CTX_RESULT_NO_DATA;
+}
+
+static eContextResult screen_ctx_selected_visible_actions(const bContext *C,
+ bContextDataResult *result)
+{
+ return screen_ctx_sel_actions_impl(C, result, false);
+}
+static eContextResult screen_ctx_selected_editable_actions(const bContext *C,
+ bContextDataResult *result)
+{
+ return screen_ctx_sel_actions_impl(C, result, true);
+}
static eContextResult screen_ctx_sel_edit_fcurves_(const bContext *C,
bContextDataResult *result,
const int extra_filter)
@@ -1185,6 +1271,8 @@ static void ensure_ed_screen_context_functions(void)
register_context_function("editable_gpencil_layers", screen_ctx_editable_gpencil_layers);
register_context_function("editable_gpencil_strokes", screen_ctx_editable_gpencil_strokes);
register_context_function("active_operator", screen_ctx_active_operator);
+ register_context_function("selected_visible_actions", screen_ctx_selected_visible_actions);
+ register_context_function("selected_editable_actions", screen_ctx_selected_editable_actions);
register_context_function("editable_fcurves", screen_ctx_editable_fcurves);
register_context_function("visible_fcurves", screen_ctx_visible_fcurves);
register_context_function("selected_editable_fcurves", screen_ctx_selected_editable_fcurves);