Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/scene/scene_edit.c
| /* SPDX-License-Identifier: GPL-2.0-or-later */ | /* SPDX-License-Identifier: GPL-2.0-or-later */ | ||||
| /** \file | /** \file | ||||
| * \ingroup edscene | * \ingroup edscene | ||||
| */ | */ | ||||
| #include <stdio.h> | #include <stdio.h> | ||||
| #include <string.h> | #include <string.h> | ||||
| #include "BLI_compiler_attrs.h" | #include "BLI_compiler_attrs.h" | ||||
| #include "BLI_listbase.h" | #include "BLI_listbase.h" | ||||
| #include "BLI_string.h" | #include "BLI_string.h" | ||||
| #include "DNA_sequence_types.h" | #include "DNA_sequence_types.h" | ||||
| #include "DNA_video_edit_types.h" | |||||
| #include "BKE_context.h" | #include "BKE_context.h" | ||||
| #include "BKE_global.h" | #include "BKE_global.h" | ||||
| #include "BKE_layer.h" | #include "BKE_layer.h" | ||||
| #include "BKE_lib_id.h" | #include "BKE_lib_id.h" | ||||
| #include "BKE_main.h" | #include "BKE_main.h" | ||||
| #include "BKE_node.h" | #include "BKE_node.h" | ||||
| #include "BKE_report.h" | #include "BKE_report.h" | ||||
| ▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | |||||
| /** Add a new scene in the sequence editor. */ | /** Add a new scene in the sequence editor. */ | ||||
| Scene *ED_scene_sequencer_add(Main *bmain, | Scene *ED_scene_sequencer_add(Main *bmain, | ||||
| bContext *C, | bContext *C, | ||||
| eSceneCopyMethod method, | eSceneCopyMethod method, | ||||
| const bool assign_strip) | const bool assign_strip) | ||||
| { | { | ||||
| Sequence *seq = NULL; | Sequence *seq = NULL; | ||||
| Scene *scene_active = CTX_data_scene(C); | |||||
| Scene *scene_strip = NULL; | Scene *scene_strip = NULL; | ||||
| /* Sequencer need to use as base the scene defined in the strip, not the main scene. */ | /* Sequencer need to use as base the scene defined in the strip, not the main scene. */ | ||||
| Editing *ed = scene_active->ed; | VideoEdit *video_edit = CTX_data_video_edit(C); | ||||
| if (ed) { | if (video_edit) { | ||||
| seq = ed->act_seq; | seq = video_edit->act_seq; | ||||
| if (seq && seq->scene) { | if (seq && seq->scene) { | ||||
| scene_strip = seq->scene; | scene_strip = seq->scene; | ||||
| } | } | ||||
| } | } | ||||
| /* If no scene assigned to the strip, only NEW scene mode is logic. */ | /* If no scene assigned to the strip, only NEW scene mode is logic. */ | ||||
| if (scene_strip == NULL) { | if (scene_strip == NULL) { | ||||
| method = SCE_COPY_NEW; | method = SCE_COPY_NEW; | ||||
| } | } | ||||
| Scene *scene_new = scene_add(bmain, scene_strip, method); | Scene *scene_new = scene_add(bmain, scene_strip, method); | ||||
| /* If don't need assign the scene to the strip, nothing else to do. */ | /* If don't need assign the scene to the strip, nothing else to do. */ | ||||
| if (!assign_strip) { | if (!assign_strip) { | ||||
| return scene_new; | return scene_new; | ||||
| } | } | ||||
| /* As the scene is created in sequencer, do not set the new scene as active. | /* As the scene is created in sequencer, do not set the new scene as active. | ||||
| * This is useful for story-boarding where we want to keep actual scene active. | * This is useful for story-boarding where we want to keep actual scene active. | ||||
| * The new scene is linked to the active strip and the viewport updated. */ | * The new scene is linked to the active strip and the viewport updated. */ | ||||
| if (scene_new && seq) { | if (scene_new && seq) { | ||||
| seq->scene = scene_new; | seq->scene = scene_new; | ||||
| /* Do a refresh of the sequencer data. */ | /* Do a refresh of the sequencer data. */ | ||||
| SEQ_relations_invalidate_cache_raw(scene_active, seq); | SEQ_relations_invalidate_cache_raw(video_edit, seq); | ||||
| DEG_id_tag_update(&scene_active->id, ID_RECALC_AUDIO | ID_RECALC_SEQUENCER_STRIPS); | /** FIXME: Makse sure this works. */ | ||||
| DEG_id_tag_update(&video_edit->id, ID_RECALC_AUDIO | ID_RECALC_SEQUENCER_STRIPS); | |||||
| DEG_relations_tag_update(bmain); | DEG_relations_tag_update(bmain); | ||||
| } | } | ||||
| WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene_active); | WM_event_add_notifier(C, NC_VIDEO_EDIT | ND_SEQUENCER, video_edit); | ||||
| WM_event_add_notifier(C, NC_SCENE | ND_SCENEBROWSE, scene_active); | WM_event_add_notifier(C, NC_VIDEO_EDIT | ND_SCENEBROWSE, video_edit); | ||||
| return scene_new; | return scene_new; | ||||
| } | } | ||||
| Scene *ED_scene_add(Main *bmain, bContext *C, wmWindow *win, eSceneCopyMethod method) | Scene *ED_scene_add(Main *bmain, bContext *C, wmWindow *win, eSceneCopyMethod method) | ||||
| { | { | ||||
| Scene *scene_old = WM_window_get_active_scene(win); | Scene *scene_old = WM_window_get_active_scene(win); | ||||
| Scene *scene_new = scene_add(bmain, scene_old, method); | Scene *scene_new = scene_add(bmain, scene_old, method); | ||||
| ▲ Show 20 Lines • Show All 184 Lines • ▼ Show 20 Lines | if (ED_scene_sequencer_add(bmain, C, type, true) == NULL) { | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| static bool scene_new_sequencer_poll(bContext *C) | static bool scene_new_sequencer_poll(bContext *C) | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | VideoEdit *video_edit = CTX_data_video_edit(C); | ||||
| const Sequence *seq = SEQ_select_active_get(scene); | const Sequence *seq = SEQ_select_active_get(video_edit); | ||||
| return (seq && (seq->type == SEQ_TYPE_SCENE)); | return (seq && (seq->type == SEQ_TYPE_SCENE)); | ||||
| } | } | ||||
| static const EnumPropertyItem *scene_new_sequencer_enum_itemf(bContext *C, | static const EnumPropertyItem *scene_new_sequencer_enum_itemf(bContext *C, | ||||
| PointerRNA *UNUSED(ptr), | PointerRNA *UNUSED(ptr), | ||||
| PropertyRNA *UNUSED(prop), | PropertyRNA *UNUSED(prop), | ||||
| bool *r_free) | bool *r_free) | ||||
| { | { | ||||
| EnumPropertyItem *item = NULL; | EnumPropertyItem *item = NULL; | ||||
| int totitem = 0; | int totitem = 0; | ||||
| uint item_index; | uint item_index; | ||||
| item_index = RNA_enum_from_value(scene_new_items, SCE_COPY_NEW); | item_index = RNA_enum_from_value(scene_new_items, SCE_COPY_NEW); | ||||
| RNA_enum_item_add(&item, &totitem, &scene_new_items[item_index]); | RNA_enum_item_add(&item, &totitem, &scene_new_items[item_index]); | ||||
| bool has_scene_or_no_context = false; | bool has_scene_or_no_context = false; | ||||
| if (C == NULL) { | if (C == NULL) { | ||||
| /* For documentation generation. */ | /* For documentation generation. */ | ||||
| has_scene_or_no_context = true; | has_scene_or_no_context = true; | ||||
| } | } | ||||
| else { | else { | ||||
| Scene *scene = CTX_data_scene(C); | VideoEdit *video_edit = CTX_data_video_edit(C); | ||||
| Sequence *seq = SEQ_select_active_get(scene); | Sequence *seq = SEQ_select_active_get(video_edit); | ||||
| if (seq && (seq->type == SEQ_TYPE_SCENE) && (seq->scene != NULL)) { | if (seq && (seq->type == SEQ_TYPE_SCENE) && (seq->scene != NULL)) { | ||||
| has_scene_or_no_context = true; | has_scene_or_no_context = true; | ||||
| } | } | ||||
| } | } | ||||
| if (has_scene_or_no_context) { | if (has_scene_or_no_context) { | ||||
| int values[] = {SCE_COPY_EMPTY, SCE_COPY_LINK_COLLECTION, SCE_COPY_FULL}; | int values[] = {SCE_COPY_EMPTY, SCE_COPY_LINK_COLLECTION, SCE_COPY_FULL}; | ||||
| for (int i = 0; i < ARRAY_SIZE(values); i++) { | for (int i = 0; i < ARRAY_SIZE(values); i++) { | ||||
| ▲ Show 20 Lines • Show All 91 Lines • Show Last 20 Lines | |||||