Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/screen/screen_context.c
| Show All 13 Lines | |||||
| #include "DNA_anim_types.h" | #include "DNA_anim_types.h" | ||||
| #include "DNA_armature_types.h" | #include "DNA_armature_types.h" | ||||
| #include "DNA_gpencil_types.h" | #include "DNA_gpencil_types.h" | ||||
| #include "DNA_object_types.h" | #include "DNA_object_types.h" | ||||
| #include "DNA_scene_types.h" | #include "DNA_scene_types.h" | ||||
| #include "DNA_screen_types.h" | #include "DNA_screen_types.h" | ||||
| #include "DNA_sequence_types.h" | #include "DNA_sequence_types.h" | ||||
| #include "DNA_space_types.h" | #include "DNA_space_types.h" | ||||
| #include "DNA_video_edit_types.h" | |||||
| #include "DNA_windowmanager_types.h" | #include "DNA_windowmanager_types.h" | ||||
| #include "DNA_workspace_types.h" | #include "DNA_workspace_types.h" | ||||
| #include "BLI_ghash.h" | #include "BLI_ghash.h" | ||||
| #include "BLI_listbase.h" | #include "BLI_listbase.h" | ||||
| #include "BLI_utildefines.h" | #include "BLI_utildefines.h" | ||||
| #include "BKE_action.h" | #include "BKE_action.h" | ||||
| Show All 20 Lines | |||||
| #include "UI_interface.h" | #include "UI_interface.h" | ||||
| #include "WM_api.h" | #include "WM_api.h" | ||||
| #include "screen_intern.h" | #include "screen_intern.h" | ||||
| const char *screen_context_dir[] = { | const char *screen_context_dir[] = { | ||||
| "scene", | "scene", | ||||
| "video_edit", | |||||
| "view_layer", | "view_layer", | ||||
| "visible_objects", | "visible_objects", | ||||
| "selectable_objects", | "selectable_objects", | ||||
| "selected_objects", | "selected_objects", | ||||
| "editable_objects", | "editable_objects", | ||||
| "selected_editable_objects", | "selected_editable_objects", | ||||
| "objects_in_mode", | "objects_in_mode", | ||||
| "objects_in_mode_unique_data", | "objects_in_mode_unique_data", | ||||
| ▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | |||||
| static eContextResult screen_ctx_scene(const bContext *C, bContextDataResult *result) | static eContextResult screen_ctx_scene(const bContext *C, bContextDataResult *result) | ||||
| { | { | ||||
| wmWindow *win = CTX_wm_window(C); | wmWindow *win = CTX_wm_window(C); | ||||
| Scene *scene = WM_window_get_active_scene(win); | Scene *scene = WM_window_get_active_scene(win); | ||||
| CTX_data_id_pointer_set(result, &scene->id); | CTX_data_id_pointer_set(result, &scene->id); | ||||
| return CTX_RESULT_OK; | return CTX_RESULT_OK; | ||||
| } | } | ||||
| static eContextResult screen_ctx_video_edit(const bContext *C, bContextDataResult *result) | |||||
| { | |||||
| wmWindow *win = CTX_wm_window(C); | |||||
| VideoEdit *video_edit = WM_window_get_active_video_edit(win); | |||||
| CTX_data_id_pointer_set(result, &video_edit->id); | |||||
| return CTX_RESULT_OK; | |||||
| } | |||||
| static eContextResult screen_ctx_visible_objects(const bContext *C, bContextDataResult *result) | static eContextResult screen_ctx_visible_objects(const bContext *C, bContextDataResult *result) | ||||
| { | { | ||||
| wmWindow *win = CTX_wm_window(C); | wmWindow *win = CTX_wm_window(C); | ||||
| View3D *v3d = CTX_wm_view3d(C); /* This may be NULL in a lot of cases. */ | View3D *v3d = CTX_wm_view3d(C); /* This may be NULL in a lot of cases. */ | ||||
| Scene *scene = WM_window_get_active_scene(win); | Scene *scene = WM_window_get_active_scene(win); | ||||
| ViewLayer *view_layer = WM_window_get_active_view_layer(win); | ViewLayer *view_layer = WM_window_get_active_view_layer(win); | ||||
| BKE_view_layer_synced_ensure(scene, view_layer); | BKE_view_layer_synced_ensure(scene, view_layer); | ||||
| ▲ Show 20 Lines • Show All 508 Lines • ▼ Show 20 Lines | if (obpose) { | ||||
| CTX_data_id_pointer_set(result, &obpose->id); | CTX_data_id_pointer_set(result, &obpose->id); | ||||
| } | } | ||||
| return CTX_RESULT_OK; | return CTX_RESULT_OK; | ||||
| } | } | ||||
| static eContextResult screen_ctx_active_sequence_strip(const bContext *C, | static eContextResult screen_ctx_active_sequence_strip(const bContext *C, | ||||
| bContextDataResult *result) | bContextDataResult *result) | ||||
| { | { | ||||
| wmWindow *win = CTX_wm_window(C); | wmWindow *win = CTX_wm_window(C); | ||||
| Scene *scene = WM_window_get_active_scene(win); | VideoEdit *video_edit = WM_window_get_active_video_edit(win); | ||||
| Sequence *seq = SEQ_select_active_get(scene); | Sequence *seq = SEQ_select_active_get(video_edit); | ||||
| if (seq) { | if (seq) { | ||||
| CTX_data_pointer_set(result, &scene->id, &RNA_Sequence, seq); | CTX_data_pointer_set(result, &video_edit->id, &RNA_Sequence, seq); | ||||
| return CTX_RESULT_OK; | return CTX_RESULT_OK; | ||||
| } | } | ||||
| return CTX_RESULT_NO_DATA; | return CTX_RESULT_NO_DATA; | ||||
| } | } | ||||
| static eContextResult screen_ctx_sequences(const bContext *C, bContextDataResult *result) | static eContextResult screen_ctx_sequences(const bContext *C, bContextDataResult *result) | ||||
| { | { | ||||
| wmWindow *win = CTX_wm_window(C); | wmWindow *win = CTX_wm_window(C); | ||||
| Scene *scene = WM_window_get_active_scene(win); | VideoEdit *video_edit = WM_window_get_active_video_edit(win); | ||||
| Editing *ed = SEQ_editing_get(scene); | if (video_edit) { | ||||
| if (ed) { | LISTBASE_FOREACH (Sequence *, seq, video_edit->seqbasep) { | ||||
| LISTBASE_FOREACH (Sequence *, seq, ed->seqbasep) { | CTX_data_list_add(result, &video_edit->id, &RNA_Sequence, seq); | ||||
| CTX_data_list_add(result, &scene->id, &RNA_Sequence, seq); | |||||
| } | } | ||||
| 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_selected_sequences(const bContext *C, bContextDataResult *result) | static eContextResult screen_ctx_selected_sequences(const bContext *C, bContextDataResult *result) | ||||
| { | { | ||||
| wmWindow *win = CTX_wm_window(C); | wmWindow *win = CTX_wm_window(C); | ||||
| Scene *scene = WM_window_get_active_scene(win); | VideoEdit *video_edit = WM_window_get_active_video_edit(win); | ||||
| Editing *ed = SEQ_editing_get(scene); | if (video_edit) { | ||||
| if (ed) { | LISTBASE_FOREACH (Sequence *, seq, video_edit->seqbasep) { | ||||
| LISTBASE_FOREACH (Sequence *, seq, ed->seqbasep) { | |||||
| if (seq->flag & SELECT) { | if (seq->flag & SELECT) { | ||||
| CTX_data_list_add(result, &scene->id, &RNA_Sequence, seq); | CTX_data_list_add(result, &video_edit->id, &RNA_Sequence, seq); | ||||
| } | } | ||||
| } | } | ||||
| 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_selected_editable_sequences(const bContext *C, | static eContextResult screen_ctx_selected_editable_sequences(const bContext *C, | ||||
| bContextDataResult *result) | bContextDataResult *result) | ||||
| { | { | ||||
| wmWindow *win = CTX_wm_window(C); | wmWindow *win = CTX_wm_window(C); | ||||
| Scene *scene = WM_window_get_active_scene(win); | VideoEdit *video_edit = WM_window_get_active_video_edit(win); | ||||
| Editing *ed = SEQ_editing_get(scene); | if (video_edit == NULL) { | ||||
| if (ed == NULL) { | |||||
| return CTX_RESULT_NO_DATA; | return CTX_RESULT_NO_DATA; | ||||
| } | } | ||||
| ListBase *channels = SEQ_channels_displayed_get(ed); | ListBase *channels = SEQ_channels_displayed_get(video_edit); | ||||
| LISTBASE_FOREACH (Sequence *, seq, ed->seqbasep) { | LISTBASE_FOREACH (Sequence *, seq, video_edit->seqbasep) { | ||||
| if (seq->flag & SELECT && !SEQ_transform_is_locked(channels, seq)) { | if (seq->flag & SELECT && !SEQ_transform_is_locked(channels, seq)) { | ||||
| CTX_data_list_add(result, &scene->id, &RNA_Sequence, seq); | CTX_data_list_add(result, &video_edit->id, &RNA_Sequence, seq); | ||||
| } | } | ||||
| } | } | ||||
| 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; | ||||
| } | } | ||||
| static eContextResult screen_ctx_active_nla_track(const bContext *C, bContextDataResult *result) | static eContextResult screen_ctx_active_nla_track(const bContext *C, bContextDataResult *result) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 578 Lines • ▼ Show 20 Lines | static void ensure_ed_screen_context_functions(void) | ||||
| /* Murmur hash is faster for smaller strings (according to BLI_hash_mm2). */ | /* Murmur hash is faster for smaller strings (according to BLI_hash_mm2). */ | ||||
| ed_screen_context_functions = BLI_ghash_new( | ed_screen_context_functions = BLI_ghash_new( | ||||
| BLI_ghashutil_strhash_p_murmur, BLI_ghashutil_strcmp, __func__); | BLI_ghashutil_strhash_p_murmur, BLI_ghashutil_strcmp, __func__); | ||||
| BKE_blender_atexit_register(free_context_function_ghash, NULL); | BKE_blender_atexit_register(free_context_function_ghash, NULL); | ||||
| register_context_function("scene", screen_ctx_scene); | register_context_function("scene", screen_ctx_scene); | ||||
| register_context_function("video_edit", screen_ctx_video_edit); | |||||
| register_context_function("visible_objects", screen_ctx_visible_objects); | register_context_function("visible_objects", screen_ctx_visible_objects); | ||||
| register_context_function("selectable_objects", screen_ctx_selectable_objects); | register_context_function("selectable_objects", screen_ctx_selectable_objects); | ||||
| register_context_function("selected_objects", screen_ctx_selected_objects); | register_context_function("selected_objects", screen_ctx_selected_objects); | ||||
| register_context_function("selected_editable_objects", screen_ctx_selected_editable_objects); | register_context_function("selected_editable_objects", screen_ctx_selected_editable_objects); | ||||
| register_context_function("editable_objects", screen_ctx_editable_objects); | register_context_function("editable_objects", screen_ctx_editable_objects); | ||||
| register_context_function("objects_in_mode", screen_ctx_objects_in_mode); | register_context_function("objects_in_mode", screen_ctx_objects_in_mode); | ||||
| register_context_function("objects_in_mode_unique_data", screen_ctx_objects_in_mode_unique_data); | register_context_function("objects_in_mode_unique_data", screen_ctx_objects_in_mode_unique_data); | ||||
| register_context_function("visible_bones", screen_ctx_visible_bones); | register_context_function("visible_bones", screen_ctx_visible_bones); | ||||
| ▲ Show 20 Lines • Show All 65 Lines • Show Last 20 Lines | |||||