Blender V5.3
sequencer_add.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <cctype>
10#include <cstdlib>
11#include <cstring>
12
14
15#include "DNA_sequence_types.h"
16#include "DNA_sound_types.h"
17#include "MEM_guardedalloc.h"
18
19#include "BLI_fileops.hh"
20#include "BLI_listbase.hh"
21#include "BLI_math_base_c.hh"
22#include "BLI_path_utils.hh"
23#include "BLI_string.hh"
24#include "BLI_string_ref.hh"
25#include "BLI_string_utf8.hh"
26#include "BLI_utildefines.hh"
27
28#include "BLT_translation.hh"
29
30#include "DNA_scene_types.h"
31#include "DNA_space_types.h"
32
33#include "BKE_context.hh"
34#include "BKE_global.hh"
35#include "BKE_image.hh"
36#include "BKE_lib_id.hh"
37#include "BKE_main.hh"
38#include "BKE_report.hh"
39#include "BKE_scene.hh"
40#include "BKE_sound.hh"
41
42#include "IMB_imbuf_enums.h"
43#include "IMB_imbuf_types.hh"
44
45#include "MOV_read.hh"
46
47#include "SEQ_channels.hh"
48#include "SEQ_retiming.hh"
49#include "WM_api.hh"
50#include "WM_types.hh"
51
52#include "RNA_define.hh"
53#include "RNA_enum_types.hh"
54#include "RNA_prototypes.hh"
55
56#include "SEQ_add.hh"
57#include "SEQ_connect.hh"
58#include "SEQ_effects.hh"
59#include "SEQ_proxy.hh"
60#include "SEQ_select.hh"
61#include "SEQ_sequencer.hh"
62#include "SEQ_transform.hh"
63
64#include "ED_asset.hh"
66#include "ED_image.hh"
67#include "ED_scene.hh"
68#include "ED_screen.hh"
69#include "ED_sequencer.hh"
70#include "ED_time_scrub_ui.hh"
71
72#include "UI_interface.hh"
74#include "UI_view2d.hh"
75
76#include "DEG_depsgraph.hh"
78
79#include "sequencer_intern.hh"
80
81namespace blender::ed::vse {
82
87
88enum class ImageImport {
90 Sequence,
92};
93
96 "DETECT",
97 0,
98 "Auto Detect",
99 "Add images as individual strips, unless their filenames match Blender's numbered sequence "
100 "pattern, in which case they are grouped into a single image sequence"},
102 "SEQUENCE",
103 0,
104 "Image Sequence",
105 "Import all selected images as a single image sequence. The sequence of images does not have "
106 "to match Blender's numbered sequence pattern, so placeholders cannot be inferred"},
108 "INDIVIDUAL",
109 0,
110 "Individual Images",
111 "Add each selected image as an individual strip"},
112 {0, nullptr, 0, nullptr, nullptr},
113};
114
115/* Avoid passing multiple args and be more verbose. */
116#define SEQPROP_STARTFRAME (1 << 0)
117/* For image and effect strips only. */
118#define SEQPROP_LENGTH (1 << 1)
119/* Sets filepath or directory properties to active strip media directory to seed the file browser.
120 * If used, asserts that this is not a drag and drop operation. */
121#define SEQPROP_PATHS (1 << 2)
122/* Skips guessing channel for effect strips only. */
123#define SEQPROP_NOCHAN (1 << 3)
124#define SEQPROP_FIT_METHOD (1 << 4)
125#define SEQPROP_VIEW_TRANSFORM (1 << 5)
126#define SEQPROP_PLAYBACK_RATE (1 << 6)
127#define SEQPROP_MOVE (1 << 7)
128
129/* -------------------------------------------------------------------- */
132
133static bool is_drag_and_drop(const wmOperator *op, const wmEvent *event)
134{
135 if (event != nullptr && event->type == EVT_DROP) {
136 return true;
137 }
138 /* WARNING: foot-gun! Dragging and dropping *multiple* files will not emit `EVT_DROP`,
139 * so we can't check for that alone. */
140 return (RNA_struct_property_is_set(op->ptr, "files") &&
141 !RNA_collection_is_empty(op->ptr, "files")) ||
142 RNA_struct_property_is_set(op->ptr, "filepath");
143}
144
145static void sequencer_add_init(bContext * /*C*/, wmOperator *op)
146{
147 op->customdata = MEM_new<SequencerAddData>(__func__);
148}
149
150static void sequencer_add_free(bContext * /*C*/, wmOperator *op)
151{
152 if (op->customdata) {
153 SequencerAddData *sad = static_cast<SequencerAddData *>(op->customdata);
154 MEM_delete(sad);
155 op->customdata = nullptr;
156 }
157}
158
159static bool sequencer_add_draw_check_fn(PointerRNA *ptr, PropertyRNA *prop, void * /*user_data*/)
160{
161 const char *prop_id = RNA_property_identifier(prop);
162
163 /* Only show placeholders option if image sequence creation is not forced. */
164 if (STREQ(prop_id, "use_placeholders")) {
165 return ImageImport(RNA_enum_get(ptr, "image_import_type")) == ImageImport::Detect;
166 }
167
168 return !STR_ELEM(prop_id,
169 "filepath",
170 "directory",
171 "filename",
172 "frame_start",
173 "channel",
174 "length",
175 "move_strips_after_add",
176 "replace_sel",
177 "skip_locked_or_muted_channels",
178 "use_sequence_detection");
179}
180
181static void sequencer_add_ui(bContext * /*C*/, wmOperator *op)
182{
183 ui::Layout &layout = *op->layout;
184 SequencerAddData *sad = static_cast<SequencerAddData *>(op->customdata);
185
186 bool is_redo_panel = sad == nullptr;
187
188 if (!is_redo_panel) {
189 layout.prop(op->ptr, "move_strips_after_add", UI_ITEM_NONE, std::nullopt, ICON_NONE);
190 }
191 if (!RNA_boolean_get(op->ptr, "move_strips_after_add") || is_redo_panel) {
192 ui::Layout &col = layout.column(true);
193 col.prop(op->ptr, "frame_start", UI_ITEM_NONE, std::nullopt, ICON_NONE);
194 layout.prop(op->ptr, "channel", UI_ITEM_NONE, std::nullopt, ICON_NONE);
195 layout.prop(op->ptr, "replace_sel", UI_ITEM_NONE, std::nullopt, ICON_NONE);
196 layout.prop(op->ptr, "skip_locked_or_muted_channels", UI_ITEM_NONE, std::nullopt, ICON_NONE);
197 }
198
199 /* Main draw call. */
200 uiDefAutoButsRNA(&layout,
201 op->ptr,
203 nullptr,
204 nullptr,
206 false);
207
208 /* There is no effect strip add UI, so assume an image is being imported if "length" is found. */
209 if (RNA_struct_find_property(op->ptr, "length") &&
210 ImageImport(RNA_enum_get(op->ptr, "image_import_type")) != ImageImport::Sequence)
211 {
212 layout.prop(op->ptr, "length", UI_ITEM_NONE, std::nullopt, ICON_NONE);
213 }
214
215 if (!is_redo_panel && RNA_struct_find_property(op->ptr, "show_multiview")) {
216 layout.separator();
217
218 /* Image template. */
220 nullptr, RNA_ImageFormatSettings, &sad->im_format);
221
222 /* Multiview template. */
223 if (RNA_boolean_get(op->ptr, "show_multiview")) {
224 uiTemplateImageFormatViews(&layout, &imf_ptr, op->ptr);
225 }
226 }
227}
228
230{
231 PropertyRNA *prop;
232
233 if (flag & SEQPROP_MOVE) {
234 prop = RNA_def_boolean(
235 ot->srna,
236 "move_strips_after_add",
237 true,
238 "Move Strips After Add",
239 "Automatically begin translating strips with the mouse after adding them to the timeline");
241 }
242
243 if (flag & SEQPROP_STARTFRAME) {
244 RNA_def_int(ot->srna,
245 "frame_start",
246 0,
247 INT_MIN,
248 INT_MAX,
249 "Start Frame",
250 "Start frame of the strip",
251 -MAXFRAME,
252 MAXFRAME);
253 }
254
255 if (flag & SEQPROP_LENGTH) {
256 /* Not usual since most strips have a predefined length. */
257 RNA_def_int(ot->srna,
258 "length",
259 0,
260 1,
261 INT_MAX,
262 "Length",
263 "Length of the strip in frames, or the length of each strip if multiple are added",
264 1,
265 MAXFRAME);
266 }
267
268 RNA_def_int(ot->srna,
269 "channel",
270 1,
271 1,
273 "Channel",
274 "Channel to place this strip into",
275 1,
277
279 "replace_sel",
280 true,
281 "Replace Selection",
282 "Deselect previously selected strips after add operation completes");
283
284 /* Only for python scripts which import strips and place them after. */
285 prop = RNA_def_boolean(
286 ot->srna, "overlap", false, "Allow Overlap", "Don't correct overlap on new strips");
288
289 prop = RNA_def_enum(
290 ot->srna,
291 "overlap_mode",
294 "Overlap Mode",
295 "How to resolve overlap with existing strips. If unset, fallback to the overlap mode "
296 "from the tool settings, but shuffle vertically instead of horizontally");
298
299 prop = RNA_def_boolean(ot->srna,
300 "skip_locked_or_muted_channels",
301 true,
302 "Skip Locked/Muted Channels",
303 "Make strips occupy nearest unmuted and unlocked channels");
304
305 if (flag & SEQPROP_FIT_METHOD) {
306 ot->prop = RNA_def_enum(ot->srna,
307 "fit_method",
310 "Fit Method",
311 "Mode for fitting the image to the canvas");
312 }
313
314 if (flag & SEQPROP_VIEW_TRANSFORM) {
315 ot->prop = RNA_def_boolean(ot->srna,
316 "set_view_transform",
317 true,
318 "Set View Transform",
319 "Set appropriate view transform based on media color space");
320 }
321
322 if (flag & SEQPROP_PLAYBACK_RATE) {
323 ot->prop = RNA_def_boolean(ot->srna,
324 "adjust_playback_rate",
325 true,
326 "Adjust Playback Rate",
327 "Play at normal speed regardless of scene FPS");
328 }
329}
330
332 wmOperator *op,
333 const char *identifier)
334{
335 if (RNA_struct_find_property(op->ptr, identifier)) {
337 Strip *last_strip = seq::select_active_get(scene);
338 if (last_strip && last_strip->data && STRIP_HAS_PATH(last_strip)) {
339 Main *bmain = CTX_data_main(C);
340 char dirpath[FILE_MAX];
341 STRNCPY(dirpath, last_strip->data->dirpath);
342 BLI_path_abs(dirpath, ID_BLEND_PATH(bmain, &scene->id));
343 RNA_string_set(op->ptr, identifier, dirpath);
344 }
345 }
346}
347
348static int find_unlocked_unmuted_channel(const Editing *ed, int channel_index)
349{
350 const ListBaseT<SeqTimelineChannel> *channels = seq::channels_displayed_get(ed);
351
352 while (channel_index < seq::MAX_CHANNELS) {
353 SeqTimelineChannel *channel = seq::channel_get_by_index(channels, channel_index);
354 if (!channel->is_muted() && !channel->is_locked()) {
355 break;
356 }
357 channel_index++;
358 }
359
360 return channel_index;
361}
362
364{
365 Strip *tgt = nullptr;
368 int timeline_frame = scene->r.cfra;
369 int proximity = INT_MAX;
370
371 if (!ed || !ed->current_strips()) {
372 return 1;
373 }
374
375 for (Strip &strip : *ed->current_strips()) {
376 const int strip_end = strip.right_handle(scene);
377 if (ELEM(type, -1, strip.type) && (strip_end <= timeline_frame) &&
378 (timeline_frame - strip_end < proximity))
379 {
380 tgt = &strip;
381 proximity = timeline_frame - strip_end;
382 }
383 }
384
385 int best_channel = 1;
386 if (tgt) {
387 best_channel = (type == STRIP_TYPE_MOVIE) ? tgt->channel - 1 : tgt->channel;
388 }
389
390 best_channel = find_unlocked_unmuted_channel(ed, best_channel);
391
392 return math::clamp(best_channel, 0, seq::MAX_CHANNELS);
393}
394
396 wmOperator *op,
397 const int needed_channels,
398 const char **r_error_msg)
399{
400 const int channel = RNA_int_get(op->ptr, "channel");
401 const int frame_start = RNA_int_get(op->ptr, "frame_start");
402
403 /* First check simple case - strip is added to very top of timeline. */
404 const int max_channel = seq::MAX_CHANNELS - needed_channels + 1;
405 if (channel > max_channel) {
406 *r_error_msg = RPT_("No available channel for the current frame.");
407 return false;
408 }
409
410 /* When adding strip(s) to lower channels, we must count number of free channels. There can be
411 * gaps. */
412 Set<int> used_channels;
413 for (Strip *strip : all_strips_from_context(C)) {
414 if (strip->intersects_frame(CTX_data_sequencer_scene(C), frame_start)) {
415 used_channels.add(strip->channel);
416 }
417 }
418
419 int free_channels = 0;
420 for (int i : IndexRange(channel, seq::MAX_CHANNELS - channel + 1)) {
421 if (!used_channels.contains(i)) {
422 free_channels++;
423 }
424 if (free_channels == needed_channels) {
425 return true;
426 }
427 }
428
429 *r_error_msg = RPT_("No available channel for the current frame.");
430 return false;
431}
432
433/* Sets `channel` and `frame_start` properties when the operator is likely to have been invoked
434 * with drag-and-drop data. */
436 wmOperator *op,
437 const wmEvent *event)
438{
439 BLI_assert(is_drag_and_drop(op, event));
440
441 if (RNA_struct_property_is_set(op->ptr, "channel") ||
442 RNA_struct_property_is_set(op->ptr, "frame_start"))
443 {
444 return;
445 }
446
447 ARegion *region = CTX_wm_region(C);
448 if (!region || region->regiontype != RGN_TYPE_WINDOW) {
449 return;
450 }
451
452 float frame_start, channel;
453 ui::view2d_region_to_view(&region->v2d, event->mval[0], event->mval[1], &frame_start, &channel);
454 RNA_int_set(op->ptr, "channel", int(channel));
455 RNA_int_set(op->ptr, "frame_start", int(frame_start));
456}
457
459{
460 SequencerAddData *sad = static_cast<SequencerAddData *>(op->customdata);
461 if (sad == nullptr) {
462 return false;
463 }
464 return sad->is_drop_event;
465}
466
468{
469 PropertyRNA *prop = RNA_struct_find_property(op->ptr, "move_strips_after_add");
470
471 return prop != nullptr && RNA_property_boolean_get(op->ptr, prop) &&
472 (op->flag & OP_IS_REPEAT) == 0 && !op_invoked_by_drop_event(op);
473}
474
476 bContext *C, wmOperator *op, int flag, int type, const wmEvent *event)
477{
479
480 const bool is_drop = is_drag_and_drop(op, event);
481 const int current_frame = scene->r.cfra;
482 if (event != nullptr && is_drop) {
483 SequencerAddData *sad = static_cast<SequencerAddData *>(op->customdata);
484 BLI_assert_msg(sad != nullptr,
485 "Drag and drop code must call 'sequencer_add_init' and 'sequencer_add_free'");
486 sad->is_drop_event = true;
488 }
489
490 /* Effect strips shouldn't have their channel guessed. Instead,
491 * it will be set to the first free channel above the input strips. */
492 if (!(flag & SEQPROP_NOCHAN) && !RNA_struct_property_is_set(op->ptr, "channel")) {
494 }
495
496 if (!RNA_struct_property_is_set(op->ptr, "frame_start")) {
497 RNA_int_set(op->ptr, "frame_start", current_frame);
498 }
499
500 if ((flag & SEQPROP_LENGTH) && !RNA_struct_property_is_set(op->ptr, "length")) {
501 RNA_int_set(op->ptr, "length", seq::default_strip_length(scene->frames_per_second()));
502 }
503
504 if (flag & SEQPROP_PATHS) {
505 BLI_assert(!is_drop);
508 }
509}
510
512{
514 return;
515 }
516
517 wmOperatorType *ot = WM_operatortype_find("TRANSFORM_OT_seq_slide", true);
519 RNA_boolean_set(&ptr, "remove_on_cancel", true);
520 RNA_boolean_set(&ptr, "view2d_edge_pan", true);
521 RNA_boolean_set(&ptr, "release_confirm", false);
524}
525
527{
528 const Main *bmain = CTX_data_main(C);
529 const ARegion *region = CTX_wm_region(C);
530
531 memset(load_data, 0, sizeof(seq::LoadData));
532
533 load_data->start_frame = RNA_int_get(op->ptr, "frame_start");
534 load_data->channel = RNA_int_get(op->ptr, "channel");
535 load_data->image.length = 1;
536 load_data->image.count = 1;
537
538 PropertyRNA *prop;
539 if ((prop = RNA_struct_find_property(op->ptr, "fit_method"))) {
540 load_data->fit_method = eSeqImageFitMethod(RNA_enum_get(op->ptr, "fit_method"));
542 }
543
544 if ((prop = RNA_struct_find_property(op->ptr, "adjust_playback_rate"))) {
545 load_data->adjust_playback_rate = RNA_boolean_get(op->ptr, "adjust_playback_rate");
546 }
547
548 if ((prop = RNA_struct_find_property(op->ptr, "filepath"))) {
549 RNA_property_string_get(op->ptr, prop, load_data->path);
550 /* File basename might be too long, better report it now than silently
551 * truncating the basename later. */
552 const char *basename = BLI_path_basename(load_data->path);
553 if (strlen(basename) >= sizeof(StripElem::filename)) {
555 RPT_ERROR,
556 "Filename '%s' too long (max length %zu, was %zu)",
557 basename,
558 sizeof(StripElem::filename),
559 strlen(basename));
560 return false;
561 }
562 STRNCPY(load_data->name, basename);
563 }
564 else if ((prop = RNA_struct_find_property(op->ptr, "directory"))) {
565 std::string directory = RNA_string_get(op->ptr, "directory");
566
567 if ((prop = RNA_struct_find_property(op->ptr, "files"))) {
568 RNA_PROP_BEGIN (op->ptr, itemptr, prop) {
569 std::string filename = RNA_string_get(&itemptr, "name");
570 STRNCPY(load_data->name, filename.c_str());
572 load_data->path, sizeof(load_data->path), directory.c_str(), filename.c_str());
573 break;
574 }
576 }
577 }
578
579 const bool relative = (prop = RNA_struct_find_property(op->ptr, "relative_path")) &&
580 RNA_property_boolean_get(op->ptr, prop);
581 if (relative) {
583 }
584
585 if ((prop = RNA_struct_find_property(op->ptr, "length"))) {
586 load_data->image.length = RNA_property_int_get(op->ptr, prop);
587 load_data->effect.length = load_data->image.length;
588 }
589
590 if ((prop = RNA_struct_find_property(op->ptr, "cache")) &&
591 RNA_property_boolean_get(op->ptr, prop))
592 {
594 }
595
596 if ((prop = RNA_struct_find_property(op->ptr, "mono")) &&
597 RNA_property_boolean_get(op->ptr, prop))
598 {
600 }
601
602 if ((prop = RNA_struct_find_property(op->ptr, "use_framerate")) &&
603 RNA_property_boolean_get(op->ptr, prop))
604 {
606 }
607
608 if ((prop = RNA_struct_find_property(op->ptr, "set_view_transform")) &&
609 RNA_property_boolean_get(op->ptr, prop))
610 {
612 }
613
614 if ((prop = RNA_struct_find_property(op->ptr, "use_multiview")) &&
615 RNA_property_boolean_get(op->ptr, prop))
616 {
617 if (op->customdata) {
618 SequencerAddData *sad = static_cast<SequencerAddData *>(op->customdata);
619 ImageFormatData *imf = &sad->im_format;
620
621 load_data->use_multiview = true;
622 load_data->views_format = imf->views_format;
623 load_data->stereo3d_format = &imf->stereo3d_format;
624 }
625 }
626
627 if (region == nullptr) {
628 RNA_boolean_set(op->ptr, "move_strips_after_add", false);
629 }
630
631 /* Override strip position by current mouse position. */
632 if (should_move_strips_after_add(op) && region != nullptr) {
633 const wmWindow *win = CTX_wm_window(C);
634 int2 mouse_region(win->runtime->eventstate->xy[0] - region->winrct.xmin,
635 win->runtime->eventstate->xy[1] - region->winrct.ymin);
636
637 /* Clamp mouse cursor location (strip starting position) to the sequencer region bounds so that
638 * it is immediately visible even if the mouse cursor is out of bounds. For maximums, use 90%
639 * of the bounds instead of 1 frame away, which works well even if zoomed out. */
641 rcti clamp_bounds;
642 BLI_rcti_init(&clamp_bounds,
643 mask.xmin,
644 mask.xmin + 0.9 * BLI_rcti_size_x(&mask),
645 mask.ymin,
646 mask.ymin + 0.9 * BLI_rcti_size_y(&mask));
647 BLI_rcti_clamp_pt_v(&clamp_bounds, mouse_region);
648
649 float2 mouse_view;
651 &region->v2d, mouse_region.x, mouse_region.y, &mouse_view.x, &mouse_view.y);
652
653 load_data->start_frame = std::trunc(mouse_view.x);
654 load_data->channel = std::trunc(mouse_view.y);
655 }
656 return true;
657}
658
660 bContext *C, wmOperator *op, seq::LoadData *load_data, Scene *scene, const int num_strips)
661{
663
664 const char *error_msg;
665 if (!have_free_channels(C, op, num_strips, &error_msg)) {
666 BKE_report(op->reports, RPT_ERROR, error_msg);
667 return false;
668 }
669
670 /* Keeping the old selection when moving newly imported strips is unexpected and feels buggy,
671 * so we deselect when `move_strips_after_add` is set too. */
672 if (RNA_boolean_get(op->ptr, "move_strips_after_add") || RNA_boolean_get(op->ptr, "replace_sel"))
673 {
674 deselect_all_strips(scene);
676 }
677
679 return false;
680 }
681
682 return true;
683}
684
685static bool should_handle_overlap(const wmOperator *op)
686{
687 return RNA_boolean_get(op->ptr, "overlap") == false;
688}
689
691{
693 Editing *ed = seq::editing_get(scene);
694
695 const bool overlap_mode_is_set = RNA_struct_property_is_set(op->ptr, "overlap_mode");
696 const eSeqOverlapMode overlap_mode = overlap_mode_is_set ?
697 eSeqOverlapMode(RNA_enum_get(op->ptr, "overlap_mode")) :
699
700 /* Do some minimal shuffling now (on add) if there will be a move afterwards; this parks the
701 * strip in a free channel so that there will be no overlap on undo of the add. Otherwise, this
702 * is the final placement, so resolve overlap more properly instead of hard-coding to shuffle. */
704 (!overlap_mode_is_set && overlap_mode == SEQ_OVERLAP_SHUFFLE))
705 {
706 seq::transform_shuffle_vertical(ed->current_strips(), strips, scene);
707 return;
708 }
709
710 ScrArea *area = CTX_wm_area(C);
711 const bool use_sync_markers = ((area->spacedata.first_as<SpaceSeq>())->flag &
712 SEQ_MARKER_TRANS) != 0;
714 ed->current_strips(),
715 strips,
716 use_sync_markers,
717 overlap_mode,
719}
720
722{
724 Editing *ed = seq::editing_get(scene);
725
726 if (strip == nullptr) {
727 return;
728 }
729
730 if (RNA_boolean_get(op->ptr, "replace_sel")) {
731 strip->flag |= SEQ_SELECT;
732 seq::select_active_set(scene, strip);
733 }
734
735 /* Use set overlap_mode to fix overlaps. */
736 if (should_handle_overlap(op) && seq::transform_test_overlap(scene, ed->current_strips(), strip))
737 {
738 VectorSet<Strip *> strip_col;
739 strip_col.add(strip);
740 seq_load_handle_overlap(C, op, strip_col);
741 }
742}
743
744/* In this alternative version we only check for overlap, but do not do anything about them. */
746 wmOperator *op,
747 Strip *strip)
748{
750 Editing *ed = seq::editing_get(scene);
751
752 if (strip == nullptr) {
753 return false;
754 }
755
756 if (RNA_boolean_get(op->ptr, "replace_sel")) {
757 strip->flag |= SEQ_SELECT;
758 seq::select_active_set(scene, strip);
759 }
760
761 return seq::transform_test_overlap(scene, ed->current_strips(), strip);
762}
763
765{
767 /* Disable following properties if there are any existing strips, unless overridden by user. */
768 if (ed && ed->current_strips() && ed->current_strips()->first()) {
769 if (RNA_struct_find_property(op->ptr, "use_framerate")) {
770 RNA_boolean_set(op->ptr, "use_framerate", false);
771 }
772 if (RNA_struct_find_property(op->ptr, "set_view_transform")) {
773 RNA_boolean_set(op->ptr, "set_view_transform", false);
774 }
775 }
776}
777
779
780/* -------------------------------------------------------------------- */
783
785{
786 Main *bmain = CTX_data_main(C);
788 const Editing *ed = seq::editing_ensure(scene);
789 Scene *sce_seq = static_cast<Scene *>(
790 BLI_findlink(&bmain->scenes, RNA_enum_get(op->ptr, "scene")));
791
792 if (sce_seq == nullptr) {
793 BKE_report(op->reports, RPT_ERROR, "Scene not found");
794 return OPERATOR_CANCELLED;
795 }
796
798 if (!sequencer_add_generic_exec(C, op, &load_data, scene, 1)) {
799 return OPERATOR_CANCELLED;
800 }
801 load_data.scene = sce_seq;
802
803 Strip *strip = seq::add_scene_strip(scene, ed->current_strips(), &load_data);
805
809 move_strips(C, op);
810
811 return OPERATOR_FINISHED;
812}
813
815 wmOperator *op,
816 const wmEvent *event)
817{
819 if (!RNA_struct_property_is_set(op->ptr, "scene")) {
820 return WM_enum_search_invoke(C, op, event);
821 }
822
827 return retval;
828}
829
831{
832 PropertyRNA *prop;
833
834 /* Identifiers. */
835 ot->name = "Add Scene Strip";
836 ot->idname = "SEQUENCER_OT_scene_strip_add";
837 ot->description = "Add a strip re-using this scene as the source";
838
839 /* API callbacks. */
843
844 /* Flags. */
846
848 prop = RNA_def_enum(
849 ot->srna, "scene", rna_enum_dummy_NULL_items, 0, "Scene", "Scene to add as a strip");
852 ot->prop = prop;
853}
854
856
857/* -------------------------------------------------------------------- */
860
862 {SCE_COPY_NEW, "NEW", 0, "New", "Add new Strip with a new empty Scene with default settings"},
864 "EMPTY",
865 0,
866 "Copy Settings",
867 "Add a new Strip, with an empty scene, and copy settings from the current scene"},
869 "LINK_COPY",
870 0,
871 "Linked Copy",
872 "Add a Strip and link in the collections from the current scene (shallow copy)"},
874 "FULL_COPY",
875 0,
876 "Full Copy",
877 "Add a Strip and make a full copy of the current scene"},
878 {0, nullptr, 0, nullptr, nullptr},
879};
880
882{
883 Main *bmain = CTX_data_main(C);
885 const Editing *ed = seq::editing_ensure(scene);
886
888 if (!sequencer_add_generic_exec(C, op, &load_data, scene, 1)) {
889 return OPERATOR_CANCELLED;
890 }
891
892 int type = RNA_enum_get(op->ptr, "type");
893 Scene *scene_new = ED_scene_sequencer_add(bmain, C, eSceneCopyMethod(type));
894 if (scene_new == nullptr) {
895 return OPERATOR_CANCELLED;
896 }
897 load_data.scene = scene_new;
898
899 Strip *strip = seq::add_scene_strip(scene, ed->current_strips(), &load_data);
901
905 move_strips(C, op);
906
907 return OPERATOR_FINISHED;
908}
909
918
920{
921 /* Identifiers. */
922 ot->name = "Add Strip with a new Scene";
923 ot->idname = "SEQUENCER_OT_scene_strip_add_new";
924 ot->description = "Add a strip using a new scene as the source";
925
926 /* API callbacks. */
930
931 /* Flags. */
933
935
936 ot->prop = RNA_def_enum(ot->srna,
937 "type",
940 "Type",
941 "Method for creating the new scene");
942}
943
945
946/* -------------------------------------------------------------------- */
949
956 ReportList & /*reports*/)
957{
958 Main &bmain = *CTX_data_main(&C);
959 Scene *scene_asset = reinterpret_cast<Scene *>(
961
962 if (scene_asset && asset.is_local_id()) {
963 /* Local scene that needs to be duplicated. */
964 Scene *scene_copy = BKE_scene_duplicate(
965 &bmain,
966 scene_asset,
968 static_cast<eDupli_ID_Flags>(U.dupflag | USER_DUP_OBJECT),
970 return scene_copy;
971 }
972 return scene_asset;
973}
974
976 wmOperator *op,
977 const wmEvent *event)
978{
979 Main *bmain = CTX_data_main(C);
981 if (!scene) {
982 return OPERATOR_CANCELLED;
983 }
985 BLI_assert(ed != nullptr);
986
988
992 if (!asset) {
993 return OPERATOR_CANCELLED;
994 }
995
996 Scene *scene_asset = sequencer_add_scene_asset(*C, *asset, *op->reports);
997 if (!scene_asset) {
998 return OPERATOR_CANCELLED;
999 }
1000
1002 if (!sequencer_add_generic_exec(C, op, &load_data, scene, 1)) {
1003 return OPERATOR_CANCELLED;
1004 }
1005 load_data.scene = scene_asset;
1006
1007 Strip *strip = seq::add_scene_strip(scene, ed->current_strips(), &load_data);
1009
1013 move_strips(C, op);
1014
1015 return OPERATOR_FINISHED;
1016}
1017
1019 wmOperatorType * /*ot*/,
1020 PointerRNA *ptr)
1021{
1024 if (!asset) {
1025 return "";
1026 }
1027 const AssetMetaData &asset_data = asset->get_metadata();
1028 if (!asset_data.description) {
1029 return "";
1030 }
1031 return TIP_(asset_data.description);
1032}
1033
1035{
1036 ot->name = "Add Scene Asset";
1037 ot->description = "Add a strip using a duplicate of this scene asset as the source";
1038 ot->idname = "SEQUENCER_OT_add_scene_strip_from_scene_asset";
1039
1043
1045
1047
1049}
1050
1052
1053/* -------------------------------------------------------------------- */
1056
1058{
1059 Main *bmain = CTX_data_main(C);
1061 const Editing *ed = seq::editing_ensure(scene);
1062 MovieClip *clip = static_cast<MovieClip *>(
1063 BLI_findlink(&bmain->movieclips, RNA_enum_get(op->ptr, "clip")));
1064
1065 if (clip == nullptr) {
1066 BKE_report(op->reports, RPT_ERROR, "Movie clip not found");
1067 return OPERATOR_CANCELLED;
1068 }
1069
1071 if (!sequencer_add_generic_exec(C, op, &load_data, scene, 1)) {
1072 return OPERATOR_CANCELLED;
1073 }
1074 load_data.clip = clip;
1075
1076 Strip *strip = seq::add_movieclip_strip(scene, ed->current_strips(), &load_data);
1078
1081 move_strips(C, op);
1082
1083 return OPERATOR_FINISHED;
1084}
1085
1087 wmOperator *op,
1088 const wmEvent *event)
1089{
1090 if (!RNA_struct_property_is_set(op->ptr, "clip")) {
1091 return WM_enum_search_invoke(C, op, event);
1092 }
1093
1094 sequencer_add_init(C, op);
1097 sequencer_add_free(C, op);
1098 return retval;
1099}
1100
1102{
1103 PropertyRNA *prop;
1104
1105 /* Identifiers. */
1106 ot->name = "Add MovieClip Strip";
1107 ot->idname = "SEQUENCER_OT_movieclip_strip_add";
1108 ot->description = "Add a movieclip strip to the sequencer";
1109
1110 /* API callbacks. */
1114
1115 /* Flags. */
1117
1119 prop = RNA_def_enum(
1120 ot->srna, "clip", rna_enum_dummy_NULL_items, 0, "Clip", "Movie clip to add as a strip");
1124 ot->prop = prop;
1125}
1126
1128
1129/* -------------------------------------------------------------------- */
1132
1134{
1135 Main *bmain = CTX_data_main(C);
1137 const Editing *ed = seq::editing_ensure(scene);
1138 Mask *mask = static_cast<Mask *>(BLI_findlink(&bmain->masks, RNA_enum_get(op->ptr, "mask")));
1139
1140 if (mask == nullptr) {
1141 BKE_report(op->reports, RPT_ERROR, "Mask not found");
1142 return OPERATOR_CANCELLED;
1143 }
1144
1146 if (!sequencer_add_generic_exec(C, op, &load_data, scene, 1)) {
1147 return OPERATOR_CANCELLED;
1148 }
1149 load_data.mask = mask;
1150
1151 Strip *strip = seq::add_mask_strip(scene, ed->current_strips(), &load_data);
1153
1156 move_strips(C, op);
1157
1158 return OPERATOR_FINISHED;
1159}
1160
1162 wmOperator *op,
1163 const wmEvent *event)
1164{
1165 if (!RNA_struct_property_is_set(op->ptr, "mask")) {
1166 return WM_enum_search_invoke(C, op, event);
1167 }
1168
1169 sequencer_add_init(C, op);
1172 sequencer_add_free(C, op);
1173 return retval;
1174}
1175
1177{
1178 PropertyRNA *prop;
1179
1180 /* Identifiers. */
1181 ot->name = "Add Mask Strip";
1182 ot->idname = "SEQUENCER_OT_mask_strip_add";
1183 ot->description = "Add a mask strip to the sequencer";
1184
1185 /* API callbacks. */
1189
1190 /* Flags. */
1192
1194 prop = RNA_def_enum(
1195 ot->srna, "mask", rna_enum_dummy_NULL_items, 0, "Mask", "Mask to add as a strip");
1198 ot->prop = prop;
1199}
1200
1202
1203/* -------------------------------------------------------------------- */
1206
1207/* Strips are added in context of timeline which has different preview size than actual preview. We
1208 * must search for preview area. In most cases there will be only one preview area, but there can
1209 * be more with different preview sizes. */
1211{
1212 bScreen *screen = CTX_wm_screen(C);
1213 IMB_Proxy_Size proxy_sizes = IMB_PROXY_NONE;
1214 for (ScrArea &area : screen->areabase) {
1215 for (SpaceLink &sl : area.spacedata) {
1216 switch (sl.spacetype) {
1217 case SPACE_SEQ: {
1218 SpaceSeq *sseq = reinterpret_cast<SpaceSeq *>(&sl);
1220 continue;
1221 }
1222 proxy_sizes |= seq::rendersize_to_proxysize(
1224 }
1225 }
1226 }
1227 }
1228 return proxy_sizes;
1229}
1230
1232{
1233 if (U.sequencer_proxy_setup != USER_SEQ_PROXY_SETUP_AUTOMATIC) {
1234 return;
1235 }
1236
1239
1240 for (Strip *strip : strips) {
1241 if (strip->type != STRIP_TYPE_MOVIE) {
1242 continue;
1243 }
1244
1245 /* Enable and set proxy size. */
1246 seq::proxy_set(strip, true);
1247 strip->data->proxy->build_size_flags = eStripProxyBuildSize(seq_get_proxy_size_flags(C));
1248 strip->data->proxy->build_flags |= SEQ_PROXY_SKIP_EXISTING;
1249 seq::proxy_build_start(pj->main, pj->scene, strip, nullptr, true, pj->queue);
1250 }
1251
1252 if (!WM_jobs_is_running(wm_job)) {
1253 G.is_break = false;
1254 WM_jobs_start(CTX_wm_manager(C), wm_job);
1255 }
1257}
1258
1260 Strip *strip,
1261 Strip *anchor,
1262 const double stream_start,
1263 const double anchor_start)
1264{
1265 /* Individual a/v streams may have different 'start' values listed in their container. This
1266 * function offsets each newly added strip's start to reconstruct that data. */
1267 const double offset_seconds = stream_start - anchor_start;
1268 const int frame_offset = int(offset_seconds * scene->frames_per_second());
1269
1270 /* Only sound strips currently support extra sub-frame offsets. */
1271 if (strip->type == STRIP_TYPE_SOUND && strip->sound != nullptr) {
1272 strip->sound->offset_time = double(frame_offset) / scene->frames_per_second() - offset_seconds;
1273 }
1274 if (frame_offset != 0) {
1275 seq::transform_translate_strip(scene, strip, frame_offset);
1276 }
1277
1278 /* Expand missing sound data in the underlying container to fill the movie strip's length. To the
1279 * user, this missing data is the same as complete silence, so we pretend like it is. */
1280 if (strip->type == STRIP_TYPE_SOUND) {
1281 strip->content_length_set(std::max(anchor->content_length(), strip->content_length()));
1282 }
1283
1284 /* Match the strip length to the anchor to have all streams align on the timeline. */
1285 strip->right_handle_set(scene, anchor->right_handle(scene));
1286 strip->left_handle_set(scene, anchor->left_handle());
1287}
1288
1294
1296 wmOperator *op,
1298 VectorSet<Strip *> &r_strips_added,
1299 bool &r_has_overlap)
1300{
1301 Main *bmain = CTX_data_main(C);
1303 const Editing *ed = seq::editing_ensure(scene);
1304
1305 const bool load_sound = RNA_boolean_get(op->ptr, "sound");
1306 const bool handle_overlap = should_handle_overlap(op);
1307
1308 char filepath_abs[FILE_MAX];
1309 STRNCPY(filepath_abs, load_data->path);
1310 BLI_path_abs(filepath_abs, BKE_main_blendfile_path(bmain));
1311
1312 ColorManagedColorspaceSettings colorspace_settings;
1313 MovieReader *probe_anim = openanim_noload(
1314 filepath_abs, ImBufFlags::Zero, 0, true, &colorspace_settings);
1315 const int video_count = MOV_get_video_stream_count(probe_anim);
1316 const int sound_count = load_sound ? BKE_sound_stream_count(bmain, filepath_abs) : 0;
1317
1318 if (probe_anim != nullptr) {
1319 MOV_close(probe_anim);
1320 }
1321
1322 if (video_count == 0 && sound_count == 0) {
1323 BKE_reportf(op->reports, RPT_ERROR, "File '%s' has no streams to load", load_data->path);
1324 return;
1325 }
1326
1327 /* All strips imported in the current file, along with their stream starts for syncing. */
1328 Vector<StripEntry> entries;
1329 const int base_channel = std::max(1, load_data->channel);
1330
1331 /* Video streams. We must load these first since they can change scene FPS as a side effect. */
1332 for (const int video_index : IndexRange(video_count)) {
1333 load_data->stream_index = video_index;
1334 load_data->channel = base_channel + sound_count + video_index;
1335 Strip *strip = seq::add_movie_strip(bmain, scene, ed->current_strips(), load_data);
1336 if (strip == nullptr) {
1337 if (video_index == 0) {
1338 BKE_reportf(op->reports, RPT_ERROR, "File '%s' could not be loaded", load_data->path);
1339 }
1340 return;
1341 }
1342 /* To standardize behavior, only let the first video stream among all files change FPS. */
1343 load_data->flags &= ~seq::SEQ_LOAD_MOVIE_SYNC_FPS;
1344 entries.append({strip, load_data->video_stream_start});
1345 }
1346
1347 /* Audio streams. */
1348 for (const int sound_index : IndexRange(sound_count)) {
1349 load_data->stream_index = sound_index;
1350 load_data->channel = base_channel + sound_index;
1351 Strip *strip = seq::add_sound_strip(bmain, scene, ed->current_strips(), load_data);
1352 if (strip == nullptr) {
1353 continue;
1354 }
1355 double stream_start = 0.0;
1356 SoundStreamInfo info;
1357 if (BKE_sound_stream_info_get(bmain, load_data->path, sound_index, &info)) {
1358 stream_start = info.start;
1359 }
1360 entries.append({strip, stream_start});
1361 }
1362
1363 if (entries.is_empty()) {
1364 return;
1365 }
1366
1367 /* Sync all strip start times using a reference stream as an anchor (the first video stream). */
1368 const StripEntry &anchor_entry = entries.first();
1369 for (const StripEntry &entry : entries) {
1370 if (entry.strip == anchor_entry.strip) {
1371 continue;
1372 }
1374 scene, entry.strip, anchor_entry.strip, entry.stream_start, anchor_entry.stream_start);
1375 }
1376
1377 /* Restore/update fields for the next file added with this same load_data. */
1378 load_data->channel = base_channel;
1379 load_data->start_frame += anchor_entry.strip->right_handle(scene) -
1380 anchor_entry.strip->left_handle();
1381
1382 /* Apply per-strip generic options. */
1383 for (const StripEntry &entry : entries) {
1384 if (handle_overlap) {
1385 r_has_overlap |= seq_load_apply_generic_options_only_test_overlap(C, op, entry.strip);
1386 }
1387 else {
1388 seq_load_apply_generic_options(C, op, entry.strip);
1389 }
1390 r_strips_added.add(entry.strip);
1391 }
1392
1393 /* Connect all strips from this file together as one group. */
1394 if (U.sequencer_editor_flag & USER_SEQ_ED_CONNECT_STRIPS_BY_DEFAULT) {
1395 VectorSet<Strip *> group;
1396 for (const StripEntry &entry : entries) {
1397 group.add(entry.strip);
1398 }
1399 seq::connect(group);
1400 }
1401}
1402
1404 wmOperator *op,
1406{
1408 seq::editing_ensure(scene);
1409
1410 const bool handle_overlap = should_handle_overlap(op);
1411
1412 /* All strips eventually added by all files. */
1413 VectorSet<Strip *> strips_added;
1414 bool has_overlap = false;
1415
1416 PropertyRNA *files_prop = RNA_struct_find_property(op->ptr, "files");
1417 if (files_prop && RNA_property_collection_length(op->ptr, files_prop) > 1) {
1418 RNA_PROP_BEGIN (op->ptr, itemptr, files_prop) {
1419 char dir_only[FILE_MAX];
1420 char file_only[FILE_MAX];
1421 RNA_string_get(op->ptr, "directory", dir_only);
1422 RNA_string_get(&itemptr, "name", file_only);
1423 BLI_path_join(load_data->path, sizeof(load_data->path), dir_only, file_only);
1424 STRNCPY(load_data->name, file_only);
1425 sequencer_add_movie_strips_single_file(C, op, load_data, strips_added, has_overlap);
1426 }
1428 }
1429 else {
1430 sequencer_add_movie_strips_single_file(C, op, load_data, strips_added, has_overlap);
1431 }
1432
1433 if (handle_overlap && has_overlap) {
1434 seq_load_handle_overlap(C, op, strips_added);
1435 }
1436
1437 return strips_added;
1438}
1439
1441{
1442 if ((op->flag & OP_IS_INVOKE) && !WM_operator_poll_or_report_error(C, op->type, op->reports)) {
1443 return OPERATOR_CANCELLED;
1444 }
1445
1446 Main *bmain = CTX_data_main(C);
1448
1450 if (!sequencer_add_generic_exec(C, op, &load_data, scene, 2)) {
1451 return OPERATOR_CANCELLED;
1452 }
1453
1454 char vt_old[64];
1456 const double fps_old = scene->frames_per_second();
1457
1458 const VectorSet<Strip *> strips_added = sequencer_add_movie_strips(C, op, &load_data);
1459
1460 if (!STREQ(vt_old, scene->view_settings.view_transform)) {
1461 BKE_reportf(op->reports,
1463 "View transform set to %s (converted from %s)",
1465 vt_old);
1466 }
1467
1468 if (fps_old != scene->frames_per_second()) {
1469 BKE_reportf(op->reports,
1471 "Scene frame rate set to %.4g (converted from %.4g)",
1472 scene->frames_per_second(),
1473 fps_old);
1474 }
1475
1476 if (strips_added.is_empty()) {
1477 sequencer_add_free(C, op);
1478 return OPERATOR_CANCELLED;
1479 }
1480
1481 seq_build_proxy(C, strips_added);
1485 move_strips(C, op);
1486
1487 sequencer_add_free(C, op);
1488
1489 return OPERATOR_FINISHED;
1490}
1491
1493 wmOperator *op,
1494 const wmEvent *event)
1495{
1496 PropertyRNA *prop;
1498
1500 sequencer_add_init(C, op);
1501
1502 RNA_enum_set(op->ptr, "fit_method", seq::tool_settings_fit_method_get(scene));
1503 RNA_boolean_set(op->ptr, "adjust_playback_rate", true);
1504
1505 if (is_drag_and_drop(op, event)) {
1507
1508 const char *error_msg;
1509 if (!have_free_channels(C, op, 2, &error_msg)) {
1510 BKE_report(op->reports, RPT_ERROR, error_msg);
1511 return OPERATOR_CANCELLED;
1512 }
1513
1515 }
1516
1518
1519 /* Show multiview save options only if scene use multiview. */
1520 prop = RNA_struct_find_property(op->ptr, "show_multiview");
1521 RNA_property_boolean_set(op->ptr, prop, (scene->r.scemode & R_MULTIVIEW) != 0);
1522
1525}
1526
1528{
1529
1530 /* Identifiers. */
1531 ot->name = "Add Movie Strip";
1532 ot->idname = "SEQUENCER_OT_movie_strip_add";
1533 ot->description = "Add a movie strip to the sequencer";
1534
1535 /* API callbacks. */
1539 ot->ui = sequencer_add_ui;
1541
1542 /* Flags. */
1544
1556 SEQPROP_MOVE);
1557 RNA_def_boolean(ot->srna, "sound", true, "Sound", "Load sound with the movie");
1559 "use_framerate",
1560 true,
1561 "Set Scene Frame Rate",
1562 "Set frame rate of the current scene to the frame rate of the movie");
1563}
1564
1566
1567/* -------------------------------------------------------------------- */
1570
1572 wmOperator *op,
1574{
1575 Main *bmain = CTX_data_main(C);
1577 Editing *ed = seq::editing_ensure(scene);
1578
1579 const bool handle_overlap = should_handle_overlap(op);
1580 VectorSet<Strip *> strips_added;
1581 bool has_overlap = false;
1582
1583 RNA_BEGIN (op->ptr, itemptr, "files") {
1584 char dir_only[FILE_MAX];
1585 char file_only[FILE_MAX];
1586 RNA_string_get(op->ptr, "directory", dir_only);
1587 RNA_string_get(&itemptr, "name", file_only);
1588 BLI_path_join(load_data->path, sizeof(load_data->path), dir_only, file_only);
1589 STRNCPY(load_data->name, file_only);
1590 Strip *strip = seq::add_sound_strip(bmain, scene, ed->current_strips(), load_data);
1591 if (strip == nullptr) {
1592 BKE_reportf(op->reports, RPT_ERROR, "File '%s' could not be loaded", load_data->path);
1593 }
1594 else {
1595 has_overlap |= seq_load_apply_generic_options_only_test_overlap(C, op, strip);
1596 strips_added.add(strip);
1597 load_data->start_frame += strip->right_handle(scene) - strip->left_handle();
1598 }
1599 }
1600 RNA_END;
1601
1602 if (handle_overlap && has_overlap) {
1603 seq_load_handle_overlap(C, op, strips_added);
1604 }
1605}
1606
1608{
1609 Main *bmain = CTX_data_main(C);
1611 Editing *ed = seq::editing_ensure(scene);
1612
1613 Strip *strip = seq::add_sound_strip(bmain, scene, ed->current_strips(), load_data);
1614 if (strip == nullptr) {
1615 BKE_reportf(op->reports, RPT_ERROR, "File '%s' could not be loaded", load_data->path);
1616 return false;
1617 }
1619
1620 return true;
1621}
1622
1624{
1625 if ((op->flag & OP_IS_INVOKE) && !WM_operator_poll_or_report_error(C, op->type, op->reports)) {
1626 return OPERATOR_CANCELLED;
1627 }
1628
1629 Main *bmain = CTX_data_main(C);
1631
1633 if (!sequencer_add_generic_exec(C, op, &load_data, scene, 1)) {
1634 return OPERATOR_CANCELLED;
1635 }
1636
1637 const int tot_files = RNA_property_collection_length(op->ptr,
1638 RNA_struct_find_property(op->ptr, "files"));
1639 if (tot_files > 1) {
1641 }
1642 else {
1644 sequencer_add_free(C, op);
1645 return OPERATOR_CANCELLED;
1646 }
1647 }
1648
1652 move_strips(C, op);
1653
1654 sequencer_add_free(C, op);
1655
1656 return OPERATOR_FINISHED;
1657}
1658
1660 wmOperator *op,
1661 const wmEvent *event)
1662{
1663 sequencer_add_init(C, op);
1664
1665 if (is_drag_and_drop(op, event)) {
1667
1668 const char *error_msg;
1669 if (!have_free_channels(C, op, 1, &error_msg)) {
1670 BKE_report(op->reports, RPT_ERROR, error_msg);
1671 return OPERATOR_CANCELLED;
1672 }
1673
1675 }
1676
1678
1681}
1682
1684{
1685
1686 /* Identifiers. */
1687 ot->name = "Add Sound Strip";
1688 ot->idname = "SEQUENCER_OT_sound_strip_add";
1689 ot->description = "Add a sound strip to the sequencer";
1690
1691 /* API callbacks. */
1694 ot->ui = sequencer_add_ui;
1697
1698 /* Flags. */
1700
1710 RNA_def_boolean(ot->srna, "cache", false, "Cache", "Cache the sound in memory");
1711 RNA_def_boolean(ot->srna, "mono", false, "Mono", "Merge all the sound's channels into one");
1712}
1713
1715
1716/* -------------------------------------------------------------------- */
1719
1720void frame_filename_set(char *dst,
1721 size_t dst_maxncpy,
1722 const char *filename_stripped,
1723 const int frame,
1724 const int numdigits,
1725 const char *ext)
1726{
1727 BLI_strncpy(dst, filename_stripped, dst_maxncpy);
1728 BLI_path_frame(dst, dst_maxncpy, frame, numdigits);
1729 BLI_path_extension_ensure(dst, dst_maxncpy, ext);
1730}
1731
1733 Scene *scene,
1734 Strip *strip,
1736 const ImageFrameRange *range)
1737{
1738 int framenr, numdigits;
1739 if (!BLI_path_frame_get(load_data->path, &framenr, &numdigits)) {
1740 numdigits = 0;
1741 }
1742
1743 char ext[FILE_MAX];
1744 char filename_stripped[FILE_MAX];
1745 BLI_path_split_file_part(load_data->path, filename_stripped, sizeof(filename_stripped));
1746 BLI_path_frame_strip(filename_stripped, ext, sizeof(ext));
1747
1748 StripElem *se = strip->data->stripdata;
1749 const bool use_placeholders = RNA_boolean_get(op->ptr, "use_placeholders");
1750 if (use_placeholders) {
1751 for (int i = range->offset; i < range->max_framenr + 1; i++, se++) {
1752 frame_filename_set(se->filename, sizeof(se->filename), filename_stripped, i, numdigits, ext);
1753 }
1754 }
1755 else {
1756 size_t strip_frame = 0;
1757 for (ImageFrame &frame : range->frames) {
1758 char filename[FILE_MAX];
1760 filename, sizeof(filename), filename_stripped, frame.framenr, numdigits, ext);
1761 seq::add_image_load_file(scene, strip, strip_frame, filename);
1762 strip_frame++;
1763 }
1764 }
1765}
1766
1768 wmOperator *op,
1770{
1771 if ((op->flag & OP_IS_INVOKE) && !WM_operator_poll_or_report_error(C, op->type, op->reports)) {
1772 return false;
1773 }
1774
1775 Main *bmain = CTX_data_main(C);
1777 Editing *ed = seq::editing_ensure(scene);
1778
1779 /* Note that forced image sequence creation does not consider `use_placeholders`, since their
1780 * existence can only be determined if images follow the naming scheme (not guaranteed here). */
1782 op->ptr, RNA_struct_find_property(op->ptr, "files"));
1783
1784 if (load_data.image.count == 0) {
1785 sequencer_add_free(C, op);
1786 return false;
1787 }
1788
1789 Strip *strip = seq::add_image_strip(bmain, scene, ed->current_strips(), &load_data);
1790 char dirpath[sizeof(strip->data->dirpath)];
1791 BLI_path_split_dir_part(load_data.path, dirpath, sizeof(dirpath));
1792 seq::add_image_set_directory(strip, dirpath);
1793
1794 int i = 0;
1795 RNA_BEGIN (op->ptr, itemptr, "files") {
1796 std::string filename = RNA_string_get(&itemptr, "name");
1797 seq::add_image_load_file(scene, strip, i, filename.c_str());
1798 i++;
1799 }
1800 RNA_END;
1801
1802 seq::add_image_init_alpha_mode(bmain, scene, strip);
1804 return true;
1805}
1806
1808{
1809 Main *bmain = CTX_data_main(C);
1811 Editing *ed = seq::editing_ensure(scene);
1812
1813 const char *blendfile_path = BKE_main_blendfile_path(bmain);
1814 ListBaseT<ImageFrameRange> ranges = ED_image_filesel_detect_sequences(
1815 blendfile_path, blendfile_path, op, false);
1816 if (ranges.is_empty()) {
1817 sequencer_add_free(C, op);
1818 return false;
1819 }
1820
1821 const bool use_placeholders = RNA_boolean_get(op->ptr, "use_placeholders");
1822 const bool handle_overlap = should_handle_overlap(op);
1823 VectorSet<Strip *> strips_added;
1824 bool has_overlap = false;
1825
1826 for (ImageFrameRange &range : ranges) {
1827 /* Populate `load_data` with data from `range`. */
1828 load_data.image.count = use_placeholders ? range.max_framenr - range.offset + 1 :
1829 range.frames.count();
1830 STRNCPY(load_data.path, range.filepath);
1831 BLI_path_split_file_part(load_data.path, load_data.name, sizeof(load_data.name));
1832
1833 Strip *strip = seq::add_image_strip(bmain, scene, ed->current_strips(), &load_data);
1834
1835 char dirpath[sizeof(strip->data->dirpath)];
1836 BLI_path_split_dir_part(load_data.path, dirpath, sizeof(dirpath));
1837 seq::add_image_set_directory(strip, dirpath);
1838
1839 /* Set `StripElem` filenames, one for each `ImageFrame` in this range, or if `use_placeholders`
1840 * is set, every frame between `offset` and `max_framenr` . */
1841 sequencer_add_image_strip_load_files(op, scene, strip, &load_data, &range);
1842
1843 seq::add_image_init_alpha_mode(bmain, scene, strip);
1844
1845 has_overlap |= seq_load_apply_generic_options_only_test_overlap(C, op, strip);
1846 strips_added.add(strip);
1847 load_data.start_frame += seq::transform_single_image_check(strip) ? load_data.image.length :
1848 load_data.image.count;
1849 range.frames.free_no_destruct();
1850 }
1851 ranges.free_no_destruct();
1852
1853 if (handle_overlap && has_overlap) {
1854 seq_load_handle_overlap(C, op, strips_added);
1855 }
1856
1857 return true;
1858}
1859
1861{
1863
1865 if (!sequencer_add_generic_exec(C, op, &load_data, scene, 1)) {
1866 return OPERATOR_CANCELLED;
1867 }
1868
1869 char vt_old[64];
1871
1872 const ImageImport import_type = ImageImport(RNA_enum_get(op->ptr, "image_import_type"));
1873
1874 if (import_type == ImageImport::Sequence) {
1876 return OPERATOR_CANCELLED;
1877 }
1878 }
1879 else {
1880 /* Note that `use_sequence_detection` is false when import type is `ImageImport::Individual`.
1881 * This is used by `ED_image_filesel_detect_sequences`, called from `sequencer_add_images`. */
1882 RNA_boolean_set(op->ptr, "use_sequence_detection", import_type == ImageImport::Detect);
1883 if (!sequencer_add_images(C, op, load_data)) {
1884 return OPERATOR_CANCELLED;
1885 }
1886 }
1887
1888 if (!STREQ(vt_old, scene->view_settings.view_transform)) {
1889 BKE_reportf(op->reports,
1891 "View transform set to %s (converted from %s)",
1893 vt_old);
1894 }
1895
1898 move_strips(C, op);
1899
1900 sequencer_add_free(C, op);
1901
1902 return OPERATOR_FINISHED;
1903}
1904
1906 wmOperator *op,
1907 const wmEvent *event)
1908{
1909 PropertyRNA *prop;
1911
1913 sequencer_add_init(C, op);
1914
1915 RNA_enum_set(op->ptr, "fit_method", seq::tool_settings_fit_method_get(scene));
1916
1917 /* Name set already by drag and drop. */
1918 if (is_drag_and_drop(op, event)) {
1920
1921 const char *error_msg;
1922 if (!have_free_channels(C, op, 1, &error_msg)) {
1923 BKE_report(op->reports, RPT_ERROR, error_msg);
1924 return OPERATOR_CANCELLED;
1925 }
1926
1928 }
1929
1932
1933 /* Show multiview save options only if the scene uses multiview. */
1934 prop = RNA_struct_find_property(op->ptr, "show_multiview");
1935 RNA_property_boolean_set(op->ptr, prop, (scene->r.scemode & R_MULTIVIEW) != 0);
1936
1939}
1940
1942{
1943
1944 /* Identifiers. */
1945 ot->name = "Add Image Strip";
1946 ot->idname = "SEQUENCER_OT_image_strip_add";
1947 ot->description = "Add an image or image sequence to the sequencer";
1948
1949 /* API callbacks. */
1953 ot->ui = sequencer_add_ui;
1955
1956 /* Flags. */
1958
1960 ot,
1970
1971 RNA_def_enum(ot->srna,
1972 "image_import_type",
1975 "Import As",
1976 "Mode for importing selected images");
1977
1978 /* Required for `ED_image_filesel_detect_sequences`, but not shown in UI.
1979 * Set to true on ImageImport::Detect. */
1981 ot->srna,
1982 "use_sequence_detection",
1983 true,
1984 "Detect Sequences",
1985 "Automatically detect animated sequences in selected images (based on file names)");
1986
1988 "use_placeholders",
1989 false,
1990 "Use Placeholders",
1991 "Reserve placeholder frames for missing frames of the image sequence");
1992}
1993
1995
1996/* -------------------------------------------------------------------- */
1999
2001 wmOperator *op,
2003 const StringRef text)
2004{
2006 Editing *ed = seq::editing_ensure(scene);
2007
2008 load_data->effect.type = STRIP_TYPE_TEXT;
2009 Strip *strip = seq::add_effect_strip(scene, ed->current_strips(), load_data);
2011
2012 TextVars *textvars = static_cast<TextVars *>(strip->effectdata);
2013 if (!text.is_empty()) {
2014 /* Make sure to delete default text ("Text") before overriding it. */
2015 MEM_SAFE_DELETE(textvars->text_ptr);
2016 textvars->text_ptr = BLI_strdupn(text.data(), text.size());
2017 textvars->text_len_bytes = text.size();
2018 textvars->cursor_offset = BLI_strlen_utf8(textvars->text_ptr);
2019 }
2020 textvars->runtime = MEM_new<seq::TextVarsRuntime>(__func__);
2021 seq::text_effect_update_runtime(nullptr, *textvars, int2(scene->r.xsch, scene->r.ysch));
2022
2023 return strip;
2024}
2025
2027 wmOperator *op,
2029{
2030 size_t buf_len;
2031 char *buf = BLI_file_read_text_as_mem(load_data->path, 1, &buf_len);
2032 if (buf == nullptr) {
2033 BKE_reportf(op->reports, RPT_ERROR, "File '%s' could not be loaded", load_data->path);
2034 return nullptr;
2035 }
2036 buf[buf_len] = '\0';
2037
2038 Strip *strip = sequencer_add_text_strip(C, op, load_data, StringRef(buf, buf_len));
2039 MEM_delete(buf);
2040
2041 return strip;
2042}
2043
2045{
2046 if ((op->flag & OP_IS_INVOKE) && !WM_operator_poll_or_report_error(C, op->type, op->reports)) {
2047 return OPERATOR_CANCELLED;
2048 }
2049
2051
2053 if (!sequencer_add_generic_exec(C, op, &load_data, scene, 1)) {
2054 return OPERATOR_CANCELLED;
2055 }
2056
2057 if (RNA_collection_is_empty(op->ptr, "files")) {
2059 }
2060 else {
2061 char directory[FILE_MAX];
2062 RNA_string_get(op->ptr, "directory", directory);
2063
2064 RNA_BEGIN (op->ptr, itemptr, "files") {
2065 char filename[FILE_MAX];
2066 RNA_string_get(&itemptr, "name", filename);
2067 BLI_path_join(load_data.path, sizeof(load_data.path), directory, filename);
2068 STRNCPY(load_data.name, filename);
2069
2071 if (strip != nullptr) {
2072 load_data.start_frame += strip->right_handle(scene) - strip->left_handle();
2073 }
2074 }
2075 RNA_END;
2076 }
2077
2080 move_strips(C, op);
2081
2082 sequencer_add_free(C, op);
2083
2084 return OPERATOR_FINISHED;
2085}
2086
2097
2099 wmOperator *op,
2100 const PropertyRNA *prop)
2101{
2102 const char *prop_id = RNA_property_identifier(prop);
2103
2104 if (STR_ELEM(prop_id, "filepath", "directory", "filename", "relative_path")) {
2105 return !RNA_collection_is_empty(op->ptr, "files");
2106 }
2107 if (STREQ(prop_id, "text")) {
2108 return RNA_collection_is_empty(op->ptr, "files");
2109 }
2110
2111 return true;
2112}
2113
2115{
2116 PropertyRNA *prop;
2117
2118 /* Identifiers. */
2119 ot->name = "Add Text Strip";
2120 ot->idname = "SEQUENCER_OT_text_strip_add";
2121 ot->description = "Add a text strip to the sequencer";
2122
2123 /* API callbacks. */
2129
2130 /* Flags. */
2132
2142 prop = RNA_def_string(
2143 ot->srna, "text", nullptr, 0, "Text", "Initialize the strip with this text");
2145}
2146
2148
2149/* -------------------------------------------------------------------- */
2152
2154{
2156 Editing *ed = seq::editing_ensure(scene);
2157
2158 StripType effect_type = StripType(RNA_enum_get(op->ptr, "type"));
2159 const int min_inputs = seq::effect_type_get_min_num_inputs(effect_type);
2160
2161 VectorSet<Strip *> inputs;
2162 if (min_inputs != 0 || effect_type == STRIP_TYPE_COMPOSITOR) {
2163 inputs = strip_effect_get_new_inputs(scene, effect_type);
2164 /* Compositor strips can have up to 2 inputs. */
2165 const int target_count = effect_type == STRIP_TYPE_COMPOSITOR ?
2166 math::min(int(inputs.size()), 2) :
2167 min_inputs;
2168 if (!effect_inputs_validate(inputs.size(), target_count, op->reports)) {
2169 return OPERATOR_CANCELLED;
2170 }
2171 }
2172
2174 if (!sequencer_add_generic_exec(C, op, &load_data, scene, 1)) {
2175 return OPERATOR_CANCELLED;
2176 }
2177
2178 load_data.effect.type = effect_type;
2179 Strip *input1 = inputs.size() > 0 ? inputs[0] : nullptr;
2180 Strip *input2 = inputs.size() == 2 ? inputs[1] : nullptr;
2181 load_data.effect.input1 = input1;
2182 load_data.effect.input2 = input2;
2183
2184 /* Set channel. If unset, use lowest free one above strips. */
2185 if (!RNA_struct_property_is_set(op->ptr, "channel")) {
2186 if (input1 != nullptr) {
2187 int chan = max_ii(input1 ? input1->channel : 0, input2 ? input2->channel : 0);
2188 if (chan < seq::MAX_CHANNELS) {
2189 load_data.channel = chan;
2190 }
2191 }
2192 }
2193
2194 Strip *strip = seq::add_effect_strip(scene, ed->current_strips(), &load_data);
2196
2197 if (strip->type == STRIP_TYPE_COLOR) {
2198 SolidColorVars *colvars = static_cast<SolidColorVars *>(strip->effectdata);
2199 RNA_float_get_array(op->ptr, "color", colvars->col);
2200 colvars->width = RNA_struct_property_is_set(op->ptr, "width") ? RNA_int_get(op->ptr, "width") :
2201 scene->r.xsch;
2202 colvars->height = RNA_struct_property_is_set(op->ptr, "height") ?
2203 RNA_int_get(op->ptr, "height") :
2204 scene->r.ysch;
2205 }
2206 else if (strip->type == STRIP_TYPE_TEXT) {
2207 TextVars *textvars = static_cast<TextVars *>(strip->effectdata);
2208 textvars->runtime = MEM_new<seq::TextVarsRuntime>(__func__);
2209 seq::text_effect_update_runtime(nullptr, *textvars, int2(scene->r.xsch, scene->r.ysch));
2210 }
2211
2214
2215 /* Place generator effects; others are automatically placed above their inputs. */
2216 if (seq::effect_type_get_min_num_inputs(load_data.effect.type) == 0 &&
2217 (load_data.effect.type != STRIP_TYPE_COMPOSITOR || input1 == nullptr))
2218 {
2219 move_strips(C, op);
2220 }
2221
2222 return OPERATOR_FINISHED;
2223}
2224
2225static bool is_op_for_effect_with_inputs(const Scene *scene, StripType type)
2226{
2227 if (seq::effect_type_get_min_num_inputs(type) != 0) {
2228 return true;
2229 }
2230 /* Adding compositor effect with any selected strip; assuming it will be for that strip. */
2231 if (type == STRIP_TYPE_COMPOSITOR) {
2232 if (seq::select_has_any(scene)) {
2233 return true;
2234 }
2235 }
2236 return false;
2237}
2238
2240 wmOperator *op,
2241 const wmEvent *event)
2242{
2243 bool is_type_set = RNA_struct_property_is_set(op->ptr, "type");
2244 if (!is_type_set) {
2245 BKE_report(op->reports, RPT_ERROR_INVALID_INPUT, "Strip type is not set.");
2246 return OPERATOR_CANCELLED;
2247 }
2248
2249 sequencer_add_init(C, op);
2250
2251 int prop_flag = SEQPROP_LENGTH;
2252 /* When invoking an effect strip which uses inputs, skip guessing of the channel. */
2253 StripType type = StripType(RNA_enum_get(op->ptr, "type"));
2255 prop_flag |= SEQPROP_NOCHAN;
2256 }
2257
2258 sequencer_generic_invoke_xy__internal(C, op, prop_flag, type, event);
2260 sequencer_add_free(C, op);
2261 return retval;
2262}
2263
2265 wmOperator *op,
2266 const PropertyRNA *prop)
2267{
2268 const char *prop_id = RNA_property_identifier(prop);
2269 StripType type = StripType(RNA_enum_get(op->ptr, "type"));
2270
2271 /* Hide start frame and length for effect strips that are locked to their parents' location. */
2273 if (STR_ELEM(prop_id, "frame_start", "length")) {
2274 return false;
2275 }
2276 }
2277 if (type != STRIP_TYPE_COLOR && STR_ELEM(prop_id, "color", "width", "height")) {
2278 return false;
2279 }
2280
2281 return true;
2282}
2283
2285 wmOperatorType * /*ot*/,
2286 PointerRNA *ptr)
2287{
2288 const int type = RNA_enum_get(ptr, "type");
2289
2290 switch (type) {
2291 case STRIP_TYPE_CROSS:
2292 return TIP_("Add a crossfade transition strip for two selected strips with video content");
2293 case STRIP_TYPE_ADD:
2294 return TIP_("Add an add blend mode effect strip for two selected strips with video content");
2295 case STRIP_TYPE_SUB:
2296 return TIP_(
2297 "Add a subtract blend mode effect strip for two selected strips with video content");
2299 return TIP_(
2300 "Add an alpha over blend mode effect strip for two selected strips with video content");
2302 return TIP_(
2303 "Add an alpha under blend mode effect strip for two selected strips with video content");
2305 return TIP_(
2306 "Add a gamma crossfade transition strip for two selected strips with video content");
2307 case STRIP_TYPE_MUL:
2308 return TIP_(
2309 "Add a multiply blend mode effect strip for two selected strips with video content");
2310 case STRIP_TYPE_WIPE:
2311 return TIP_("Add a wipe transition strip for two selected strips with video content");
2312 case STRIP_TYPE_GLOW:
2313 return TIP_("Add a glow effect strip for a single selected strip with video content");
2314 case STRIP_TYPE_COLOR:
2315 return TIP_("Add a color strip to the sequencer");
2316 case STRIP_TYPE_SPEED:
2317 return TIP_("Add a video speed effect strip for a single selected strip with video content");
2319 return TIP_("Add a multicam selector effect strip to the sequencer");
2321 return TIP_("Add an adjustment layer effect strip to the sequencer");
2323 return TIP_(
2324 "Add a gaussian blur effect strip for a single selected strip with video content");
2325 case STRIP_TYPE_TEXT:
2326 return TIP_("Add a text strip to the sequencer");
2328 return TIP_("Add a color mix effect strip to the sequencer");
2330 return TIP_("Add a compositor based effect strip for zero, one, or two selected inputs");
2331 default:
2332 break;
2333 }
2334
2335 /* Use default description. */
2336 return "";
2337}
2338
2340{
2341 PropertyRNA *prop;
2342
2343 /* Identifiers. */
2344 ot->name = "Add Effect Strip";
2345 ot->idname = "SEQUENCER_OT_effect_strip_add";
2346 ot->description = "Add an effect to the sequencer, most are applied on top of existing strips";
2347
2348 /* API callbacks. */
2354
2355 /* Flags. */
2357
2358 prop = RNA_def_enum(ot->srna,
2359 "type",
2362 "Type",
2363 "Sequencer effect type");
2366
2367 /* The following properties are only used when strip is of the Color type. */
2369 ot->srna, "width", 0, 1, INT_MAX, "Width", "Width of the color strip in pixels", 1, INT_MAX);
2370 RNA_def_int(ot->srna,
2371 "height",
2372 0,
2373 1,
2374 SHRT_MAX,
2375 "Height",
2376 "Height of the color strip in pixels",
2377 1,
2378 SHRT_MAX);
2379 prop = RNA_def_float_color(ot->srna,
2380 "color",
2381 3,
2382 nullptr,
2383 0.0f,
2384 1.0f,
2385 "Color",
2386 "Initialize the strip with this color",
2387 0.0f,
2388 1.0f);
2391}
2392
2394
2395} // namespace blender::ed::vse
Main runtime representation of an asset.
File and directory operations.
#define FILE_MAX
#define BLI_path_join(...)
#define STR_ELEM(...)
#define STRNCPY_UTF8(dst, src)
#define RPT_(msgid)
#define BLT_I18NCONTEXT_ID_SEQUENCE
#define TIP_(msgid)
#define BLT_I18NCONTEXT_ID_MOVIECLIP
#define ID_BLEND_PATH(_bmain, _id)
Definition DNA_ID.h:688
#define MAXFRAME
#define STRIP_HAS_PATH(_strip)
Read Blender memory allocation and freeing.
#define RNA_PROP_END
#define RNA_BEGIN(sptr, itemptr, propname)
#define RNA_END
#define RNA_PROP_BEGIN(sptr, itemptr, prop)
#define C
Definition RandGen.cpp:29
#define UI_ITEM_NONE
#define ELEM(...)
#define BLI_assert_msg(a, msg)
#define STREQ(a, b)
constexpr IndexRange()=default
bool contains(const Key &key) const
Definition BLI_set.hh:310
bool add(const Key &key)
Definition BLI_set.hh:248
constexpr StringRef()
bool add(const Key &key)
int64_t size() const
void append(const T &value)
bool is_empty() const
const T & first() const
const T & data(const Action &owning_action) const
void Detect(const FloatImage &image, const DetectOptions &options, vector< Feature > *detected_features)
Definition detect.cc:347
float4 load_data(StoredFloat4 data)
#define SHRT_MAX
#define INT_MAX
ID * asset_local_id_ensure_imported(Main &bmain, const asset_system::AssetRepresentation &asset, int flags=0, const std::optional< eAssetImportMethod > import_method=std::nullopt, const std::optional< ImportInstantiateContext > instantiate_context=std::nullopt, ReportList *reports=nullptr)
void operator_asset_reference_props_register(StructRNA &srna)
const asset_system::AssetRepresentation * operator_asset_reference_props_get_asset_from_all_library(const bContext &C, PointerRNA &ptr, ReportList *reports)
void SEQUENCER_OT_mask_strip_add(wmOperatorType *ot)
static int find_unlocked_unmuted_channel(const Editing *ed, int channel_index)
static int sequencer_generic_invoke_xy_guess_channel(bContext *C, int type)
static void sequencer_disable_one_time_properties(bContext *C, wmOperator *op)
static void sequencer_add_free(bContext *, wmOperator *op)
static void seq_load_apply_generic_options(bContext *C, wmOperator *op, Strip *strip)
static const EnumPropertyItem rna_enum_image_import_type_items[]
static void sequencer_generic_invoke_path__internal(bContext *C, wmOperator *op, const char *identifier)
static bool is_op_for_effect_with_inputs(const Scene *scene, StripType type)
static bool sequencer_add_text_strip_poll_property(const bContext *, wmOperator *op, const PropertyRNA *prop)
static wmOperatorStatus sequencer_add_image_strip_exec(bContext *C, wmOperator *op)
static bool sequencer_add_draw_check_fn(PointerRNA *ptr, PropertyRNA *prop, void *)
static wmOperatorStatus sequencer_add_scene_asset_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static wmOperatorStatus sequencer_add_movie_strip_exec(bContext *C, wmOperator *op)
void SEQUENCER_OT_movieclip_strip_add(wmOperatorType *ot)
static bool seq_load_apply_generic_options_only_test_overlap(bContext *C, wmOperator *op, Strip *strip)
static bool should_handle_overlap(const wmOperator *op)
static bool have_free_channels(bContext *C, wmOperator *op, const int needed_channels, const char **r_error_msg)
static wmOperatorStatus sequencer_add_mask_strip_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static wmOperatorStatus sequencer_add_mask_strip_exec(bContext *C, wmOperator *op)
static std::string sequencer_add_scene_asset_get_description(bContext *C, wmOperatorType *, PointerRNA *ptr)
static wmOperatorStatus sequencer_add_text_strip_exec(bContext *C, wmOperator *op)
void SEQUENCER_OT_add_scene_strip_from_scene_asset(wmOperatorType *ot)
void SEQUENCER_OT_effect_strip_add(wmOperatorType *ot)
static bool sequencer_add_effect_strip_poll_property(const bContext *C, wmOperator *op, const PropertyRNA *prop)
const EnumPropertyItem sequencer_prop_effect_types[]
static void sequencer_generic_invoke_xy__internal(bContext *C, wmOperator *op, int flag, int type, const wmEvent *event)
static void sequencer_add_sound_multiple_strips(bContext *C, wmOperator *op, seq::LoadData *load_data)
static IMB_Proxy_Size seq_get_proxy_size_flags(bContext *C)
static wmOperatorStatus sequencer_add_scene_strip_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static Strip * sequencer_add_text_strip(bContext *C, wmOperator *op, seq::LoadData *load_data, const StringRef text)
static Strip * sequencer_add_text_strip_from_file(bContext *C, wmOperator *op, seq::LoadData *load_data)
static bool sequencer_add_images(bContext *C, wmOperator *op, seq::LoadData &load_data)
static void sequencer_add_image_strip_load_files(wmOperator *op, Scene *scene, Strip *strip, seq::LoadData *load_data, const ImageFrameRange *range)
static void seq_build_proxy(bContext *C, const VectorSet< Strip * > strips)
static wmOperatorStatus sequencer_add_movieclip_strip_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static Scene * sequencer_add_scene_asset(const bContext &C, const asset_system::AssetRepresentation &asset, ReportList &)
static void move_strips(bContext *C, wmOperator *op)
VectorSet< Strip * > strip_effect_get_new_inputs(const Scene *scene, StripType effect_type, bool ignore_active)
static bool sequencer_add_image_sequence_force(bContext *C, wmOperator *op, seq::LoadData &load_data)
static bool sequencer_add_generic_exec(bContext *C, wmOperator *op, seq::LoadData *load_data, Scene *scene, const int num_strips)
static wmOperatorStatus sequencer_add_scene_strip_new_invoke(bContext *C, wmOperator *op, const wmEvent *event)
bool effect_inputs_validate(int have_inputs, int num_inputs, ReportList *reports)
static std::string sequencer_add_effect_strip_get_description(bContext *, wmOperatorType *, PointerRNA *ptr)
void SEQUENCER_OT_movie_strip_add(wmOperatorType *ot)
void sequencer_select_do_updates(const bContext *C, Scene *scene)
static wmOperatorStatus sequencer_add_movie_strip_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static bool is_drag_and_drop(const wmOperator *op, const wmEvent *event)
static EnumPropertyItem strip_new_scene_items[]
void SEQUENCER_OT_scene_strip_add(wmOperatorType *ot)
static wmOperatorStatus sequencer_add_text_strip_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void frame_filename_set(char *dst, size_t dst_maxncpy, const char *filename_stripped, const int frame, const int numdigits, const char *ext)
static void sequencer_generic_props__internal(wmOperatorType *ot, int flag)
static bool op_invoked_by_drop_event(const wmOperator *op)
static bool sequencer_add_sound_single_strip(bContext *C, wmOperator *op, seq::LoadData *load_data)
bool deselect_all_strips(const Scene *scene)
static wmOperatorStatus sequencer_add_effect_strip_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void SEQUENCER_OT_sound_strip_add(wmOperatorType *ot)
static wmOperatorStatus sequencer_add_effect_strip_exec(bContext *C, wmOperator *op)
static wmOperatorStatus sequencer_add_scene_strip_new_exec(bContext *C, wmOperator *op)
static void sequencer_add_init(bContext *, wmOperator *op)
static VectorSet< Strip * > sequencer_add_movie_strips(bContext *C, wmOperator *op, seq::LoadData *load_data)
static wmOperatorStatus sequencer_add_scene_strip_exec(bContext *C, wmOperator *op)
void SEQUENCER_OT_text_strip_add(wmOperatorType *ot)
static wmOperatorStatus sequencer_add_sound_strip_exec(bContext *C, wmOperator *op)
static void seq_load_handle_overlap(bContext *C, wmOperator *op, Span< Strip * > strips)
void SEQUENCER_OT_image_strip_add(wmOperatorType *ot)
static bool load_data_init_from_operator(seq::LoadData *load_data, bContext *C, wmOperator *op)
static void sequencer_file_drop_channel_frame_set(bContext *C, wmOperator *op, const wmEvent *event)
static bool should_move_strips_after_add(const wmOperator *op)
static void sequencer_add_movie_strips_single_file(bContext *C, wmOperator *op, seq::LoadData *load_data, VectorSet< Strip * > &r_strips_added, bool &r_has_overlap)
static wmOperatorStatus sequencer_add_image_strip_invoke(bContext *C, wmOperator *op, const wmEvent *event)
VectorSet< Strip * > all_strips_from_context(bContext *C)
static wmOperatorStatus sequencer_add_movieclip_strip_exec(bContext *C, wmOperator *op)
static wmOperatorStatus sequencer_add_sound_strip_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static void sequencer_add_ui(bContext *, wmOperator *op)
static void sequencer_add_movie_sync_strip(Scene *scene, Strip *strip, Strip *anchor, const double stream_start, const double anchor_start)
void SEQUENCER_OT_scene_strip_add_new(wmOperatorType *ot)
std::string filename(const std::string_view &str, size_t pos)
T clamp(const T &a, const T &min, const T &max)
T min(const T &a, const T &b)
bool proxy_build_start(Main *bmain, Scene *scene, Strip *strip, Set< std::string > *processed_paths, bool build_only_on_bad_performance, Vector< ProxyBuildContext * > &r_queue)
Definition proxy.cc:455
Strip * add_effect_strip(Scene *scene, ListBaseT< Strip > *seqbase, LoadData *load_data)
Definition strip_add.cc:174
eSeqImageFitMethod tool_settings_fit_method_get(Scene *scene)
Definition sequencer.cc:409
Strip * add_image_strip(Main *bmain, Scene *scene, ListBaseT< Strip > *seqbase, LoadData *load_data)
Definition strip_add.cc:245
void transform_translate_strip(Scene *evil_scene, Strip *strip, int delta)
void transform_handle_overlap(Scene *scene, ListBaseT< Strip > *seqbasep, Span< Strip * > source_strips, bool use_sync_markers, Span< Strip * > time_dependent_strips)
IMB_Proxy_Size rendersize_to_proxysize(eSpaceSeq_Proxy_RenderSize render_size)
Definition proxy.cc:137
bool transform_test_overlap(const Scene *scene, Strip *strip1, Strip *strip2)
Editing * editing_get(const Scene *scene)
Definition sequencer.cc:304
void add_image_load_file(Scene *scene, Strip *strip, size_t strip_frame, const char *filename)
Definition strip_add.cc:210
void add_image_set_directory(Strip *strip, const char *dirpath)
Definition strip_add.cc:205
bool select_has_any(const Scene *scene)
void text_effect_update_runtime(const RenderData *context, TextVars &text, const int2 image_size)
void connect(Strip *strip1, Strip *strip2)
bool transform_single_image_check(const Strip *strip)
Editing * editing_ensure(Scene *scene)
Definition sequencer.cc:309
void proxy_set(Strip *strip, bool value)
Definition proxy.cc:771
Strip * select_active_get(const Scene *scene)
constexpr int MAX_CHANNELS
Strip * add_sound_strip(Main *, Scene *, ListBaseT< Strip > *, LoadData *)
Definition strip_add.cc:367
ProxyJob * ED_seq_proxy_job_get(const bContext *C, wmJob *wm_job)
Definition proxy_job.cc:71
void add_image_init_alpha_mode(Main *bmain, Scene *scene, Strip *strip)
Definition strip_add.cc:216
void tool_settings_fit_method_set(Scene *scene, eSeqImageFitMethod fit_method)
Definition sequencer.cc:433
Strip * add_movieclip_strip(Scene *scene, ListBaseT< Strip > *seqbase, LoadData *load_data)
Definition strip_add.cc:151
Strip * add_scene_strip(Scene *scene, ListBaseT< Strip > *seqbase, LoadData *load_data)
Definition strip_add.cc:138
bool retiming_selection_clear(const Editing *ed)
void select_active_set(Scene *scene, Strip *strip)
SeqTimelineChannel * channel_get_by_index(const ListBaseT< SeqTimelineChannel > *channels, const int channel_index)
Definition channels.cc:59
@ SEQ_LOAD_SOUND_MONO
Definition SEQ_add.hh:38
@ SEQ_LOAD_SET_VIEW_TRANSFORM
Definition SEQ_add.hh:40
@ SEQ_LOAD_SOUND_CACHE
Definition SEQ_add.hh:37
@ SEQ_LOAD_MOVIE_SYNC_FPS
Definition SEQ_add.hh:39
eSeqRippleFlag tool_settings_ripple_flag_get(Scene *scene)
Definition sequencer.cc:451
void transform_shuffle_vertical(ListBaseT< Strip > *seqbasep, Span< Strip * > strips, Scene *scene, const int channel_delta)
int effect_type_get_min_num_inputs(StripType type)
Definition effects.cc:347
ListBaseT< SeqTimelineChannel > * channels_displayed_get(const Editing *ed)
Definition channels.cc:26
Strip * add_movie_strip(Main *bmain, Scene *scene, ListBaseT< Strip > *seqbase, LoadData *load_data)
Definition strip_add.cc:394
Strip * add_mask_strip(Scene *scene, ListBaseT< Strip > *seqbase, LoadData *load_data)
Definition strip_add.cc:163
wmJob * ED_seq_proxy_wm_job_get(const bContext *C)
Definition proxy_job.cc:86
int default_strip_length(const double scene_fps)
Definition strip_add.cc:64
eSeqOverlapMode tool_settings_overlap_mode_get(Scene *scene)
Definition sequencer.cc:445
void view2d_region_to_view(const View2D *v2d, float x, float y, float *r_view_x, float *r_view_y) ATTR_NONNULL()
Definition view2d.cc:1651
const EnumPropertyItem * RNA_movieclip_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *prop, bool *r_free)
UserDef U
Definition blender.cc:58
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void RNA_def_enum_funcs(PropertyRNA *prop, EnumPropertyItemFunc itemfunc)
ScrArea * CTX_wm_area(const bContext *C)
char * STRNCPY(char(&dst)[N], const char *src)
int RNA_enum_get(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
@ RPT_ERROR_INVALID_INPUT
Definition BKE_report.hh:42
@ RPT_WARNING
Definition BKE_report.hh:40
void uiTemplateImageFormatViews(ui::Layout *layout, PointerRNA *imfptr, PointerRNA *ptr)
Scene * CTX_data_sequencer_scene(const bContext *C)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
bool BLI_path_abs(char path[FILE_MAX], const char *basepath) ATTR_NONNULL(1
bool WM_operator_poll_or_report_error(bContext *C, wmOperatorType *ot, ReportList *reports)
PropertyRNA * RNA_def_float_color(StructOrFunctionRNA *cont_, const char *identifier, const int len, const float *default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
void WM_operator_properties_free(PointerRNA *ptr)
const char * RNA_property_identifier(const PropertyRNA *prop)
void MOV_close(MovieReader *anim)
Definition movie_read.cc:70
void RNA_string_set(PointerRNA *ptr, const char *name, const char *value)
bool BKE_sound_stream_info_get(Main *main, const char *filepath, int stream, SoundStreamInfo *sound_info)
void RNA_int_set(PointerRNA *ptr, const char *name, int value)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
PointerRNA WM_operator_properties_create_ptr(wmOperatorType *ot)
eSceneCopyMethod
Definition BKE_scene.hh:35
@ SCE_COPY_NEW
Definition BKE_scene.hh:36
@ SCE_COPY_FULL
Definition BKE_scene.hh:39
@ SCE_COPY_LINK_COLLECTION
Definition BKE_scene.hh:38
@ SCE_COPY_EMPTY
Definition BKE_scene.hh:37
std::string RNA_property_string_get(PointerRNA *ptr, PropertyRNA *prop)
bool BLI_path_frame(char *path, size_t path_maxncpy, int frame, int digits) ATTR_NONNULL(1)
int RNA_int_get(PointerRNA *ptr, const char *name)
wmWindow * CTX_wm_window(const bContext *C)
void RNA_enum_set(PointerRNA *ptr, const char *name, int value)
char * BLI_strdupn(const char *str, size_t len) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
MINLINE int max_ii(int a, int b)
@ SEQ_VIEW_SEQUENCE_PREVIEW
int RNA_property_collection_length(PointerRNA *ptr, PropertyRNA *prop)
bool BLI_path_frame_get(const char *path, int *r_frame, int *r_digits_len) ATTR_NONNULL(1
void WM_operator_properties_filesel(wmOperatorType *ot, const int filter, const short type, const eFileSel_Action action, const eFileSel_Flag flag, const short display, const short sort)
bool ED_operator_sequencer_active_editable(bContext *C)
@ USER_SEQ_PROXY_SETUP_AUTOMATIC
void WM_jobs_start(wmWindowManager *wm, wmJob *wm_job)
Definition wm_jobs.cc:498
bool RNA_property_boolean_get(PointerRNA *ptr, PropertyRNA *prop)
Global G
Definition blender.cc:57
const char * BKE_main_blendfile_path(const Main *bmain) ATTR_NONNULL()
Definition main.cc:1058
@ LIB_ID_DUPLICATE_IS_ROOT_ID
void void void const char * BLI_path_basename(const char *path) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
void * BLI_findlink(const ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:541
bool BLI_path_extension_ensure(char *path, size_t path_maxncpy, const char *ext) ATTR_NONNULL(1
char * BLI_file_read_text_as_mem(const char *filepath, size_t pad_bytes, size_t *r_size)
Definition storage.cc:539
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
Definition BLI_rect.hh:207
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
void void BLI_path_split_dir_part(const char *filepath, char *dir, size_t dir_maxncpy) ATTR_NONNULL(1
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
ListBaseT< ImageFrameRange > ED_image_filesel_detect_sequences(StringRefNull blendfile_path, StringRefNull root_path, wmOperator *op, bool detect_udim)
@ ASSET_IMPORT_APPEND
void DEG_id_tag_update(ID *id, unsigned int flags)
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:162
const EnumPropertyItem * RNA_scene_without_sequencer_scene_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *prop, bool *r_free)
@ WM_FILESEL_DIRECTORY
Definition WM_api.hh:1330
@ WM_FILESEL_RELPATH
Definition WM_api.hh:1329
@ WM_FILESEL_SHOW_PROPS
Definition WM_api.hh:1335
@ WM_FILESEL_FILES
Definition WM_api.hh:1333
@ WM_FILESEL_FILEPATH
Definition WM_api.hh:1332
wmWindowManager * CTX_wm_manager(const bContext *C)
int BKE_sound_stream_count(Main *main, const char *filepath)
const EnumPropertyItem * RNA_mask_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *prop, bool *r_free)
void RNA_def_property_subtype(PropertyRNA *prop, PropertySubType subtype)
bool void BLI_path_rel(char path[FILE_MAX], const char *basepath) ATTR_NONNULL(1)
bool RNA_struct_property_is_set(PointerRNA *ptr, const char *identifier)
rcti ED_time_scrub_clamp_scroller_mask(const rcti &scroller_mask)
PointerRNA RNA_pointer_create_discrete(ID *id, StructRNA *type, void *data)
const EnumPropertyItem rna_enum_strip_scale_method_items[]
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
const EnumPropertyItem rna_enum_dummy_NULL_items[]
Definition rna_rna.cc:28
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
Definition BLI_rect.hh:203
void RNA_boolean_set(PointerRNA *ptr, const char *name, bool value)
void RNA_def_property_translation_context(PropertyRNA *prop, const char *context)
void BLI_rcti_init(struct rcti *rect, int xmin, int xmax, int ymin, int ymax)
Definition rct.cc:428
@ USER_SEQ_ED_CONNECT_STRIPS_BY_DEFAULT
wmOperatorType * WM_operatortype_find(const char *idname, bool quiet)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, const int default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
void void void BLI_path_split_file_part(const char *filepath, char *file, size_t file_maxncpy) ATTR_NONNULL(1
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
Definition report.cc:191
@ FILE_OPENFILE
Definition WM_api.hh:1341
Main * CTX_data_main(const bContext *C)
int MOV_get_video_stream_count(MovieReader *anim)
@ ID_RECALC_SEQUENCER_STRIPS
Definition DNA_ID.h:1122
wmOperatorStatus WM_operator_name_call_ptr(bContext *C, wmOperatorType *ot, wm::OpCallContext context, PointerRNA *properties, const wmEvent *event)
@ PROP_SKIP_SAVE
Definition RNA_types.hh:414
@ PROP_ENUM_NO_TRANSLATE
Definition RNA_types.hh:502
@ PROP_HIDDEN
Definition RNA_types.hh:408
wmOperatorStatus WM_enum_search_invoke(bContext *C, wmOperator *op, const wmEvent *)
void DEG_relations_tag_update(Main *bmain)
const EnumPropertyItem rna_enum_strip_overlap_mode_items[]
void RNA_property_boolean_set(PointerRNA *ptr, PropertyRNA *prop, bool value)
bScreen * CTX_wm_screen(const bContext *C)
bool void BLI_path_frame_strip(char *path, char *r_ext, size_t ext_maxncpy) ATTR_NONNULL(1
bool RNA_collection_is_empty(PointerRNA *ptr, const char *name)
@ OPTYPE_REGISTER
Definition WM_types.hh:188
@ OPTYPE_UNDO
Definition WM_types.hh:190
@ OPTYPE_INTERNAL
Definition WM_types.hh:210
std::string RNA_string_get(PointerRNA *ptr, const char *name)
size_t BLI_strlen_utf8(const char *strc) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
@ PROP_COLOR_GAMMA
Definition RNA_types.hh:329
Scene * ED_scene_sequencer_add(Main *bmain, bContext *C, eSceneCopyMethod method)
Definition scene_edit.cc:76
int RNA_property_int_get(PointerRNA *ptr, PropertyRNA *prop)
ARegion * CTX_wm_region(const bContext *C)
bool BLI_rcti_clamp_pt_v(const struct rcti *rect, int xy[2])
void WM_event_add_fileselect(bContext *C, wmOperator *op)
Scene * BKE_scene_duplicate(Main *bmain, Scene *sce, eSceneCopyMethod type, eDupli_ID_Flags duplicate_flags, uint duplicate_options)
Definition scene.cc:1917
MovieReader * openanim_noload(const char *filepath, ImBufFlags flags, int streamindex, bool keep_original_colorspace, ColorManagedColorspaceSettings *colorspace_settings)
void RNA_float_get_array(PointerRNA *ptr, const char *name, float *values)
bool WM_jobs_is_running(const wmJob *wm_job)
Definition wm_jobs.cc:358
void ED_area_tag_redraw(ScrArea *area)
Definition area.cc:784
#define SEQPROP_LENGTH
#define SEQPROP_MOVE
#define SEQPROP_PATHS
#define SEQPROP_VIEW_TRANSFORM
#define SEQPROP_STARTFRAME
#define SEQPROP_NOCHAN
#define SEQPROP_PLAYBACK_RATE
#define SEQPROP_FIT_METHOD
eRegion_Type regiontype
The meta-data of an asset. By creating and giving this for a data-block (ID.asset_data),...
eImageFormat_ViewsFormat views_format
ListBaseT< ImageFrame > frames
Definition ED_image.hh:225
ListBaseT< MovieClip > movieclips
Definition BKE_main.hh:419
ListBaseT< Mask > masks
Definition BKE_main.hh:420
ListBaseT< Scene > scenes
Definition BKE_main.hh:386
ColorManagedViewSettings view_settings
struct RenderData r
ListBaseT< SpaceLink > spacedata
eSpaceSeq_Proxy_RenderSize render_size
eSpaceSeq_Displays view
seq::TextVarsRuntime * runtime
ListBaseT< struct ScrArea > areabase
Vector< ProxyBuildContext * > queue
Definition SEQ_proxy.hh:63
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< StringRef > name_opt, int icon, std::optional< StringRef > placeholder=std::nullopt)
Layout & column(bool align)
void separator(float factor=1.0f, LayoutSeparatorType type=LayoutSeparatorType::Auto)
wmEventType type
Definition WM_types.hh:817
wmOperatorStatus(*) exec(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1125
bool(*) poll_property(const bContext *C, wmOperator *op, const PropertyRNA *prop) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1171
const char * description
Definition WM_types.hh:1115
void(*) cancel(bContext *C, wmOperator *op)
Definition WM_types.hh:1149
void(*) ui(bContext *C, wmOperator *op)
Definition WM_types.hh:1176
bool(*) poll(bContext *C) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1165
wmOperatorStatus(*) invoke(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1141
std::string(*) get_description(bContext *C, wmOperatorType *ot, PointerRNA *ptr)
Definition WM_types.hh:1197
struct ReportList * reports
struct wmOperatorType * type
bke::WindowRuntime * runtime
float length() const
Definition sky_math.h:294