Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/screen/screen_context.c
| Show First 20 Lines • Show All 94 Lines • ▼ Show 20 Lines | const char *screen_context_dir[] = { | ||||
| "annotation_data_owner", | "annotation_data_owner", | ||||
| "visible_gpencil_layers", | "visible_gpencil_layers", | ||||
| "editable_gpencil_layers", | "editable_gpencil_layers", | ||||
| "editable_gpencil_strokes", | "editable_gpencil_strokes", | ||||
| "active_gpencil_layer", | "active_gpencil_layer", | ||||
| "active_gpencil_frame", | "active_gpencil_frame", | ||||
| "active_annotation_layer", | "active_annotation_layer", | ||||
| "active_operator", | "active_operator", | ||||
| "active_action", | |||||
| "selected_visible_actions", | "selected_visible_actions", | ||||
| "selected_editable_actions", | "selected_editable_actions", | ||||
| "visible_fcurves", | "visible_fcurves", | ||||
| "editable_fcurves", | "editable_fcurves", | ||||
| "selected_visible_fcurves", | "selected_visible_fcurves", | ||||
| "selected_editable_fcurves", | "selected_editable_fcurves", | ||||
| "active_editable_fcurve", | "active_editable_fcurve", | ||||
| "selected_editable_keyframes", | "selected_editable_keyframes", | ||||
| ▲ Show 20 Lines • Show All 853 Lines • ▼ Show 20 Lines | static eContextResult screen_ctx_active_operator(const bContext *C, bContextDataResult *result) | ||||
| if (op && op->ptr) { | if (op && op->ptr) { | ||||
| CTX_data_pointer_set(result, NULL, &RNA_Operator, op); | CTX_data_pointer_set(result, NULL, &RNA_Operator, op); | ||||
| return CTX_RESULT_OK; | return CTX_RESULT_OK; | ||||
| } | } | ||||
| return CTX_RESULT_NO_DATA; | return CTX_RESULT_NO_DATA; | ||||
| } | } | ||||
| static eContextResult screen_ctx_sel_actions_impl(const bContext *C, | static eContextResult screen_ctx_sel_actions_impl(const bContext *C, | ||||
| bContextDataResult *result, | bContextDataResult *result, | ||||
| bool active_only, | |||||
| bool editable) | bool editable) | ||||
| { | { | ||||
| bAnimContext ac; | bAnimContext ac; | ||||
| if (ANIM_animdata_get_context(C, &ac) && ELEM(ac.spacetype, SPACE_ACTION, SPACE_GRAPH)) { | 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. */ | /* In the Action and Shape Key editor always use the action field at the top. */ | ||||
| if (ac.spacetype == SPACE_ACTION) { | if (ac.spacetype == SPACE_ACTION) { | ||||
| SpaceAction *saction = (SpaceAction *)ac.sl; | SpaceAction *saction = (SpaceAction *)ac.sl; | ||||
| if (ELEM(saction->mode, SACTCONT_ACTION, SACTCONT_SHAPEKEY)) { | if (ELEM(saction->mode, SACTCONT_ACTION, SACTCONT_SHAPEKEY)) { | ||||
| if (active_only) { | |||||
| CTX_data_id_pointer_set(result, (ID *)saction->action); | |||||
| } | |||||
| else { | |||||
| if (saction->action && !(editable && ID_IS_LINKED(saction->action))) { | if (saction->action && !(editable && ID_IS_LINKED(saction->action))) { | ||||
| CTX_data_id_list_add(result, &saction->action->id); | CTX_data_id_list_add(result, &saction->action->id); | ||||
| } | } | ||||
| CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION); | CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION); | ||||
| } | |||||
| return CTX_RESULT_OK; | return CTX_RESULT_OK; | ||||
| } | } | ||||
| } | } | ||||
| /* Search for selected animation data items. */ | /* Search for selected animation data items. */ | ||||
| ListBase anim_data = {NULL, NULL}; | ListBase anim_data = {NULL, NULL}; | ||||
| int filter = ANIMFILTER_DATA_VISIBLE; | int filter = ANIMFILTER_DATA_VISIBLE; | ||||
| bool check_selected = false; | bool check_selected = false; | ||||
| switch (ac.spacetype) { | switch (ac.spacetype) { | ||||
| case SPACE_GRAPH: | case SPACE_GRAPH: | ||||
| filter |= ANIMFILTER_FCURVESONLY | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_SEL; | filter |= ANIMFILTER_FCURVESONLY | ANIMFILTER_CURVE_VISIBLE | | ||||
| (active_only ? ANIMFILTER_ACTIVE : ANIMFILTER_SEL); | |||||
| break; | break; | ||||
| case SPACE_ACTION: | case SPACE_ACTION: | ||||
| filter |= ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS; | filter |= ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS; | ||||
| check_selected = true; | check_selected = true; | ||||
| break; | break; | ||||
| } | } | ||||
| ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); | ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); | ||||
| GSet *seen_set = BLI_gset_ptr_new("seen actions"); | GSet *seen_set = active_only ? NULL : BLI_gset_ptr_new("seen actions"); | ||||
| LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) { | LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) { | ||||
| /* In dopesheet check selection status of individual items, skipping | /* In dopesheet check selection status of individual items, skipping | ||||
| * if not selected or has no selection flag. This is needed so that | * if not selected or has no selection flag. This is needed so that | ||||
| * selecting action or group rows without any channels works. */ | * selecting action or group rows without any channels works. */ | ||||
| if (check_selected && ANIM_channel_setting_get(&ac, ale, ACHANNEL_SETTING_SELECT) <= 0) { | if (check_selected && ANIM_channel_setting_get(&ac, ale, ACHANNEL_SETTING_SELECT) <= 0) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| bAction *action = ANIM_channel_action_get(ale); | bAction *action = ANIM_channel_action_get(ale); | ||||
| if (action) { | if (action) { | ||||
| if (active_only) { | |||||
| CTX_data_id_pointer_set(result, (ID *)action); | |||||
| break; | |||||
| } | |||||
| else { | |||||
| if (editable && ID_IS_LINKED(action)) { | if (editable && ID_IS_LINKED(action)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| /* Add the action to the output list if not already added. */ | /* Add the action to the output list if not already added. */ | ||||
| if (BLI_gset_add(seen_set, action)) { | if (BLI_gset_add(seen_set, action)) { | ||||
| CTX_data_id_list_add(result, &action->id); | CTX_data_id_list_add(result, &action->id); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | |||||
| BLI_gset_free(seen_set, NULL); | |||||
| ANIM_animdata_freelist(&anim_data); | ANIM_animdata_freelist(&anim_data); | ||||
| if (!active_only) { | |||||
| BLI_gset_free(seen_set, NULL); | |||||
| CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION); | CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION); | ||||
| } | |||||
| return CTX_RESULT_OK; | return CTX_RESULT_OK; | ||||
| } | } | ||||
| return CTX_RESULT_NO_DATA; | return CTX_RESULT_NO_DATA; | ||||
| } | } | ||||
| static eContextResult screen_ctx_active_action(const bContext *C, bContextDataResult *result) | |||||
| { | |||||
| return screen_ctx_sel_actions_impl(C, result, true, false); | |||||
| } | |||||
| static eContextResult screen_ctx_selected_visible_actions(const bContext *C, | static eContextResult screen_ctx_selected_visible_actions(const bContext *C, | ||||
| bContextDataResult *result) | bContextDataResult *result) | ||||
| { | { | ||||
| return screen_ctx_sel_actions_impl(C, result, false); | return screen_ctx_sel_actions_impl(C, result, false, false); | ||||
| } | } | ||||
| static eContextResult screen_ctx_selected_editable_actions(const bContext *C, | static eContextResult screen_ctx_selected_editable_actions(const bContext *C, | ||||
| bContextDataResult *result) | bContextDataResult *result) | ||||
| { | { | ||||
| return screen_ctx_sel_actions_impl(C, result, true); | return screen_ctx_sel_actions_impl(C, result, false, true); | ||||
| } | } | ||||
| static eContextResult screen_ctx_sel_edit_fcurves_(const bContext *C, | static eContextResult screen_ctx_sel_edit_fcurves_(const bContext *C, | ||||
| bContextDataResult *result, | bContextDataResult *result, | ||||
| const int extra_filter) | const int extra_filter) | ||||
| { | { | ||||
| bAnimContext ac; | bAnimContext ac; | ||||
| if (ANIM_animdata_get_context(C, &ac) && ELEM(ac.spacetype, SPACE_ACTION, SPACE_GRAPH)) { | if (ANIM_animdata_get_context(C, &ac) && ELEM(ac.spacetype, SPACE_ACTION, SPACE_GRAPH)) { | ||||
| ListBase anim_data = {NULL, NULL}; | ListBase anim_data = {NULL, NULL}; | ||||
| ▲ Show 20 Lines • Show All 197 Lines • ▼ Show 20 Lines | static void ensure_ed_screen_context_functions(void) | ||||
| register_context_function("annotation_data_owner", screen_ctx_annotation_data_owner); | register_context_function("annotation_data_owner", screen_ctx_annotation_data_owner); | ||||
| register_context_function("active_gpencil_layer", screen_ctx_active_gpencil_layer); | register_context_function("active_gpencil_layer", screen_ctx_active_gpencil_layer); | ||||
| register_context_function("active_annotation_layer", screen_ctx_active_annotation_layer); | register_context_function("active_annotation_layer", screen_ctx_active_annotation_layer); | ||||
| register_context_function("active_gpencil_frame", screen_ctx_active_gpencil_frame); | register_context_function("active_gpencil_frame", screen_ctx_active_gpencil_frame); | ||||
| register_context_function("visible_gpencil_layers", screen_ctx_visible_gpencil_layers); | register_context_function("visible_gpencil_layers", screen_ctx_visible_gpencil_layers); | ||||
| register_context_function("editable_gpencil_layers", screen_ctx_editable_gpencil_layers); | 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("editable_gpencil_strokes", screen_ctx_editable_gpencil_strokes); | ||||
| register_context_function("active_operator", screen_ctx_active_operator); | register_context_function("active_operator", screen_ctx_active_operator); | ||||
| register_context_function("active_action", screen_ctx_active_action); | |||||
| register_context_function("selected_visible_actions", screen_ctx_selected_visible_actions); | 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("selected_editable_actions", screen_ctx_selected_editable_actions); | ||||
| register_context_function("editable_fcurves", screen_ctx_editable_fcurves); | register_context_function("editable_fcurves", screen_ctx_editable_fcurves); | ||||
| register_context_function("visible_fcurves", screen_ctx_visible_fcurves); | register_context_function("visible_fcurves", screen_ctx_visible_fcurves); | ||||
| register_context_function("selected_editable_fcurves", screen_ctx_selected_editable_fcurves); | register_context_function("selected_editable_fcurves", screen_ctx_selected_editable_fcurves); | ||||
| register_context_function("selected_visible_fcurves", screen_ctx_selected_visible_fcurves); | register_context_function("selected_visible_fcurves", screen_ctx_selected_visible_fcurves); | ||||
| register_context_function("active_editable_fcurve", screen_ctx_active_editable_fcurve); | register_context_function("active_editable_fcurve", screen_ctx_active_editable_fcurve); | ||||
| register_context_function("selected_editable_keyframes", screen_ctx_selected_editable_keyframes); | register_context_function("selected_editable_keyframes", screen_ctx_selected_editable_keyframes); | ||||
| Show All 19 Lines | |||||