Blender V5.3
sequencer_edit.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 <ranges>
10
11#include "CLG_log.h"
12
13#include "BLI_fileops.hh"
14#include "BLI_listbase.hh"
15#include "BLI_math_vector_c.hh"
16#include "BLI_path_utils.hh"
17#include "BLI_string.hh"
18#include "BLI_string_ref.hh"
19#include "BLI_string_utf8.hh"
20#include "BLI_string_utils.hh"
21#include "BLI_timecode.hh"
22#include "BLI_utildefines.hh"
23#include "BLI_vector.hh"
24
25#include "MEM_guardedalloc.h"
26
27#include "BLT_translation.hh"
28
29#include "DNA_anim_types.h"
30#include "DNA_scene_types.h"
31#include "DNA_sequence_types.h"
32#include "DNA_sound_types.h"
33
34#include "BKE_animsys.hh"
35#include "BKE_context.hh"
36#include "BKE_global.hh"
37#include "BKE_idtype.hh"
38#include "BKE_layer.hh"
39#include "BKE_library.hh"
40#include "BKE_main.hh"
41#include "BKE_report.hh"
42#include "BKE_sound.hh"
43
44#include "SEQ_add.hh"
45#include "SEQ_animation.hh"
46#include "SEQ_channels.hh"
47#include "SEQ_connect.hh"
48#include "SEQ_edit.hh"
49#include "SEQ_effects.hh"
50#include "SEQ_iterator.hh"
51#include "SEQ_prefetch.hh"
52#include "SEQ_relations.hh"
53#include "SEQ_render.hh"
54#include "SEQ_select.hh"
55#include "SEQ_sequencer.hh"
57#include "SEQ_time.hh"
58#include "SEQ_transform.hh"
59#include "SEQ_utils.hh"
60
61#include "ANIM_animdata.hh"
62
63#include "WM_api.hh"
64#include "WM_types.hh"
65
66#include "RNA_define.hh"
67#include "RNA_enum_types.hh"
68#include "RNA_prototypes.hh"
69
70#include "ED_fileselect.hh"
71#include "ED_image.hh"
72#include "ED_numinput.hh"
73#include "ED_object.hh"
74#include "ED_scene.hh"
75#include "ED_screen.hh"
76#include "ED_screen_types.hh"
77#include "ED_sequencer.hh"
78
79#include "UI_interface.hh"
81#include "UI_resources.hh"
82#include "UI_view2d.hh"
83
84#include "DEG_depsgraph.hh"
86
87#include "sequencer_intern.hh"
88#include <cstddef>
89#include <fmt/format.h>
90
91namespace blender::ed::vse {
92
93static CLG_LogRef LOG = {"seq.edit"};
94
95/* -------------------------------------------------------------------- */
98
100{
101 return maskedit_poll(C);
102}
103
105{
106 if (sseq && sseq->mainb == SEQ_DRAW_IMG_IMBUF) {
107 return (seq::active_mask_get(scene) != nullptr);
108 }
109
110 return false;
111}
112
114{
115 SpaceSeq *sseq = CTX_wm_space_seq(C);
116
117 if (sseq) {
119 return check_show_maskedit(sseq, scene);
120 }
121
122 return false;
123}
124
125bool check_show_imbuf(const SpaceSeq &sseq)
126{
127 return (sseq.mainb == SEQ_DRAW_IMG_IMBUF) &&
129}
130
131bool check_show_strip(const SpaceSeq &sseq)
132{
134}
135
137{
138 if (!fcurve->rna_path().startswith("sequence_editor.strips_all[\"")) {
139 return false;
140 }
141
142 if (!fcurve->rna_path().endswith("\"].color")) {
143 return false;
144 }
145
146 return true;
147}
148
150{
151 if (!scene->adt) {
152 return false;
153 }
154 if (!scene->adt->action) {
155 return false;
156 }
157
158 for (FCurve *fcurve : animrig::fcurves_for_assigned_action(scene->adt)) {
160 return true;
161 }
162 }
163
164 return false;
165}
166
168
169/* -------------------------------------------------------------------- */
172
174{
176 if (!scene) {
177 return false;
178 }
179 return (seq::editing_get(scene) != nullptr);
180}
181
183{
184 if (!sequencer_edit_poll(C)) {
185 return false;
186 }
187 ARegion *region = CTX_wm_region(C);
188 if (!(region && (region->regiontype == RGN_TYPE_CHANNELS))) {
189 return false;
190 }
191 return true;
192}
193
198
199#if 0 /* UNUSED */
200bool sequencer_strip_poll(bContext *C)
201{
202 Editing *ed;
203 return (((ed = seq::editing_get(CTX_data_sequencer_scene(C))) != nullptr) && (ed->act_strip != nullptr));
204}
205#endif
206
208{
209 const Scene *scene = CTX_data_sequencer_scene(C);
210 if (!scene || !ID_IS_EDITABLE(&scene->id)) {
211 return false;
212 }
213 const Editing *ed = seq::editing_get(scene);
214 if (!ed) {
215 return false;
216 }
217 const Strip *strip_active = ed->act_strip;
218 if (!strip_active) {
219 CTX_wm_operator_poll_msg_set(C, "No active strip");
220 return false;
221 }
222 return true;
223}
224
226{
227 const Scene *scene = CTX_data_sequencer_scene(C);
228 if (!scene || !ID_IS_EDITABLE(&scene->id)) {
229 return false;
230 }
231 const Editing *ed = seq::editing_get(scene);
232 if (!ed) {
233 return false;
234 }
235 const Strip *strip_active = ed->act_strip;
236 if (!strip_active) {
237 CTX_wm_operator_poll_msg_set(C, "No active strip");
238 return false;
239 }
240 if ((strip_active->flag & SEQ_SELECT) == 0) {
241 CTX_wm_operator_poll_msg_set(C, "Active strip isn't selected");
242 return false;
243 }
244 return true;
245}
246
248{
250 if (!scene) {
251 CTX_wm_operator_poll_msg_set(C, "Context missing sequencer scene");
252 return false;
253 }
254 Editing *ed = seq::editing_get(scene);
255 if (!ed) {
256 return false;
257 }
258 Strip *strip = ed->act_strip;
259 if (!strip) {
260 return false;
261 }
262 return STRIP_HAS_PATH(strip);
263}
264
266{
267 if (!sequencer_edit_poll(C)) {
268 return false;
269 }
270 SpaceSeq *sseq = CTX_wm_space_seq(C);
271 if (sseq == nullptr) {
272 return false;
273 }
275 (sseq->mainb == SEQ_DRAW_IMG_IMBUF)))
276 {
277 return false;
278 }
279 ARegion *region = CTX_wm_region(C);
280 if (!(region && region->regiontype == RGN_TYPE_PREVIEW)) {
281 return false;
282 }
283
284 return true;
285}
286
288{
290 if (!scene) {
291 return false;
292 }
293 Editing *ed = seq::editing_get(scene);
294 if (!ed) {
295 return false;
296 }
297 SpaceSeq *sseq = CTX_wm_space_seq(C);
298 if (sseq == nullptr) {
299 return false;
300 }
301 if (!(ELEM(sseq->view, SEQ_VIEW_PREVIEW) && (sseq->mainb == SEQ_DRAW_IMG_IMBUF))) {
302 return false;
303 }
304 ARegion *region = CTX_wm_region(C);
305 if (!(region && region->regiontype == RGN_TYPE_PREVIEW)) {
306 return false;
307 }
308
309 return true;
310}
311
313{
314 SpaceSeq *sseq = CTX_wm_space_seq(C);
315 if (sseq == nullptr) {
316 return false;
317 }
318 if (!check_show_strip(*sseq)) {
319 return false;
320 }
321 ARegion *region = CTX_wm_region(C);
322 if (!(region && region->regiontype == RGN_TYPE_WINDOW)) {
323 return false;
324 }
325 return true;
326}
327
329{
330 if (!sequencer_edit_poll(C)) {
331 return false;
332 }
334 Editing *ed = seq::editing_get(scene);
335
336 if (ed) {
337 Strip *active_strip = seq::select_active_get(scene);
338 if (active_strip && active_strip->is_effect()) {
339 return true;
340 }
341 }
342
343 return false;
344}
345
347{
348 if (!sequencer_edit_poll(C)) {
349 return false;
350 }
352 Strip *active_strip = seq::select_active_get(scene);
353 if (active_strip && active_strip->effect_num_inputs_get() == 2) {
354 const Strip *input1 = active_strip->input1;
355 const Strip *input2 = active_strip->input2;
356 const bool inputs_fully_overlap = input1->left_handle() == input2->left_handle() &&
357 input1->right_handle(scene) == input2->right_handle(scene);
358 if (seq::effect_is_transition(active_strip->type) && !inputs_fully_overlap) {
360 "Transition inputs can only be swapped if the order is "
361 "ambiguous (i.e. if inputs fully overlap horizontally)");
362 return false;
363 }
364 return true;
365 }
366
367 return false;
368}
369
371
372/* -------------------------------------------------------------------- */
375
377{
378 WorkSpace *workspace = CTX_wm_workspace(&C);
379 if (!workspace || !workspace->sequencer_scene) {
380 return false;
381 }
382 if ((workspace->flags & WORKSPACE_SYNC_SCENE_TIME) == 0) {
383 return false;
384 }
385 SpaceSeq *sseq = CTX_wm_space_seq(&C);
387 if (!sseq && !sprop) {
388 /* We only want to start syncing the time when we're in a sequence editor,
389 * or if updating strip properties.
390 * Changing time in any other editor should just affect the active scene. */
391 return false;
392 }
393 return true;
394}
395
397{
400 if (screen && screen->animtimer) {
401 wmTimer *wt = screen->animtimer;
402 ScreenAnimData *sad = static_cast<ScreenAnimData *>(wt->customdata);
403 if (sad->do_scene_syncing) {
404 return sad->scene;
405 }
406 /* If we're playing a scene that's not a sequence scene, don't try and sync. */
407 return nullptr;
408 }
411 }
412 return nullptr;
413}
414
415const Strip *get_scene_strip_for_time_sync(const Scene *sequencer_scene)
416{
417 const Editing *ed = seq::editing_get(sequencer_scene);
418 if (!ed) {
419 return nullptr;
420 }
421 ListBaseT<Strip> *seqbase = seq::active_seqbase_get(ed);
422 const ListBaseT<SeqTimelineChannel> *channels = seq::channels_displayed_get(ed);
424 sequencer_scene, seqbase, sequencer_scene->r.cfra);
425 /* Ignore effect strips, sound strips and muted strips. */
426 query_strips.remove_if([&](const Strip *strip) {
427 return strip->is_effect() || strip->type == STRIP_TYPE_SOUND ||
428 seq::render_is_muted(channels, strip);
429 });
430 Vector<Strip *> strips = query_strips.extract_vector();
431 /* Sort strips by channel. */
432 std::ranges::sort(strips,
433 [](const Strip *a, const Strip *b) { return a->channel > b->channel; });
434 /* Get the top-most scene strip. */
435 for (const Strip *strip : strips) {
436 if (strip->type == STRIP_TYPE_SCENE) {
437 return strip;
438 }
439 }
440 return nullptr;
441}
442
444{
445 Scene *sequencer_scene = get_sequencer_scene_for_time_sync(C);
446 if (!sequencer_scene) {
447 return;
448 }
449
450 wmWindow *win = CTX_wm_window(&C);
451 const Strip *scene_strip = get_scene_strip_for_time_sync(sequencer_scene);
452 if (!scene_strip || !scene_strip->scene) {
453 /* No scene strip with scene found. Switch to pinned scene. */
454 Main *bmain = CTX_data_main(&C);
455 WM_window_set_active_scene(bmain, &C, win, sequencer_scene);
456 return;
457 }
458
460 Object *prev_obact = BKE_view_layer_active_object_get(view_layer);
461
462 Scene *active_scene = WM_window_get_active_scene(win);
463 if (active_scene != scene_strip->scene) {
464 /* Sync active scene in window. */
465 Main *bmain = CTX_data_main(&C);
466 WM_window_set_active_scene(bmain, &C, win, scene_strip->scene);
467 active_scene = scene_strip->scene;
468 }
469 Object *camera = [&]() -> Object * {
470 if (scene_strip->scene_camera) {
471 return scene_strip->scene_camera;
472 }
473 return scene_strip->scene->camera;
474 }();
475 if (camera) {
476 /* Sync camera in any 3D view that uses camera view. */
477 PointerRNA camera_ptr = RNA_id_pointer_create(&camera->id);
479 for (ScrArea &area : screen->areabase) {
480 for (SpaceLink &sl : area.spacedata) {
481 if (sl.spacetype != SPACE_VIEW3D) {
482 continue;
483 }
484 View3D *view3d = reinterpret_cast<View3D *>(&sl);
485 if (view3d->camera == camera) {
486 continue;
487 }
488 /* HACK: This should not hijack the local camera of 3d viewports. */
489 PointerRNA view3d_ptr = RNA_pointer_create_discrete(&screen->id, RNA_SpaceView3D, view3d);
490 RNA_boolean_set(&view3d_ptr, "use_local_camera", true);
491 RNA_pointer_set(&view3d_ptr, "camera", camera_ptr);
492 }
493 }
494 }
495
496 /* Compute the scene time based on the scene strip. */
497 const float frame_index = seq::give_frame_index(
498 sequencer_scene, scene_strip, sequencer_scene->r.cfra) +
499 active_scene->r.sfra + scene_strip->anim_startofs;
500 if (active_scene->r.flag & SCER_SHOW_SUBFRAME) {
501 active_scene->r.cfra = int(frame_index);
502 active_scene->r.subframe = frame_index - int(frame_index);
503 }
504 else {
505 active_scene->r.cfra = round_fl_to_int(frame_index);
506 active_scene->r.subframe = 0.0f;
507 }
508 FRAMENUMBER_MIN_CLAMP(active_scene->r.cfra);
509
510 /* Try to sync the object mode of the active object. */
511 if (prev_obact) {
513 if (obact && prev_obact->type == obact->type) {
514 object::mode_set(&C, prev_obact->mode);
515 }
516 }
517
521}
522
524
525/* -------------------------------------------------------------------- */
528
530{
532 const bool do_all = RNA_boolean_get(op->ptr, "all");
533 const Editing *ed = seq::editing_get(scene);
534
535 seq::edit_remove_gaps(scene, ed->current_strips(), scene->r.cfra, do_all);
536
539
540 return OPERATOR_FINISHED;
541}
542
544{
545 /* Identifiers. */
546 ot->name = "Remove Gaps";
547 ot->idname = "SEQUENCER_OT_gap_remove";
548 ot->description =
549 "Remove gap at current frame to first strip at the right, independent of selection or "
550 "locked state of strips";
551
552 /* API callbacks. */
553 // ot->invoke = sequencer_snap_invoke;
556
557 /* Flags. */
559
560 RNA_def_boolean(ot->srna, "all", false, "All Gaps", "Do all gaps to right of current frame");
561}
562
564
565/* -------------------------------------------------------------------- */
568
570{
572 const int frames = RNA_int_get(op->ptr, "frames");
573 const Editing *ed = seq::editing_get(scene);
574 seq::transform_strips_after_frame(scene, ed->current_strips(), scene->r.cfra, frames);
575
577
578 return OPERATOR_FINISHED;
579}
580
582{
583 /* Identifiers. */
584 ot->name = "Insert Gaps";
585 ot->idname = "SEQUENCER_OT_gap_insert";
586 ot->description =
587 "Insert gap at current frame to first strips at the right, independent of selection or "
588 "locked state of strips";
589
590 /* API callbacks. */
591 // ot->invoke = sequencer_snap_invoke;
594
595 /* Flags. */
597
598 RNA_def_int(ot->srna,
599 "frames",
600 10,
601 0,
602 INT_MAX,
603 "Frames",
604 "Frames to insert after current strip",
605 0,
606 1000);
607}
608
610
611/* -------------------------------------------------------------------- */
614
615static seq::Side mouse_frame_side_get(View2D *v2d, short mouse_x, int frame)
616{
617 int mval[2];
618 float mouseloc[2];
619
620 mval[0] = mouse_x;
621 mval[1] = 0;
622
623 /* Choose the side based on which side of the current frame the mouse is on. */
624 ui::view2d_region_to_view(v2d, mval[0], mval[1], &mouseloc[0], &mouseloc[1]);
625
626 return mouseloc[0] > frame ? seq::Side::Right : seq::Side::Left;
627}
628
630{
632
633 Editing *ed = seq::editing_get(scene);
634 const ListBaseT<SeqTimelineChannel> *channels = seq::channels_displayed_get(ed);
635 const bool keep_offset = RNA_boolean_get(op->ptr, "keep_offset");
636 const int snap_frame = RNA_int_get(op->ptr, "frame");
637 const auto snap_side = seq::Side(RNA_enum_get(op->ptr, "side"));
638
639 VectorSet<Strip *> selected = seq::query_selected_strips(ed->current_strips());
640 selected.remove_if([&](Strip *strip) { return seq::transform_is_locked(channels, strip); });
641
642 if (selected.is_empty()) {
643 return OPERATOR_CANCELLED;
644 }
645
646 /* Get distance from a strip to the snap frame. This is based on `snap_side`:
647 * behavior feels more natural when mouse cursor on the right side of the snap frame means that
648 * the whole strip ends up on the right, and left side -> whole strip on the left. */
649 auto strip_snap_delta_get = [&](Strip *strip) {
650 return (snap_side == seq::Side::Right) ? snap_frame - strip->left_handle() :
651 snap_frame - strip->right_handle(scene);
652 };
653
654 std::optional<int> group_delta;
655 if (keep_offset) {
656 /* Try to use the active strip as the snap anchor. */
657 Strip *strip_anchor = seq::select_active_get(scene);
658 /* Fallback to the closest selected strip to the playhead. */
659 if (strip_anchor == nullptr) {
660 int best_dist = std::numeric_limits<int>::max();
661 for (Strip *strip : selected) {
662 const int dist = math::min(math::abs(snap_frame - strip->left_handle()),
663 math::abs(snap_frame - strip->right_handle(scene)));
664 if (dist < best_dist) {
665 best_dist = dist;
666 strip_anchor = strip;
667 }
668 }
669 }
670 else if (!(strip_anchor->flag & SEQ_SELECT)) {
671 strip_anchor->flag |= SEQ_SELECT;
672 selected.add(strip_anchor);
673 }
674
675 const bool left_sel = strip_anchor->flag & SEQ_LEFTSEL;
676 const bool right_sel = strip_anchor->flag & SEQ_RIGHTSEL;
677 if (left_sel) {
678 group_delta = snap_frame - strip_anchor->left_handle();
679 }
680 if (right_sel) {
681 const int right_delta = snap_frame - strip_anchor->right_handle(scene);
682 /* If both handles are selected, overwrite `group_delta` only if `right_delta` is smaller. */
683 if (!group_delta.has_value() || math::abs(right_delta) < group_delta) {
684 group_delta = right_delta;
685 }
686 }
687
688 /* No handles selected. */
689 if (!group_delta.has_value()) {
690 group_delta = strip_snap_delta_get(strip_anchor);
691 }
692 }
693
694 for (Strip *strip : selected) {
696 continue;
697 }
698 const bool left_sel = strip->flag & SEQ_LEFTSEL;
699 const bool right_sel = strip->flag & SEQ_RIGHTSEL;
700
701 if (left_sel) {
702 strip->left_handle_set(scene,
703 group_delta ? (strip->left_handle() + *group_delta) : snap_frame);
704 }
705 if (right_sel) {
706 strip->right_handle_set(
707 scene, group_delta ? (strip->right_handle(scene) + *group_delta) : snap_frame);
708 }
709
710 if (!left_sel && !right_sel) {
712 scene, strip, group_delta ? *group_delta : strip_snap_delta_get(strip));
713 }
715 }
716
717 seq::transform_handle_overlap(scene, ed->current_strips(), selected, false);
718
719 /* Recalculate bounds of effect strips, offsetting the keyframes if not snapping any handles. */
720 for (Strip *strip : selected) {
721 if (strip->is_effect()) {
722 const bool either_handle_selected = (strip->flag & (SEQ_LEFTSEL | SEQ_RIGHTSEL)) != 0;
723
724 if (strip->input1 && (strip->input1->flag & SEQ_SELECT)) {
725 if (!either_handle_selected) {
727 scene, strip, group_delta ? *group_delta : (snap_frame - strip->left_handle()));
728 }
729 }
730 else if (strip->input2 && (strip->input2->flag & SEQ_SELECT)) {
731 if (!either_handle_selected) {
733 scene, strip, group_delta ? *group_delta : (snap_frame - strip->left_handle()));
734 }
735 }
736 }
737 }
738
741
742 return OPERATOR_FINISHED;
743}
744
746{
749
750 int snap_frame = scene->r.cfra;
751 RNA_int_set(op->ptr, "frame", snap_frame);
752
753 auto snap_side = seq::Side(RNA_enum_get(op->ptr, "side"));
754 if (ED_operator_sequencer_active(C) && v2d) {
755 snap_side = mouse_frame_side_get(v2d, event->mval[0], snap_frame);
756 }
757 else {
758 snap_side = seq::Side::Left;
759 }
760
761 RNA_enum_set(op->ptr, "side", int(snap_side));
762 return sequencer_snap_exec(C, op);
763}
764
766{
767 /* Identifiers. */
768 ot->name = "Snap Strips to the Current Frame";
769 ot->idname = "SEQUENCER_OT_snap";
770 ot->description =
771 "Snap strips to the current frame, using the active (or closest) strip as the anchor, and "
772 "the mouse cursor relative to the playhead to determine the side of the playhead to snap to";
773
774 /* API callbacks. */
778
779 /* Flags. */
781
782 RNA_def_int(ot->srna,
783 "frame",
784 0,
785 INT_MIN,
786 INT_MAX,
787 "Frame",
788 "Frame where selected strips will be snapped",
789 INT_MIN,
790 INT_MAX);
791
792 PropertyRNA *prop;
793 prop = RNA_def_enum(
794 ot->srna,
795 "side",
797 int(seq::Side::Left),
798 "Snap Side",
799 "Which side of the playhead strips should snap to when no handles are selected");
801
803 ot->srna,
804 "keep_offset",
805 true,
806 "Keep Offset",
807 "Whether the selection should be snapped as a whole or by each individual strip");
808}
809
811
812/* -------------------------------------------------------------------- */
815
816/* Modal Keymap */
817enum {
823};
824
846
848{
849 static const EnumPropertyItem modal_items[] = {
850 {SLIP_MODAL_CONFIRM, "CONFIRM", 0, "Confirm", ""},
851 {SLIP_MODAL_CANCEL, "CANCEL", 0, "Cancel", ""},
852
853 {SLIP_MODAL_PRECISION_ENABLE, "PRECISION_ENABLE", 0, "Precision Enable", ""},
854 {SLIP_MODAL_PRECISION_DISABLE, "PRECISION_DISABLE", 0, "Precision Disable", ""},
855 {SLIP_MODAL_CLAMP_TOGGLE, "CLAMP_TOGGLE", 0, "Clamp Toggle", ""},
856
857 {0, nullptr, 0, nullptr, nullptr},
858 };
859
860 wmKeyMap *keymap = WM_modalkeymap_find(keyconf, "Slip Modal");
861
862 /* This function is called for each space-type, only needs to add map once. */
863 if (keymap && keymap->modal_items) {
864 return;
865 }
866
867 keymap = WM_modalkeymap_ensure(keyconf, "Slip Modal", modal_items);
868
869 /* Assign map to operators. */
870 WM_modalkeymap_assign(keymap, "SEQUENCER_OT_slip");
871}
872
873static void slip_draw_status(bContext *C, const wmOperator *op)
874{
875 SlipData *data = static_cast<SlipData *>(op->customdata);
876
877 WorkspaceStatus status(C);
878
879 status.opmodal(IFACE_("Confirm"), op->type, SLIP_MODAL_CONFIRM);
880 status.opmodal(IFACE_("Cancel"), op->type, SLIP_MODAL_CANCEL);
881
882 status.opmodal(IFACE_("Precision"), op->type, SLIP_MODAL_PRECISION_ENABLE, data->precision);
883
884 if (data->can_clamp) {
885 status.opmodal(IFACE_("Clamp"), op->type, SLIP_MODAL_CLAMP_TOGGLE, data->clamp);
886 }
887 if (data->clamp_warning) {
888 status.item(TIP_("Not enough content to clamp strip(s)"), ICON_STATUS_WARNING_FILLED);
889 }
890}
891
892static void slip_update_header(const Scene *scene,
893 ScrArea *area,
894 SlipData *data,
895 const float offset)
896{
897 if (area == nullptr) {
898 return;
899 }
900
901 char msg[UI_MAX_DRAW_STR];
902 if (hasNumInput(&data->num_input)) {
903 char num_str[NUM_STR_REP_LEN];
904 outputNumInput(&data->num_input, num_str, scene->unit);
905 SNPRINTF_UTF8(msg, IFACE_("Slip Offset: Frames: %s"), num_str);
906 }
907 else {
908 int frame_offset = std::trunc(offset);
909 if (data->show_subframe) {
910 float subframe_offset_sec = (offset - std::trunc(offset)) / scene->frames_per_second();
911 SNPRINTF_UTF8(msg,
912 IFACE_("Slip Offset: Frames: %d Sound Offset: %.3f"),
913 frame_offset,
914 subframe_offset_sec);
915 }
916 else {
917 SNPRINTF_UTF8(msg, IFACE_("Slip Offset: Frames: %d"), frame_offset);
918 }
919 }
920
921 ED_area_status_text(area, msg);
922}
923
924static SlipData *slip_data_init(bContext *C, const wmOperator *op, const wmEvent *event)
925{
926 const Scene *scene = CTX_data_sequencer_scene(C);
927 const Editing *ed = seq::editing_get(scene);
928 const View2D *v2d = ui::view2d_fromcontext(C);
929
930 SlipData *data = MEM_new<SlipData>("slipdata");
931
932 VectorSet<Strip *> strips;
933 if (RNA_boolean_get(op->ptr, "use_cursor_position") && event) {
934 Strip *strip = strip_under_mouse_get(scene, v2d, event->mval);
935 if (strip) {
936 strips.add(strip);
937 }
938 if (!RNA_boolean_get(op->ptr, "ignore_connections")) {
940 for (Strip *connection : connections) {
941 strips.add(connection);
942 }
943 }
944 }
945 else {
946 strips = seq::query_selected_strips(ed->current_strips());
947 }
948
949 const ListBaseT<SeqTimelineChannel> *channels = seq::channels_displayed_get(
950 seq::editing_get(scene));
951 strips.remove_if([&](Strip *strip) {
952 return (seq::transform_single_image_check(strip) || seq::transform_is_locked(channels, strip));
953 });
954 if (strips.is_empty()) {
955 MEM_SAFE_DELETE(data);
956 return nullptr;
957 }
958 data->strips = strips;
959
960 data->show_subframe = false;
961 data->clamp_warning = false;
962 data->can_clamp = false;
963
964 const bool clamp_default = (U.sequencer_editor_flag & USER_SEQ_ED_CLAMP_STRIPS_BY_DEFAULT);
965 data->clamp = clamp_default;
966
967 for (Strip *strip : strips) {
968 strip->runtime->flag |= seq::StripRuntimeFlag::ShowOffsets;
969
970 /* If any strips start out with hold offsets visible, disable clamping on initialization. */
971 if (clamp_default && (strip->startofs < 0 || strip->end_offset() < 0)) {
972 data->clamp = false;
973 }
974 /* If any strips do not have enough underlying content to
975 * fill their bounds, show a warning. */
976 if (strip->content_length() < strip->right_handle(scene) - strip->left_handle()) {
977 data->clamp_warning = true;
978 }
979 /* Strip exists with enough content, we can clamp. */
980 else {
981 data->can_clamp = true;
982 }
983 if (strip->type == STRIP_TYPE_SOUND) {
984 data->show_subframe = true;
985 }
986 }
987
988 return data;
989}
990
992{
994 ScrArea *area = CTX_wm_area(C);
996
997 SlipData *data = slip_data_init(C, op, event);
998 if (data == nullptr) {
999 return OPERATOR_CANCELLED;
1000 }
1001 op->customdata = data;
1002
1003 initNumInput(&data->num_input);
1005 v2d, event->mval[0], event->mval[1], &data->init_mouse_co[0], &data->init_mouse_co[1]);
1006 data->precision = false;
1007 data->prev_offset = 0.0f;
1008 data->prev_mval_x = event->mval[0];
1009 data->virtual_mval_x = event->mval[0];
1010
1011 slip_draw_status(C, op);
1012 slip_update_header(scene, area, data, 0.0f);
1013
1015
1016 /* Enable cursor wrapping. */
1018
1019 /* Notify so we draw extensions immediately. */
1021
1022 G.moving |= G_TRANSFORM_SEQ;
1023
1025}
1026
1028 bContext *C, wmOperator *op, Scene *scene, SlipData *data, const float delta)
1029{
1030 float new_offset = data->prev_offset + delta;
1031 /* Calculate rounded whole frames between offsets, which cannot be determined from `delta` alone.
1032 * For example, 0.9 -> 1.0 would have a `delta` of 0.1 and a `frame_delta` of 1. */
1033 int frame_delta = std::trunc(new_offset) - std::trunc(data->prev_offset);
1034
1035 float subframe_delta = 0.0f;
1036 /* Only apply subframe delta if the input is not an integer. */
1037 if (std::trunc(delta) != delta) {
1038 /* Note that `subframe_delta` has opposite sign to `frame_delta`
1039 * when `abs(delta)` < `abs(frame_delta)` to undo its effect. */
1040 subframe_delta = delta - frame_delta;
1041 }
1042
1043 bool slip_keyframes = RNA_boolean_get(op->ptr, "slip_keyframes");
1044 for (Strip *strip : data->strips) {
1045 seq::time_slip_strip(scene, strip, frame_delta, subframe_delta, slip_keyframes);
1046 seq::relations_invalidate_cache(scene, strip);
1047
1049 /* Reconstruct handle clamp state from first principles. */
1050 if (data->clamp == true) {
1051 if (strip->left_handle() == strip->content_start()) {
1052 strip->runtime->flag |= seq::StripRuntimeFlag::ClampedLH;
1053 }
1054 if (strip->right_handle(scene) == strip->content_end(scene)) {
1055 strip->runtime->flag |= seq::StripRuntimeFlag::ClampedRH;
1056 }
1057 }
1058 }
1059
1061
1062 RNA_float_set(op->ptr, "offset", new_offset);
1063 data->prev_offset = new_offset;
1064}
1065
1066static void slip_cleanup(bContext *C, wmOperator *op, Scene *scene)
1067{
1068 ScrArea *area = CTX_wm_area(C);
1069 SlipData *data = static_cast<SlipData *>(op->customdata);
1070
1071 for (Strip *strip : data->strips) {
1073 strip->runtime->flag &= ~seq::StripRuntimeFlag::ShowOffsets;
1074 }
1075
1076 MEM_SAFE_DELETE(data);
1077 if (area) {
1078 ED_area_status_text(area, nullptr);
1079 }
1080 ED_workspace_status_text(C, nullptr);
1083
1084 G.moving &= ~G_TRANSFORM_SEQ;
1085}
1086
1087/* Returns clamped offset delta relative to current strip positions,
1088 * which is the sum of the frame delta and the subframe delta. */
1089static float slip_apply_clamp(const Scene *scene, const SlipData *data, float *r_offset)
1090{
1091 float offset_delta = *r_offset - data->prev_offset;
1092
1093 if (data->can_clamp) {
1094 for (Strip *strip : data->strips) {
1095 const float unclamped_start = strip->content_start() + strip->sound_offset + offset_delta;
1096 const float unclamped_end = strip->content_end(scene) + strip->sound_offset + offset_delta;
1097
1098 const float left_handle = strip->left_handle();
1099 const float right_handle = strip->right_handle(scene);
1100
1101 float diff = 0;
1102
1103 /* Clamp hold offsets if the option is currently enabled
1104 * and if there are enough frames to fill the strip. */
1105 if (data->clamp && strip->content_length() >= right_handle - left_handle) {
1106 if (unclamped_start > left_handle) {
1107 diff = left_handle - unclamped_start;
1108 }
1109 else if (unclamped_end < right_handle) {
1110 diff = right_handle - unclamped_end;
1111 }
1112 }
1113 /* Always make sure each strip contains at least 1 frame of content,
1114 * even if the user hasn't enabled clamping. */
1115 else {
1116 if (unclamped_start > right_handle - 1) {
1117 diff = right_handle - 1 - unclamped_start;
1118 }
1119
1120 if (unclamped_end < left_handle + 1) {
1121 diff = left_handle + 1 - unclamped_end;
1122 }
1123 }
1124
1125 *r_offset += diff;
1126 offset_delta += diff;
1127 }
1128 }
1129
1130 return offset_delta;
1131}
1132
1134{
1136
1137 SlipData *data = slip_data_init(C, op, nullptr);
1138 if (data == nullptr) {
1139 return OPERATOR_CANCELLED;
1140 }
1141 op->customdata = data;
1142
1143 float offset = RNA_float_get(op->ptr, "offset");
1144 slip_apply_clamp(scene, data, &offset);
1145
1146 slip_strips_delta(C, op, scene, data, offset);
1147
1148 slip_cleanup(C, op, scene);
1149 return OPERATOR_FINISHED;
1150}
1151
1153 bContext *C, wmOperator *op, ScrArea *area, SlipData *data, Scene *scene)
1154{
1155 float offset;
1156 applyNumInput(&data->num_input, &offset);
1157
1158 const float offset_delta = slip_apply_clamp(scene, data, &offset);
1159 slip_update_header(scene, area, data, offset);
1160 RNA_float_set(op->ptr, "offset", offset);
1161
1162 slip_strips_delta(C, op, scene, data, offset_delta);
1163
1165}
1166
1168{
1171 SlipData *data = static_cast<SlipData *>(op->customdata);
1172 ScrArea *area = CTX_wm_area(C);
1173 const bool has_num_input = hasNumInput(&data->num_input);
1174
1175 if (event->val == KM_PRESS && handleNumInput(C, &data->num_input, event)) {
1176 slip_handle_num_input(C, op, area, data, scene);
1178 }
1179
1180 if (event->type == EVT_MODAL_MAP) {
1181 switch (event->val) {
1182 case SLIP_MODAL_CONFIRM: {
1183 slip_cleanup(C, op, scene);
1184 return OPERATOR_FINISHED;
1185 }
1186 case SLIP_MODAL_CANCEL: {
1187 slip_strips_delta(C, op, scene, data, -data->prev_offset);
1188 slip_cleanup(C, op, scene);
1189 return OPERATOR_CANCELLED;
1190 }
1192 if (!has_num_input) {
1193 data->precision = true;
1194 /* Align virtual mouse pointer with the truncated frame to avoid jumps. */
1195 float mouse_co[2];
1196 ui::view2d_region_to_view(v2d, data->virtual_mval_x, 0.0f, &mouse_co[0], &mouse_co[1]);
1197 float offset = mouse_co[0] - data->init_mouse_co[0];
1198 float subframe_offset = offset - std::trunc(offset);
1199 data->virtual_mval_x += -subframe_offset * ui::view2d_scale_get_x(v2d);
1200 }
1201 break;
1203 if (!has_num_input) {
1204 data->precision = false;
1205 /* If we exit precision mode, make sure we undo the fractional adjustments and align the
1206 * virtual mouse pointer. */
1207 float to_nearest_frame = -(data->prev_offset - round_fl_to_int(data->prev_offset));
1208 slip_strips_delta(C, op, scene, data, to_nearest_frame);
1209 data->virtual_mval_x += to_nearest_frame * ui::view2d_scale_get_x(v2d);
1210 }
1211 break;
1213 data->clamp = !data->clamp;
1214 break;
1215 default:
1216 break;
1217 }
1218 }
1219
1220 if (event->type == MOUSEMOVE || event->val == SLIP_MODAL_PRECISION_DISABLE ||
1221 event->val == SLIP_MODAL_CLAMP_TOGGLE)
1222 {
1223 if (!has_num_input) {
1224 float mouse_x_delta = event->mval[0] - data->prev_mval_x;
1225 data->prev_mval_x += mouse_x_delta;
1226 if (data->precision) {
1227 mouse_x_delta *= 0.1f;
1228 }
1229 data->virtual_mval_x += mouse_x_delta;
1230
1231 float mouse_co[2];
1232 ui::view2d_region_to_view(v2d, data->virtual_mval_x, 0.0f, &mouse_co[0], &mouse_co[1]);
1233 float offset = mouse_co[0] - data->init_mouse_co[0];
1234 if (!data->precision) {
1235 offset = std::trunc(offset);
1236 }
1237
1238 float clamped_offset = offset;
1239 float clamped_offset_delta = slip_apply_clamp(scene, data, &clamped_offset);
1240 /* Also adjust virtual mouse pointer after clamp is applied. */
1241 data->virtual_mval_x += (clamped_offset - offset) * ui::view2d_scale_get_x(v2d);
1242
1243 slip_strips_delta(C, op, scene, data, clamped_offset_delta);
1244 slip_update_header(scene, area, data, clamped_offset);
1245
1247 }
1248 }
1249
1250 slip_draw_status(C, op);
1251
1253}
1254
1256{
1257 /* Identifiers. */
1258 ot->name = "Slip Strips";
1259 ot->idname = "SEQUENCER_OT_slip";
1260 ot->description = "Slip the contents of selected strips";
1261
1262 /* API callbacks. */
1267
1268 /* Flags. */
1270
1271 /* Properties. */
1272 PropertyRNA *prop;
1273
1274 prop = RNA_def_float(ot->srna,
1275 "offset",
1276 0,
1277 -FLT_MAX,
1278 FLT_MAX,
1279 "Offset",
1280 "Offset to the data of the strip",
1281 -FLT_MAX,
1282 FLT_MAX);
1283 RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 100, 0);
1285 "slip_keyframes",
1286 false,
1287 "Slip Keyframes",
1288 "Move the keyframes alongside the media");
1290 "use_cursor_position",
1291 false,
1292 "Use Cursor Position",
1293 "Slip strips under mouse cursor instead of all selected strips");
1295 "ignore_connections",
1296 false,
1297 "Ignore Connections",
1298 "Do not slip connected strips if using cursor position");
1299}
1300
1302
1303/* -------------------------------------------------------------------- */
1306
1308{
1311
1312 for (Strip *strip : strips) {
1313 if (!RNA_boolean_get(op->ptr, "unselected")) {
1314 if (strip->flag & SEQ_SELECT) {
1315 strip->flag |= SEQ_MUTE;
1316 seq::relations_invalidate_cache(scene, strip);
1317 }
1318 }
1319 else {
1320 if ((strip->flag & SEQ_SELECT) == 0) {
1321 strip->flag |= SEQ_MUTE;
1322 seq::relations_invalidate_cache(scene, strip);
1323 }
1324 }
1325 }
1326
1328
1331
1332 return OPERATOR_FINISHED;
1333}
1334
1336{
1337 /* Identifiers. */
1338 ot->name = "Mute Strips";
1339 ot->idname = "SEQUENCER_OT_mute";
1340 ot->description = "Mute (un)selected strips";
1341
1342 /* API callbacks. */
1345
1346 /* Flags. */
1348
1350 ot->srna, "unselected", false, "Unselected", "Mute unselected rather than selected strips");
1351}
1352
1354
1355/* -------------------------------------------------------------------- */
1358
1360{
1362 Editing *ed = seq::editing_get(scene);
1363 ARegion *region = CTX_wm_region(C);
1364 const bool is_preview = region && (region->regiontype == RGN_TYPE_PREVIEW) &&
1366 for (Strip &strip : *ed->current_strips()) {
1367 if (is_preview) {
1368 if (strip.intersects_frame(scene, scene->r.cfra) && strip.type != STRIP_TYPE_SOUND) {
1369 strip.flag &= ~SEQ_MUTE;
1370 seq::relations_invalidate_cache(scene, &strip);
1371 }
1372 }
1373 else if (!RNA_boolean_get(op->ptr, "unselected")) {
1374 if (strip.flag & SEQ_SELECT) {
1375 strip.flag &= ~SEQ_MUTE;
1376 seq::relations_invalidate_cache(scene, &strip);
1377 }
1378 }
1379 else {
1380 if ((strip.flag & SEQ_SELECT) == 0) {
1381 strip.flag &= ~SEQ_MUTE;
1382 seq::relations_invalidate_cache(scene, &strip);
1383 }
1384 }
1385 }
1386
1388
1391
1392 return OPERATOR_FINISHED;
1393}
1394
1396{
1397 /* Identifiers. */
1398 ot->name = "Unmute Strips";
1399 ot->idname = "SEQUENCER_OT_unmute";
1400 ot->description = "Unmute (un)selected strips";
1401
1402 /* API callbacks. */
1405
1406 /* Flags. */
1408
1410 "unselected",
1411 false,
1412 "Unselected",
1413 "Unmute unselected rather than selected strips");
1414}
1415
1417
1418/* -------------------------------------------------------------------- */
1421
1423{
1425 Editing *ed = seq::editing_get(scene);
1426
1427 for (Strip &strip : *ed->current_strips()) {
1428 if (strip.flag & SEQ_SELECT) {
1429 strip.flag |= SEQ_LOCK;
1430 }
1431 }
1432
1434
1435 return OPERATOR_FINISHED;
1436}
1437
1439{
1440 /* Identifiers. */
1441 ot->name = "Lock Strips";
1442 ot->idname = "SEQUENCER_OT_lock";
1443 ot->description = "Lock strips so they cannot be transformed";
1444
1445 /* API callbacks. */
1448
1449 /* Flags. */
1451}
1452
1454
1455/* -------------------------------------------------------------------- */
1458
1460{
1462 Editing *ed = seq::editing_get(scene);
1463
1464 for (Strip &strip : *ed->current_strips()) {
1465 if (strip.flag & SEQ_SELECT) {
1466 strip.flag &= ~SEQ_LOCK;
1467 }
1468 }
1469
1471
1472 return OPERATOR_FINISHED;
1473}
1474
1476{
1477 /* Identifiers. */
1478 ot->name = "Unlock Strips";
1479 ot->idname = "SEQUENCER_OT_unlock";
1480 ot->description = "Unlock strips so they can be transformed";
1481
1482 /* API callbacks. */
1485
1486 /* Flags. */
1488}
1489
1491
1492/* -------------------------------------------------------------------- */
1495
1497{
1499 Editing *ed = seq::editing_get(scene);
1500 ListBaseT<Strip> *active_seqbase = seq::active_seqbase_get(ed);
1501
1502 VectorSet<Strip *> selected = seq::query_selected_strips(active_seqbase);
1503
1504 if (selected.is_empty()) {
1505 return OPERATOR_CANCELLED;
1506 }
1507
1508 const bool toggle = RNA_boolean_get(op->ptr, "toggle");
1509 if (toggle && seq::are_strips_connected_together(selected)) {
1510 seq::disconnect(selected);
1511 }
1512 else {
1513 seq::connect(selected);
1514 }
1515
1517 return OPERATOR_FINISHED;
1518}
1519
1521{
1522 ot->name = "Connect Strips";
1523 ot->idname = "SEQUENCER_OT_connect";
1524 ot->description = "Link selected strips together for simplified group selection";
1525
1528
1530
1531 RNA_def_boolean(ot->srna, "toggle", true, "Toggle", "Toggle strip connections");
1532}
1533
1535
1536/* -------------------------------------------------------------------- */
1539
1541{
1543 Editing *ed = seq::editing_get(scene);
1544 ListBaseT<Strip> *active_seqbase = seq::active_seqbase_get(ed);
1545
1546 VectorSet<Strip *> selected = seq::query_selected_strips(active_seqbase);
1547
1548 if (seq::disconnect(selected)) {
1550 return OPERATOR_FINISHED;
1551 }
1552 return OPERATOR_CANCELLED;
1553}
1554
1556{
1557 ot->name = "Disconnect Strips";
1558 ot->idname = "SEQUENCER_OT_disconnect";
1559 ot->description = "Unlink selected strips so that they can be selected individually";
1560
1563
1565}
1566
1568
1569/* -------------------------------------------------------------------- */
1572
1574{
1575 Main *bmain = CTX_data_main(C);
1577 Editing *ed = seq::editing_get(scene);
1578 const bool adjust_length = RNA_boolean_get(op->ptr, "adjust_length");
1579
1580 VectorSet<Strip *> reloaded_strips;
1581 for (Strip &strip : *ed->current_strips()) {
1582 if (strip.flag & SEQ_SELECT) {
1583 seq::add_reload_new_file(bmain, scene, &strip, !adjust_length);
1585
1586 reloaded_strips.add(&strip);
1587 }
1588 }
1589
1590 if (adjust_length) {
1591 seq::transform_handle_overlap(scene, ed->current_strips(), reloaded_strips, false);
1592 }
1593
1595
1596 return OPERATOR_FINISHED;
1597}
1598
1600{
1601 PropertyRNA *prop;
1602
1603 /* Identifiers. */
1604 ot->name = "Reload Strips";
1605 ot->idname = "SEQUENCER_OT_reload";
1606 ot->description = "Reload strips in the sequencer";
1607
1608 /* API callbacks. */
1611
1612 /* Flags. */
1613 ot->flag = OPTYPE_REGISTER; /* No undo, the data changed is stored outside 'main'. */
1614
1615 prop = RNA_def_boolean(ot->srna,
1616 "adjust_length",
1617 false,
1618 "Adjust Length",
1619 "Adjust length of strips to their data length");
1621}
1622
1624
1625/* -------------------------------------------------------------------- */
1628
1630{
1631 if (G.is_rendering) {
1632 return false;
1633 }
1634 return sequencer_edit_poll(C);
1635}
1636
1647
1649{
1650 /* Identifiers. */
1651 ot->name = "Refresh Sequencer";
1652 ot->idname = "SEQUENCER_OT_refresh_all";
1653 ot->description = "Refresh the sequencer editor";
1654
1655 /* API callbacks. */
1658}
1659
1661
1662/* -------------------------------------------------------------------- */
1665
1666bool effect_inputs_validate(int have_inputs, int num_inputs, ReportList *reports)
1667{
1668 if (have_inputs > 2) {
1669 BKE_report(reports, RPT_ERROR, "Cannot apply effect to more than 2 strips with video content");
1670 return false;
1671 }
1672 if (num_inputs == 2 && have_inputs != 2) {
1673 BKE_report(reports, RPT_ERROR, "Exactly 2 selected strips with video content are needed");
1674 return false;
1675 }
1676 if (num_inputs == 1 && have_inputs != 1) {
1677 BKE_report(reports, RPT_ERROR, "Exactly one selected strip with video content is needed");
1678 return false;
1679 }
1680 return true;
1681}
1682
1684 StripType effect_type,
1685 bool ignore_active)
1686{
1687 Editing *ed = seq::editing_get(scene);
1688 VectorSet<Strip *> inputs = seq::query_selected_strips(ed->current_strips());
1689 /* Ignore sound strips for now (avoids unnecessary errors when connected strips are
1690 * selected together, and the intent to operate on strips with video content is clear). */
1691 inputs.remove_if([&](Strip *strip) { return strip->type == STRIP_TYPE_SOUND; });
1692
1693 if (ignore_active) {
1694 /* If `ignore_active` is true, this function is being called from the reassign inputs
1695 * operator, meaning the active strip must be the effect strip to reassign. */
1696 Strip *active_strip = seq::select_active_get(scene);
1697 inputs.remove_if([&](Strip *strip) { return strip == active_strip; });
1698 }
1699
1700 /* Reorganize inputs before creating effect strip. Note that transition inputs are automatically
1701 * swapped after add & during transform by #strip_time_effect_range_set, so ignore that here. */
1702 if (inputs.size() == 2 && !seq::effect_is_transition(effect_type)) {
1703 Strip *first = inputs[0];
1704 Strip *second = inputs[1];
1705
1706 /* Blend-modes make the active strip the second input. If neither strip is active (as in
1707 * reassign inputs), make it the strip on the lower channel. */
1708 if (first == seq::select_active_get(scene) ||
1709 (ignore_active && first->channel < second->channel))
1710 {
1711 /* Swap inputs. */
1712 inputs.clear();
1713 inputs.add(second);
1714 inputs.add(first);
1715 }
1716 }
1717
1718 return inputs;
1719}
1720
1722{
1724 Strip *active_strip = seq::select_active_get(scene);
1725 const int num_inputs = active_strip->effect_num_inputs_get();
1726
1727 if (num_inputs == 0) {
1728 BKE_report(op->reports, RPT_ERROR, "Cannot reassign inputs: strip has no inputs");
1729 return OPERATOR_CANCELLED;
1730 }
1731
1732 VectorSet<Strip *> inputs = strip_effect_get_new_inputs(scene, active_strip->type, true);
1733
1734 if (!effect_inputs_validate(inputs.size(), num_inputs, op->reports)) {
1735 return OPERATOR_CANCELLED;
1736 }
1737
1738 Strip *input1 = inputs[0];
1739 Strip *input2 = inputs.size() == 2 ? inputs[1] : nullptr;
1740
1741 /* Check if reassigning would create recursivity. */
1742 if (seq::relations_render_loop_check(input1, active_strip) ||
1743 seq::relations_render_loop_check(input2, active_strip))
1744 {
1745 BKE_report(op->reports, RPT_ERROR, "Cannot reassign inputs: recursion detected");
1746 return OPERATOR_CANCELLED;
1747 }
1748
1749 active_strip->input1 = input1;
1750 active_strip->input2 = input2;
1751
1752 int old_start = active_strip->start;
1753
1754 /* Force time position update for reassigned effects.
1755 * TODO(Richard): This is because internally startdisp is still used, due to poor performance
1756 * of mapping effect range to inputs. This mapping could be cached though. */
1758 input1->left_handle_set(scene, input1->left_handle());
1759
1760 Editing *ed = seq::editing_get(scene);
1761 ListBaseT<Strip> *active_seqbase = seq::active_seqbase_get(ed);
1762 seq::transform_shuffle_vertical(active_seqbase, {active_strip}, scene);
1763
1764 seq::relations_invalidate_cache(scene, active_strip);
1765 seq::offset_animdata(scene, active_strip, (active_strip->start - old_start));
1766
1768
1769 return OPERATOR_FINISHED;
1770}
1771
1773{
1774 /* Identifiers. */
1775 ot->name = "Reassign Inputs";
1776 ot->idname = "SEQUENCER_OT_reassign_inputs";
1777 ot->description = "Reassign the inputs for the effect strip";
1778
1779 /* API callbacks. */
1782
1783 /* Flags. */
1785}
1786
1788
1789/* -------------------------------------------------------------------- */
1792
1794{
1796 Strip *active_strip = seq::select_active_get(scene);
1797
1798 if (!active_strip->is_effect()) {
1799 BKE_report(op->reports, RPT_ERROR, "Active strip is not an effect strip");
1800 return OPERATOR_CANCELLED;
1801 }
1802
1803 if (active_strip->effect_num_inputs_get() != 2 || active_strip->input1 == nullptr ||
1804 active_strip->input2 == nullptr)
1805 {
1806 BKE_report(op->reports, RPT_ERROR, "Strip needs two inputs to swap");
1807 return OPERATOR_CANCELLED;
1808 }
1809
1810 Strip *strip = active_strip->input1;
1811 active_strip->input1 = active_strip->input2;
1812 active_strip->input2 = strip;
1813
1814 seq::relations_invalidate_cache(scene, active_strip);
1816
1817 return OPERATOR_FINISHED;
1818}
1820{
1821 /* Identifiers. */
1822 ot->name = "Swap Inputs";
1823 ot->idname = "SEQUENCER_OT_swap_inputs";
1824 ot->description = "Swap the two inputs of the effect strip";
1825
1826 /* API callbacks. */
1829
1830 /* Flags. */
1832}
1833
1835
1836/* -------------------------------------------------------------------- */
1839
1841 {seq::SPLIT_SOFT, "SOFT", 0, "Soft", ""},
1842 {seq::SPLIT_HARD, "HARD", 0, "Hard", ""},
1843 {0, nullptr, 0, nullptr, nullptr},
1844};
1845
1847 {int(seq::Side::Left), "LEFT", 0, "Left", ""},
1848 {int(seq::Side::Right), "RIGHT", 0, "Right", ""},
1849 {0, nullptr, 0, nullptr, nullptr},
1850};
1851
1853 {int(seq::Side::Mouse), "MOUSE", 0, "Mouse Position", ""},
1854 {int(seq::Side::Left), "LEFT", 0, "Left", ""},
1855 {int(seq::Side::Right), "RIGHT", 0, "Right", ""},
1856 {int(seq::Side::Both), "BOTH", 0, "Both", ""},
1857 {int(seq::Side::NoChange), "NO_CHANGE", 0, "No Change", ""},
1858 {0, nullptr, 0, nullptr, nullptr},
1859};
1860
1862{
1863 if (RNA_struct_property_is_set(op->ptr, "ignore_selection") &&
1864 !RNA_struct_property_is_set(op->ptr, "only_selected"))
1865 {
1866 return !RNA_boolean_get(op->ptr, "ignore_selection");
1867 }
1868 return RNA_boolean_get(op->ptr, "only_selected");
1869}
1870
1871/* Get the splitting side for the Split Strips's operator exec() callback. */
1873{
1874 const auto split_side = seq::Side(RNA_enum_get(op->ptr, "side"));
1875
1876 /* The mouse position can not be resolved from the exec() as the mouse coordinate is not
1877 * accessible. So fall-back to the RIGHT side instead.
1878 *
1879 * seq::Side::Mouse is used by the Strip menu, together with the EXEC_DEFAULT operator
1880 * context in order to have properly resolved shortcut in the menu. */
1881 if (split_side == seq::Side::Mouse) {
1882 return seq::Side::Right;
1883 }
1884
1885 return split_side;
1886}
1887
1889{
1890 Main *bmain = CTX_data_main(C);
1892 Editing *ed = seq::editing_get(scene);
1893 bool changed = false;
1894 bool failed = false;
1895
1896 const bool split_at_cursor = RNA_boolean_get(op->ptr, "use_cursor_position");
1897 const bool all_channels = RNA_boolean_get(op->ptr, "all_channels");
1898 const bool only_selected = split_only_selected_get(op);
1899
1900 const int split_frame = RNA_struct_property_is_set(op->ptr, "frame") ?
1901 RNA_int_get(op->ptr, "frame") :
1902 scene->r.cfra;
1903 const int split_channel = RNA_int_get(op->ptr, "channel");
1904
1905 const seq::eSplitMethod method = seq::eSplitMethod(RNA_enum_get(op->ptr, "type"));
1906 const seq::Side split_side = sequence_split_side_for_exec_get(op);
1907
1908 /* Only consider ignoring connections for a blade tool split on a single channel, enabled by
1909 * `alt`. The option is moot for playhead splits with `K` and all-channel blade tool splits,
1910 * since they will always either cut (a) everything at the frame, or (b) only selected strips. */
1911 const bool ignore_connections = split_at_cursor && !all_channels &&
1912 RNA_boolean_get(op->ptr, "ignore_connections");
1914 if (!ignore_connections) {
1915 include |= only_selected ? seq::StripRelation::SelectedConnected :
1917 }
1918
1919 const std::optional<int> channel = (split_at_cursor && !all_channels) ?
1920 std::optional<int>(split_channel) :
1921 std::nullopt;
1923 scene, split_frame, channel, only_selected);
1924 if (strips.is_empty() && only_selected &&
1925 !seq::edit_split_strips_get(scene, split_frame, channel, false).is_empty())
1926 {
1927 BKE_report(op->reports, RPT_WARNING, "No selected strips to split");
1928 return OPERATOR_CANCELLED;
1929 }
1930
1931 seq::prefetch_stop(scene);
1932
1933 const char *error_msg = nullptr;
1934 changed =
1936 bmain, scene, ed->current_strips(), strips, split_frame, method, include, &error_msg)
1937 .is_empty();
1938 if (error_msg != nullptr) {
1939 /* We might have split some strips (#changed could be true); others might have still failed. */
1940 BKE_report(op->reports, RPT_WARNING, error_msg);
1941 failed = true;
1942 }
1943
1944 if (changed) { /* Got new strips? */
1945 if (!ELEM(split_side, seq::Side::NoChange, seq::Side::Both)) {
1946 for (Strip &strip : *seq::active_seqbase_get(ed)) {
1947 if (split_side == seq::Side::Left) {
1948 if (strip.left_handle() >= split_frame) {
1949 strip.flag &= ~STRIP_ALLSEL;
1950 }
1951 }
1952 else {
1953 if (strip.right_handle(scene) <= split_frame) {
1954 strip.flag &= ~STRIP_ALLSEL;
1955 }
1956 }
1957 }
1958 }
1960 return OPERATOR_FINISHED;
1961 }
1962
1963 if (failed) {
1964 return OPERATOR_CANCELLED;
1965 }
1966
1967 /* Passthrough to selection if used as tool. */
1969}
1970
1972{
1975
1976 auto split_side = seq::Side(RNA_enum_get(op->ptr, "side"));
1977 int split_frame = scene->r.cfra;
1978
1979 if (split_side == seq::Side::Mouse) {
1980 if (ED_operator_sequencer_active(C) && v2d) {
1981 split_side = mouse_frame_side_get(v2d, event->mval[0], split_frame);
1982 }
1983 else {
1984 split_side = seq::Side::Both;
1985 }
1986 }
1987 if (v2d && RNA_boolean_get(op->ptr, "use_cursor_position")) {
1988 float mouseloc[2];
1989 ui::view2d_region_to_view(v2d, event->mval[0], event->mval[1], &mouseloc[0], &mouseloc[1]);
1990 split_frame = round_fl_to_int(mouseloc[0]);
1991 const std::optional<int> channel = RNA_boolean_get(op->ptr, "all_channels") ?
1992 std::nullopt :
1993 std::optional<int>(mouseloc[1]);
1994 if (seq::edit_split_strips_get(scene, split_frame, channel, false).is_empty()) {
1995 /* Do not pass through to selection. */
1996 return OPERATOR_CANCELLED;
1997 }
1998 RNA_int_set(op->ptr, "channel", mouseloc[1]);
1999 }
2000 RNA_int_set(op->ptr, "frame", split_frame);
2001 RNA_enum_set(op->ptr, "side", int(split_side));
2002 // RNA_enum_set(op->ptr, "type", split_hard);
2003
2004 return sequencer_split_exec(C, op);
2005}
2006
2007static void sequencer_split_ui(bContext * /*C*/, wmOperator *op)
2008{
2009 ui::Layout &layout = *op->layout;
2010 layout.use_property_split_set(true);
2011 layout.use_property_decorate_set(false);
2012
2013 ui::Layout &row = layout.row(false);
2014 row.prop(op->ptr, "type", ui::ITEM_R_EXPAND, std::nullopt, ICON_NONE);
2015 layout.prop(op->ptr, "frame", UI_ITEM_NONE, std::nullopt, ICON_NONE);
2016 layout.prop(op->ptr, "side", UI_ITEM_NONE, std::nullopt, ICON_NONE);
2017
2018 layout.separator();
2019
2020 const bool split_at_cursor = RNA_boolean_get(op->ptr, "use_cursor_position");
2021 const bool all_channels = RNA_boolean_get(op->ptr, "all_channels");
2022
2023 if (split_at_cursor) {
2024 layout.prop(op->ptr, "all_channels", UI_ITEM_NONE, std::nullopt, ICON_NONE);
2025 }
2026
2027 layout.prop(op->ptr, "only_selected", UI_ITEM_NONE, std::nullopt, ICON_NONE);
2028
2029 /* Ignoring connections only makes sense when we split at the mouse cursor.
2030 * If splitting at the playhead, we either split selected strips (default) or on all channels. */
2031 if (split_at_cursor) {
2032 ui::Layout &row = layout.row(false);
2033 /* If `all_channels` is set, it makes no sense to ignore connections. */
2034 row.active_set(!all_channels);
2035 row.prop(op->ptr, "ignore_connections", UI_ITEM_NONE, std::nullopt, ICON_NONE);
2036 }
2037}
2038
2040{
2041 /* Identifiers. */
2042 ot->name = "Split Strips";
2043 ot->idname = "SEQUENCER_OT_split";
2044 ot->description = "Split the selected strips in two";
2045
2046 /* API callbacks. */
2050 ot->ui = sequencer_split_ui;
2051
2052 /* Flags. */
2054
2055 PropertyRNA *prop;
2056 RNA_def_int(ot->srna,
2057 "frame",
2058 0,
2059 INT_MIN,
2060 INT_MAX,
2061 "Frame",
2062 "Frame where selected strips will be split",
2063 INT_MIN,
2064 INT_MAX);
2065
2066 prop = RNA_def_int(ot->srna,
2067 "channel",
2068 0,
2069 INT_MIN,
2070 INT_MAX,
2071 "Channel",
2072 "Initial channel used for the split, which may propagate to channels of "
2073 "effects, connections, or all other channels",
2074 INT_MIN,
2075 INT_MAX);
2077
2078 RNA_def_enum(ot->srna,
2079 "type",
2082 "Type",
2083 "The type of split operation to perform on strips");
2084
2085 prop = RNA_def_boolean(ot->srna,
2086 "use_cursor_position",
2087 false,
2088 "Split at Cursor",
2089 "Split at the position of the mouse cursor instead of the current frame");
2091
2092 prop = RNA_def_boolean(ot->srna,
2093 "all_channels",
2094 false,
2095 "All Channels",
2096 "Split strips in all channels at the split frame, not only the one under "
2097 "the cursor");
2099
2100 RNA_def_boolean(ot->srna, "only_selected", false, "Only Selected", "Only split selected strips");
2101 prop = RNA_def_boolean(ot->srna,
2102 "ignore_selection",
2103 false,
2104 "Ignore Selection",
2105 "Deprecated, will be removed in 6.0. Use only_selected instead");
2107
2108 prop = RNA_def_enum(ot->srna,
2109 "side",
2111 int(seq::Side::Mouse),
2112 "Side",
2113 "The side that remains selected after splitting");
2114
2116
2118 "ignore_connections",
2119 false,
2120 "Ignore Connections",
2121 "Don't propagate split to connected strips");
2122}
2123
2125
2126/* -------------------------------------------------------------------- */
2129
2134
2136{
2137 rctf rect;
2139 ui::view2d_region_to_view_rctf(v2d, &rect, &rect);
2140 /* Snap box rect to full channel sizes, so that it doesn't have to be overlapping a strip's true
2141 * size (which is slightly shorter than the channel height) to cut it. */
2142 rect.ymin = floorf(rect.ymin);
2143 rect.ymax = ceilf(rect.ymax);
2144 return rect;
2145}
2146
2148{
2149 Main *bmain = CTX_data_main(C);
2151 Editing *ed = seq::editing_get(scene);
2152 ListBaseT<SeqTimelineChannel> *channels = seq::channels_displayed_get(ed);
2153
2154 ed->edit_point_set(scene, std::nullopt);
2155
2157
2158 const rctf box_rect = box_blade_rect_get(op, v2d);
2159 const bool remove_gaps = RNA_boolean_get(op->ptr, "remove_gaps");
2160 const bool only_selected = split_only_selected_get(op);
2161 const bool ignore_connections = RNA_boolean_get(op->ptr, "ignore_connections");
2163 if (!ignore_connections) {
2164 include |= only_selected ? seq::StripRelation::SelectedConnected :
2166 }
2167 const int2 rect_frames = {round_fl_to_int(box_rect.xmin), round_fl_to_int(box_rect.xmax)};
2168 const seq::eSplitMethod method = seq::eSplitMethod(RNA_enum_get(op->ptr, "type"));
2169
2170 int2 gap_removal_boundary = {INT_MAX, INT_MIN};
2171 VectorSet<Strip *> to_remove;
2172
2173 auto strips_to_split_get = [&](const bool selected) {
2174 Vector<Strip *> box_strips;
2175 for (Strip *strip : selected ? selected_strips_from_context(C) : all_strips_from_context(C)) {
2176 const rctf strip_rect = strip_bounds_get(scene, strip);
2177 if (!seq::transform_is_locked(channels, strip) &&
2178 BLI_rctf_isect(&strip_rect, &box_rect, nullptr))
2179 {
2180 box_strips.append(strip);
2181 }
2182 }
2183 return box_strips;
2184 };
2185
2186 Vector<Strip *> strips_to_split = strips_to_split_get(only_selected);
2187
2188 /* Report if we potentially _could_ have split some intersecting strips, but the user chose
2189 * #only_selected and they were deselected. */
2190 if (only_selected && strips_to_split.is_empty() && !strips_to_split_get(false).is_empty()) {
2191 BKE_report(op->reports, RPT_WARNING, "No selected strips to split");
2192 return OPERATOR_CANCELLED;
2193 }
2194
2195 seq::prefetch_stop(scene);
2196
2197 for (Strip *strip : strips_to_split) {
2198 gap_removal_boundary[0] = math::min(gap_removal_boundary[0], strip->left_handle());
2199 gap_removal_boundary[1] = math::max(gap_removal_boundary[1], strip->right_handle(scene));
2200 }
2201
2202 const char *error_msg = nullptr;
2203 /* Step 1: Split every strip the box touches at the left edge of the box. */
2205 scene,
2206 ed->current_strips(),
2207 strips_to_split,
2208 rect_frames[0],
2209 method,
2210 include,
2211 &error_msg);
2212
2213 /* Edge case early return where box rect is too thin to cut gaps.
2214 * In this case, the operator should only split strips with nothing marked for deletion. */
2215 if (rect_frames[0] == rect_frames[1]) {
2216 return OPERATOR_FINISHED;
2217 }
2218
2219 /* Step 2: New strips have been generated from the left split, so recalculate
2220 * #strips_to_split and split at the right edge of the box this time. */
2221 strips_to_split = strips_to_split_get(only_selected);
2223 scene,
2224 ed->current_strips(),
2225 strips_to_split,
2226 rect_frames[1],
2227 method,
2228 include,
2229 &error_msg);
2230
2231 /* Step 3: Recalculate #strips_to_split once more, and mark all the strip content that lies in
2232 * the box's frame range for deletion. */
2233 for (Strip *strip : strips_to_split_get(only_selected)) {
2234 if (strip->left_handle() >= rect_frames[0] && strip->right_handle(scene) <= rect_frames[1]) {
2235 to_remove.add(strip);
2236 }
2237 }
2238
2239 if (to_remove.size() == 0) {
2240 return OPERATOR_CANCELLED;
2241 }
2242
2243 for (Strip *strip : to_remove) {
2244 seq::edit_flag_for_removal(scene, strip);
2245 /* Propagate removal to connected strips. */
2246 if (!ignore_connections) {
2247 VectorSet<Strip *> connections = seq::connected_strips_get(strip);
2248 for (Strip *connection : connections) {
2249 if (!only_selected || (connection->flag & SEQ_SELECT)) {
2250 seq::edit_flag_for_removal(scene, connection);
2251 }
2252 }
2253 }
2254 }
2255
2256 seq::edit_remove_flagged_strips(scene, ed->current_strips());
2257
2258 /* Close gaps, rippling strips. */
2259 if (remove_gaps) {
2260 gap_removal_boundary[0] = math::max(gap_removal_boundary[0], rect_frames[0]);
2261 gap_removal_boundary[1] = math::min(gap_removal_boundary[1], rect_frames[1]);
2262
2263 int offset = gap_removal_boundary[0] - gap_removal_boundary[1];
2264
2265 /* Offset should always be negative, since ripple always moves right to left. */
2266 BLI_assert(offset < 0);
2267
2268 const VectorSet<Strip *> strips = only_selected ? selected_strips_from_context(C) :
2270 VectorSet<Strip *> to_offset;
2271 for (Strip *strip : strips) {
2272 if (seq::transform_is_locked(channels, strip)) {
2273 continue;
2274 }
2275
2276 /* Ripple strips for all channels that the blade box extends to, so that the user can
2277 * optionally affect other channels than those with strips to cut. */
2278 if (strip->channel < int(box_rect.ymax) && strip->channel >= int(box_rect.ymin) &&
2279 (strip->left_handle() > rect_frames[0]))
2280 {
2281 to_offset.add(strip);
2282 }
2283 }
2284
2285 seq::expand_strips(ed, to_offset, include);
2286
2287 for (Strip *strip : to_offset) {
2288 seq::relations_invalidate_cache(scene, strip);
2289 seq::transform_translate_strip(scene, strip, offset);
2290 }
2291
2292 seq::transform_handle_overlap(scene, ed->current_strips(), to_offset, false);
2293 }
2295 return OPERATOR_FINISHED;
2296}
2297
2299{
2300 ui::Layout &layout = *op->layout;
2301 layout.use_property_split_set(true);
2302 layout.use_property_decorate_set(false);
2303
2304 layout.prop(op->ptr, "type", UI_ITEM_NONE, std::nullopt, ICON_NONE);
2305 layout.prop(op->ptr, "remove_gaps", UI_ITEM_NONE, std::nullopt, ICON_NONE);
2306 layout.prop(op->ptr, "only_selected", UI_ITEM_NONE, std::nullopt, ICON_NONE);
2307 layout.prop(op->ptr, "ignore_connections", UI_ITEM_NONE, std::nullopt, ICON_NONE);
2308}
2309
2311 wmOperator *op,
2312 const wmEvent *event)
2313{
2315
2317 int mouse_frame = ui::view2d_region_to_view_x(v2d, event->mval[0]);
2318 scene->ed->edit_point_set(scene, mouse_frame);
2319
2321 wmOperatorStatus gesture_return = WM_gesture_box_modal(C, op, event);
2322 if (gesture_return == OPERATOR_CANCELLED) {
2323 scene->ed->edit_point_set(scene, std::nullopt);
2324 }
2325
2326 if (gesture_return == OPERATOR_RUNNING_MODAL) {
2327 /* Region event handlers don't run during the gesture, keep the tooltip updated here. */
2329 }
2330 else if (ELEM(gesture_return, OPERATOR_FINISHED, OPERATOR_CANCELLED)) {
2331 /* The tooltip would otherwise stick around until the next cursor motion. */
2333 }
2334
2335 wmGesture *gesture = static_cast<wmGesture *>(op->customdata);
2336
2337 /* Set preview frame to the opposite side when moving the box. */
2338 if (gesture && gesture->move) {
2339 const rctf box_rect = box_blade_rect_get(op, v2d);
2340 scene->ed->edit_point_set(
2341 scene, (mouse_frame == int(box_rect.xmin)) ? int(box_rect.xmax) : int(box_rect.xmin));
2342 }
2343
2344 return gesture_return;
2345}
2346
2348{
2350 if (scene && scene->ed) {
2351 scene->ed->edit_point_set(scene, std::nullopt);
2352 }
2354}
2355
2357{
2358 /* Identifiers. */
2359 ot->name = "Box Blade";
2360 ot->idname = "SEQUENCER_OT_box_blade";
2361 ot->description = "Draw a box around the parts of strips you want to cut away";
2362
2363 /* API callbacks. */
2370
2371 /* Flags. */
2373
2376 RNA_def_enum(ot->srna,
2377 "type",
2380 "Type",
2381 "The type of split operation to perform on strips");
2382 RNA_def_boolean(ot->srna, "only_selected", false, "Only Selected", "Only split selected strips");
2384 ot->srna,
2385 "ignore_selection",
2386 false,
2387 "Ignore Selection",
2388 "Deprecated, will be removed in 6.0. Use only_selected instead");
2391 "ignore_connections",
2392 false,
2393 "Ignore Connections",
2394 "Don't propagate split to connected strips");
2396 "remove_gaps",
2397 true,
2398 "Remove Gaps",
2399 "In box blade mode, close gaps between cut strips, rippling later strips on the "
2400 "same channel");
2401}
2402
2404
2405/* -------------------------------------------------------------------- */
2408
2409static void sequencer_report_duplicates(wmOperator *op, ListBaseT<Strip> *duplicated_strips)
2410{
2411 Set<Scene *> scenes;
2412 Set<MovieClip *> movieclips;
2413 Set<Mask *> masks;
2414
2415 for (Strip &strip : *duplicated_strips) {
2416 switch (strip.type) {
2417 case STRIP_TYPE_SCENE:
2418 if (strip.scene) {
2419 scenes.add(strip.scene);
2420 }
2421 break;
2423 if (strip.clip) {
2424 movieclips.add(strip.clip);
2425 }
2426 break;
2427 case STRIP_TYPE_MASK:
2428 if (strip.mask) {
2429 masks.add(strip.mask);
2430 }
2431 break;
2432 default:
2433 break;
2434 }
2435 }
2436
2437 const int num_scenes = scenes.size();
2438 const int num_movieclips = movieclips.size();
2439 const int num_masks = masks.size();
2440
2441 if (num_scenes == 0 && num_movieclips == 0 && num_masks == 0) {
2442 return;
2443 }
2444
2445 std::string report;
2446 std::string sep;
2447 if (num_scenes) {
2448 report += fmt::format("{}{} {}",
2449 sep,
2450 num_scenes,
2451 (num_scenes > 1) ? RPT_(BKE_idtype_idcode_to_name_plural(ID_SCE)) :
2453 sep = ", ";
2454 }
2455 if (num_movieclips) {
2456 report += fmt::format("{}{} {}",
2457 sep,
2458 num_movieclips,
2459 (num_movieclips > 1) ? RPT_(BKE_idtype_idcode_to_name_plural(ID_MC)) :
2461 sep = ", ";
2462 }
2463 if (num_masks) {
2464 report += fmt::format("{}{} {}",
2465 sep,
2466 num_masks,
2467 (num_masks > 1) ? RPT_(BKE_idtype_idcode_to_name_plural(ID_MSK)) :
2469 sep = ", ";
2470 }
2471
2472 BKE_reportf(op->reports, RPT_INFO, RPT_("Duplicated %s"), report.c_str());
2473}
2474
2476{
2477 Main *bmain = CTX_data_main(C);
2479 Editing *ed = seq::editing_get(scene);
2480 ARegion *region = CTX_wm_region(C);
2481
2482 const bool linked = RNA_boolean_get(op->ptr, "linked");
2483
2484 if (ed == nullptr) {
2485 return OPERATOR_CANCELLED;
2486 }
2487
2488 Strip *active_strip = seq::select_active_get(scene);
2489 ListBaseT<Strip> duplicated_strips = {nullptr, nullptr};
2490
2491 /* Special case for duplicating strips in preview: Do not duplicate sound strips,muted
2492 * strips and strips that do not intersect the current frame */
2494 for (Strip &strip : *ed->current_strips()) {
2495 if (strip.type == STRIP_TYPE_SOUND || strip.flag & SEQ_MUTE ||
2496 !strip.intersects_frame(scene, scene->r.cfra))
2497 {
2498 strip.flag &= ~STRIP_ALLSEL;
2499 }
2500 }
2501 }
2502
2503 const seq::StripDuplicate dupe_flag = linked ? seq::StripDuplicate::Selected :
2507 bmain, scene, scene, &duplicated_strips, ed->current_strips(), dupe_flag, 0);
2508 deselect_all_strips(scene);
2509
2510 if (duplicated_strips.first() == nullptr) {
2511 return OPERATOR_CANCELLED;
2512 }
2513
2514 /* Report all the newly created datablocks in the status bar. */
2515 if (!linked) {
2516 sequencer_report_duplicates(op, &duplicated_strips);
2517 }
2518
2519 /* Duplicate animation.
2520 * First backup original curves from scene and duplicate strip curves from backup into scene.
2521 * This way, when pasted strips are renamed, curves are renamed with them. Finally, restore
2522 * original curves from backup.
2523 */
2524 seq::AnimationBackup animation_backup = {};
2525 seq::animation_backup_original(scene, &animation_backup);
2526
2527 ListBaseT<Strip> *seqbase = seq::active_seqbase_get(seq::editing_get(scene));
2528 Strip *strip_last = seqbase->last();
2529
2530 /* Rely on the `duplicated_strips` list being added at the end.
2531 * Their UIDs has been re-generated by the #SEQ_sequence_base_dupli_recursive(). */
2532 BLI_movelisttolist(ed->current_strips(), &duplicated_strips);
2533
2534 /* Handle duplicated strips: set active, select, ensure unique name and duplicate animation
2535 * data. */
2536 for (Strip *strip = strip_last->next; strip; strip = strip->next) {
2537 if (active_strip != nullptr && STREQ(strip->name, active_strip->name)) {
2538 seq::select_active_set(scene, strip);
2539 }
2540 strip->flag &= ~(SEQ_LEFTSEL | SEQ_RIGHTSEL | SEQ_LOCK);
2541 strip->runtime->flag |= seq::StripRuntimeFlag::IgnoreChannelLock;
2542
2543 seq::animation_duplicate_backup_to_scene(scene, strip, &animation_backup);
2544 seq::ensure_unique_name(strip, scene, {});
2545 }
2546
2547 /* Special case for duplicating strips in preview: handle overlap, because strips won't be
2548 * translated. */
2550 for (Strip *strip = strip_last->next; strip; strip = strip->next) {
2551 seq::transform_shuffle_vertical(ed->current_strips(), {strip}, scene);
2552 strip->runtime->flag &= ~seq::StripRuntimeFlag::IgnoreChannelLock;
2553 }
2554 }
2555
2556 seq::animation_restore_original(scene, &animation_backup);
2557
2561 return OPERATOR_FINISHED;
2562}
2563
2565{
2566 PropertyRNA *prop;
2567
2568 /* Identifiers. */
2569 ot->name = "Duplicate Strips";
2570 ot->idname = "SEQUENCER_OT_duplicate";
2571 ot->description = "Duplicate the selected strips";
2572
2573 /* API callbacks. */
2576
2577 /* Flags. */
2579
2580 prop = RNA_def_boolean(ot->srna,
2581 "linked",
2582 false,
2583 "Linked",
2584 "Duplicate strip but not strip data, linking to the original data");
2586}
2587
2589
2590/* -------------------------------------------------------------------- */
2593
2595{
2596 if (strip->type != STRIP_TYPE_SCENE) {
2597 return;
2598 }
2599
2600 Main *bmain = CTX_data_main(C);
2601 if (strip->scene) {
2602 if (ED_scene_delete(C, bmain, strip->scene)) {
2603 WM_event_add_notifier(C, NC_SCENE | NA_REMOVED, strip->scene);
2604 }
2605 }
2606}
2607
2609{
2610 Main *bmain = CTX_data_main(C);
2612 ListBaseT<Strip> *seqbasep = seq::active_seqbase_get(seq::editing_get(scene));
2613 const bool delete_data = RNA_boolean_get(op->ptr, "delete_data");
2614
2616 return OPERATOR_CANCELLED;
2617 }
2618
2619 seq::prefetch_stop(scene);
2620
2621 for (Strip *strip : selected_strips_from_context(C)) {
2622 seq::edit_flag_for_removal(scene, strip);
2623 if (delete_data) {
2625 }
2626 }
2627 seq::edit_remove_flagged_strips(scene, seqbasep);
2628
2630
2632 if (scene->adt && scene->adt->action) {
2634 }
2638 return OPERATOR_FINISHED;
2639}
2640
2642{
2644 ListBaseT<TimeMarker> *markers = &scene->markers;
2645
2646 if (!markers->is_empty()) {
2647 ARegion *region = CTX_wm_region(C);
2648 if (region && (region->regiontype == RGN_TYPE_WINDOW)) {
2649 /* Bounding box of 30 pixels is used for markers shortcuts,
2650 * prevent conflict with markers shortcuts here. */
2651 if (event->mval[1] <= 30) {
2652 return OPERATOR_PASS_THROUGH;
2653 }
2654 }
2655 }
2656
2657 return sequencer_delete_exec(C, op);
2658}
2659
2661{
2662 /* Identifiers. */
2663 ot->name = "Delete Strips";
2664 ot->idname = "SEQUENCER_OT_delete";
2665 ot->description = "Delete selected strips from the sequencer";
2666
2667 /* API callbacks. */
2671
2672 /* Flags. */
2674
2675 /* Properties. */
2676 ot->prop = RNA_def_boolean(ot->srna,
2677 "delete_data",
2678 false,
2679 "Delete Data",
2680 "After removing the Strip, delete the associated data also");
2682}
2683
2685
2686/* -------------------------------------------------------------------- */
2689
2691{
2692 PropertyRNA *prop;
2693
2694 if ((options & SEQ_RIPPLE_ALL_CHANNELS) != 0) {
2695 prop = RNA_def_boolean(ot->srna,
2696 "all_channels",
2697 true,
2698 "All Channels",
2699 "Ripple strips on other channels too, else only strips on the same "
2700 "channels as the edited strips");
2702 }
2703
2704 if ((options & SEQ_RIPPLE_MARKERS) != 0) {
2705 prop = RNA_def_boolean(
2706 ot->srna, "markers", true, "Markers", "Ripple markers along with strips");
2708 }
2709
2710 if ((options & SEQ_RIPPLE_CLEAR_RANGES) != 0) {
2711 prop = RNA_def_boolean(
2712 ot->srna,
2713 "clear_ranges",
2714 true,
2715 "Clear Ranges",
2716 "Delete strip contents inside the removed ranges on rippled channels so later strips "
2717 "close the full gap, else ripple later strips only as far as they can");
2719 }
2720
2721 if ((options & SEQ_RIPPLE_INSERT) != 0) {
2722 prop = RNA_def_boolean(ot->srna,
2723 "insert",
2724 false,
2725 "Insert",
2726 "Split strips at the leftmost edited handle and push the remainder "
2727 "aside, else ripple only as far as needed to resolve the overlap");
2729 }
2730}
2731
2733{
2735 if (scene == nullptr) {
2736 return;
2737 }
2738
2739 const eSeqRippleFlag ripple_flag = seq::tool_settings_ripple_flag_get(scene);
2740 RNA_boolean_set(op->ptr, "all_channels", (ripple_flag & SEQ_RIPPLE_ALL_CHANNELS) != 0);
2741 RNA_boolean_set(op->ptr, "markers", (ripple_flag & SEQ_RIPPLE_MARKERS) != 0);
2742 if (PropertyRNA *prop = RNA_struct_find_property(op->ptr, "clear_ranges")) {
2743 RNA_property_boolean_set(op->ptr, prop, (ripple_flag & SEQ_RIPPLE_CLEAR_RANGES) != 0);
2744 }
2745}
2746
2748{
2749 eSeqRippleFlag ripple_flag = {};
2751 ripple_flag, RNA_boolean_get(op->ptr, "all_channels"), SEQ_RIPPLE_ALL_CHANNELS);
2752 SET_FLAG_FROM_TEST(ripple_flag, RNA_boolean_get(op->ptr, "markers"), SEQ_RIPPLE_MARKERS);
2753 if (PropertyRNA *prop = RNA_struct_find_property(op->ptr, "clear_ranges")) {
2755 ripple_flag, RNA_property_boolean_get(op->ptr, prop), SEQ_RIPPLE_CLEAR_RANGES);
2756 }
2757 return ripple_flag;
2758}
2759
2760/* In the destructive case, we delete or trim all strip contents that occupy the same time
2761 * ranges as any ripple deleted strips before doing any rippling. */
2762static void ripple_range_clear(Scene *scene,
2763 ListBaseT<Strip> *seqbasep,
2764 const ListBaseT<SeqTimelineChannel> *channels,
2765 const seq::RippleRange &range,
2766 const bool all_channels)
2767{
2768 Vector<Strip *> to_edit;
2769 for (Strip &strip : *seqbasep) {
2770 if (seq::transform_is_locked(channels, &strip) || strip.is_effect_with_inputs()) {
2771 continue;
2772 }
2773 if (strip.left_handle() >= range.end || strip.right_handle(scene) <= range.start) {
2774 continue;
2775 }
2776 if (!seq::transform_strip_is_on_rippled_channel(range, &strip, all_channels)) {
2777 continue;
2778 }
2779 to_edit.append(&strip);
2780 }
2781
2782 Vector<Strip *> to_remove;
2783 for (Strip *strip : to_edit) {
2784 const bool covers_left = range.start <= strip->left_handle();
2785 const bool covers_right = range.end >= strip->right_handle(scene);
2786
2787 if (covers_left && covers_right) {
2788 to_remove.append(strip);
2789 }
2790 else if (covers_left) {
2791 strip->left_handle_set(scene, range.end);
2792 }
2793 else if (covers_right) {
2794 strip->right_handle_set(scene, range.start);
2795 }
2796 else {
2797 /* Ripple range is smaller than the strip and entirely contained within it,
2798 * must split and trim to simulate deleting just that portion. */
2799 const char *error_msg = nullptr;
2800 Strip *right_strip = seq::edit_strip_split(
2801 nullptr, scene, seqbasep, strip, range.start, seq::SPLIT_SOFT, true, &error_msg);
2802 if (right_strip != nullptr) {
2803 right_strip->left_handle_set(scene, range.end);
2804 }
2805 }
2806 seq::relations_invalidate_cache(scene, strip);
2807 }
2808
2809 for (Strip *strip : to_remove) {
2810 seq::edit_flag_for_removal(scene, strip);
2811 }
2812 seq::edit_remove_flagged_strips(scene, seqbasep);
2813}
2814
2815static bool should_ripple_strip(const ListBaseT<SeqTimelineChannel> *channels,
2816 const seq::RippleRange &range,
2817 const Strip *strip,
2818 const bool all_channels)
2819{
2820 const SeqTimelineChannel *channel = seq::channel_get_by_index(channels, strip->channel);
2821 return !channel->is_locked() &&
2822 seq::transform_strip_is_on_rippled_channel(range, strip, all_channels);
2823}
2824
2826 ListBaseT<Strip> *seqbasep,
2827 const ListBaseT<SeqTimelineChannel> *channels,
2828 const seq::RippleRange &range,
2829 const bool all_channels)
2830{
2831 Vector<Bounds<int>> occupied_ranges;
2832 /* First, figure out which parts of the deleted range have something in them. The gaps will be
2833 * calculated by walking through these occupied ranges. */
2834 for (Strip &strip : *seqbasep) {
2835 if (!should_ripple_strip(channels, range, &strip, all_channels)) {
2836 continue;
2837 }
2838 /* Locked strips are a special case. Since they can't move, they pretend like they start at
2839 * #range.start to prevent finding gaps before them. */
2840 const int start = (strip.flag & SEQ_LOCK) ? range.start :
2841 math::max(strip.left_handle(), range.start);
2842 const int end = math::min(strip.right_handle(scene), range.end);
2843 if (start < end) {
2844 occupied_ranges.append({start, end});
2845 }
2846 }
2847 std::ranges::sort(occupied_ranges,
2848 [](const Bounds<int> &a, const Bounds<int> &b) { return a.min < b.min; });
2849
2850 /* Calculate the gaps by walking left to right, jumping to the end of each occupied range. */
2851 Vector<Bounds<int>> gaps;
2852 int frame = range.start;
2853 for (const Bounds<int> &occupied_range : occupied_ranges) {
2854 if (occupied_range.min > frame) {
2855 gaps.append({frame, occupied_range.min});
2856 }
2857 frame = math::max(frame, occupied_range.max);
2858 }
2859 /* There may be a gap at the end, even if nothing later is occupied, tally it. */
2860 if (frame < range.end) {
2861 gaps.append({frame, range.end});
2862 }
2863 return gaps;
2864}
2865
2866static void ripple_gaps_close(Scene *scene,
2867 ListBaseT<Strip> *seqbasep,
2868 const ListBaseT<SeqTimelineChannel> *channels,
2869 const seq::RippleRange &range,
2870 const eSeqRippleFlag ripple_flag)
2871{
2872 const bool all_channels = (ripple_flag & SEQ_RIPPLE_ALL_CHANNELS) != 0;
2873 const bool ripple_markers = (ripple_flag & SEQ_RIPPLE_MARKERS) != 0;
2874
2875 const Vector<Bounds<int>> gaps = ripple_gaps_get(scene, seqbasep, channels, range, all_channels);
2876 for (const Bounds<int> &gap : gaps | std::views::reverse) {
2877 const int offset = gap.max - gap.min;
2878
2879 for (Strip &strip : *seqbasep) {
2880 if (strip.left_handle() >= gap.max &&
2881 should_ripple_strip(channels, range, &strip, all_channels))
2882 {
2883 seq::transform_translate_strip(scene, &strip, -offset);
2884 seq::relations_invalidate_cache(scene, &strip);
2885 }
2886 }
2887
2888 auto ripple_frame = [&](int &frame) {
2889 if (frame >= gap.max) {
2890 frame -= offset;
2891 }
2892 /* Markers and the playhead can exist inside a gap, we must handle this here. */
2893 else if (frame > gap.min) {
2894 frame = gap.min;
2895 }
2896 };
2897
2898 if (ripple_markers && !scene->toolsettings->lock_markers) {
2899 for (TimeMarker &marker : scene->markers) {
2900 ripple_frame(marker.frame);
2901 }
2902 }
2903
2904 ripple_frame(scene->r.cfra);
2905 }
2906}
2907
2909{
2910 Main *bmain = CTX_data_main(C);
2912 Editing *ed = seq::editing_get(scene);
2913 ListBaseT<Strip> *seqbasep = seq::active_seqbase_get(ed);
2914 const ListBaseT<SeqTimelineChannel> *channels = seq::channels_displayed_get(ed);
2915 const eSeqRippleFlag ripple_flag = ripple_flag_from_properties(op);
2916 const int timeline_frame = scene->r.cfra;
2917
2919 return OPERATOR_CANCELLED;
2920 }
2921
2923 if (selected.is_empty()) {
2924 return OPERATOR_CANCELLED;
2925 }
2926
2927 seq::prefetch_stop(scene);
2928
2929 const Vector<seq::RippleRange> ranges = seq::transform_ripple_ranges_get(scene, selected);
2930
2931 for (Strip *strip : selected) {
2932 seq::edit_flag_for_removal(scene, strip);
2933 }
2934 seq::edit_remove_flagged_strips(scene, seqbasep);
2935
2936 /* Every ripple delete changes the frames of later strips, so we must delete in reverse to avoid
2937 * invalidating range coordinates of later ranges. */
2938 for (const seq::RippleRange &range : ranges | std::views::reverse) {
2939 if ((ripple_flag & SEQ_RIPPLE_CLEAR_RANGES) != 0) {
2941 scene, seqbasep, channels, range, (ripple_flag & SEQ_RIPPLE_ALL_CHANNELS) != 0);
2942 }
2943 ripple_gaps_close(scene, seqbasep, channels, range, ripple_flag);
2944 }
2945
2946 /* Ripple back the playhead. */
2947 if (scene->r.cfra != timeline_frame) {
2950 }
2951
2953
2955 if (scene->adt && scene->adt->action) {
2957 }
2961 return OPERATOR_FINISHED;
2962}
2963
2971
2973{
2974 /* Identifiers. */
2975 ot->name = "Ripple Delete Strips";
2976 ot->idname = "SEQUENCER_OT_ripple_delete";
2977 ot->description = "Delete selected strips and close the gaps left behind";
2978
2979 /* API callbacks. */
2983
2984 /* Flags. */
2986
2987 /* Properties. */
2990}
2991
2993
2994/* -------------------------------------------------------------------- */
2997
2999{
3001 Editing *ed = seq::editing_get(scene);
3002 ListBaseT<Strip> *seqbasep = seq::active_seqbase_get(ed);
3003 const ListBaseT<SeqTimelineChannel> *channels = seq::channels_displayed_get(ed);
3004 const eSeqRippleFlag ripple_flag = ripple_flag_from_properties(op);
3005 const bool trim_left = seq::Side(RNA_enum_get(op->ptr, "side")) == seq::Side::Left;
3006 const int timeline_frame = scene->r.cfra;
3007
3009 return OPERATOR_CANCELLED;
3010 }
3011
3012 /* Step 1: Get strips to trim from selection. */
3014 if (to_trim.is_empty()) {
3015 /* Fall back to active strip. */
3016 Strip *active_strip = seq::select_active_get(scene);
3017 if (active_strip == nullptr) {
3018 return OPERATOR_CANCELLED;
3019 }
3020 to_trim.add(active_strip);
3021 }
3022 /* If strips are not editable or exist entirely on the side we keep, ignore them. */
3023 to_trim.remove_if([&](Strip *strip) {
3024 return seq::transform_is_locked(channels, strip) || strip->is_effect_with_inputs() ||
3025 (trim_left ? strip->left_handle() >= timeline_frame :
3026 strip->right_handle(scene) <= timeline_frame);
3027 });
3028 if (to_trim.is_empty()) {
3029 return OPERATOR_CANCELLED;
3030 }
3031
3032 seq::prefetch_stop(scene);
3033
3034 /* Step 2: Calculate a single range to delete (we will ripple later strips by its duration), as
3035 * well as individual ranges which might be cleared by the "Clear Ranges" property. */
3036 seq::RippleRange ripple_range{timeline_frame, timeline_frame, {}};
3037 Vector<Bounds<int>> clear_ranges;
3038 for (Strip *strip : to_trim) {
3039 if (trim_left) {
3040 ripple_range.start = min_ii(ripple_range.start, strip->left_handle());
3041 clear_ranges.append(
3042 {strip->left_handle(), min_ii(strip->right_handle(scene), timeline_frame)});
3043 }
3044 else {
3045 ripple_range.end = max_ii(ripple_range.end, strip->right_handle(scene));
3046 clear_ranges.append(
3047 {max_ii(strip->left_handle(), timeline_frame), strip->right_handle(scene)});
3048 }
3049 ripple_range.channels.add(strip->channel);
3050 }
3051
3052 /* Step 3: Trim and delete strips. */
3053 Vector<Strip *> to_delete;
3054 for (Strip *strip : to_trim) {
3055 const bool trimmed_away = trim_left ? strip->right_handle(scene) <= timeline_frame :
3056 strip->left_handle() >= timeline_frame;
3057 if (trimmed_away) {
3058 /* Entire strip is trimmed away, mark for deletion. */
3059 to_delete.append(strip);
3060 }
3061 else if (trim_left) {
3062 strip->left_handle_set(scene, timeline_frame);
3063 seq::relations_invalidate_cache(scene, strip);
3064 }
3065 else {
3066 strip->right_handle_set(scene, timeline_frame);
3067 seq::relations_invalidate_cache(scene, strip);
3068 }
3069 }
3070
3071 for (Strip *strip : to_delete) {
3072 seq::edit_flag_for_removal(scene, strip);
3073 }
3074 seq::edit_remove_flagged_strips(scene, seqbasep);
3075
3076 /* Step 4: Close the gap left behind by rippling back later strips and the playhead. */
3077 if ((ripple_flag & SEQ_RIPPLE_CLEAR_RANGES) != 0) {
3078 for (const Bounds<int> &clear_range : clear_ranges) {
3079 ripple_range_clear(scene,
3080 seqbasep,
3081 channels,
3082 {clear_range.min, clear_range.max, ripple_range.channels},
3083 (ripple_flag & SEQ_RIPPLE_ALL_CHANNELS) != 0);
3084 }
3085 }
3086 ripple_gaps_close(scene, seqbasep, channels, ripple_range, ripple_flag);
3087
3088 if (scene->r.cfra != timeline_frame) {
3091 }
3092
3094
3099 return OPERATOR_FINISHED;
3100}
3101
3103 wmOperator *op,
3104 const wmEvent * /*event*/)
3105{
3107 return sequencer_ripple_trim_exec(C, op);
3108}
3109
3111{
3112 /* Identifiers. */
3113 ot->name = "Ripple Trim Strips";
3114 ot->idname = "SEQUENCER_OT_ripple_trim";
3115 ot->description = "Trim strips to the current frame and close the gaps left behind";
3116
3117 /* API callbacks. */
3121
3122 /* Flags. */
3124
3125 /* Properties. */
3126 RNA_def_enum(ot->srna,
3127 "side",
3129 int(seq::Side::Left),
3130 "Side",
3131 "The side of the strips to trim to the current frame");
3134}
3135
3137
3138/* -------------------------------------------------------------------- */
3141
3143{
3145 Editing *ed = seq::editing_get(scene);
3146 Strip *strip;
3147 const ListBaseT<SeqTimelineChannel> *channels = seq::channels_displayed_get(
3148 seq::editing_get(scene));
3149
3150 /* For effects, try to find a replacement input. */
3151 for (strip = ed->current_strips()->first(); strip; strip = static_cast<Strip *>(strip->next)) {
3152 if (seq::transform_is_locked(channels, strip)) {
3153 continue;
3154 }
3155
3156 if (!strip->is_effect() && (strip->flag & SEQ_SELECT)) {
3157 strip->handles_set(scene, strip->content_start(), strip->content_end(scene));
3158 }
3159 }
3160
3161 /* Update lengths, etc. */
3162 strip = ed->current_strips()->first();
3163 while (strip) {
3164 seq::relations_invalidate_cache(scene, strip);
3165 strip = strip->next;
3166 }
3167
3168 VectorSet<Strip *> cleared_strips;
3169 for (strip = ed->current_strips()->first(); strip; strip = static_cast<Strip *>(strip->next)) {
3170 if (!strip->is_effect() && (strip->flag & SEQ_SELECT)) {
3171 cleared_strips.add(strip);
3172 }
3173 }
3174 seq::transform_handle_overlap(scene, ed->current_strips(), cleared_strips, false);
3175
3177
3178 return OPERATOR_FINISHED;
3179}
3180
3182{
3183 /* Identifiers. */
3184 ot->name = "Clear Strip Offset";
3185 ot->idname = "SEQUENCER_OT_offset_clear";
3186 ot->description = "Clear strip in/out offsets from the start and end of content";
3187
3188 /* API callbacks. */
3191
3192 /* Flags. */
3194}
3195
3197
3198/* -------------------------------------------------------------------- */
3201
3203{
3204 Main *bmain = CTX_data_main(C);
3206 Editing *ed = seq::editing_get(scene);
3207 ListBaseT<Strip> *seqbase = seq::active_seqbase_get(ed);
3208
3209 Strip *strip, *strip_new;
3210 StripElem *se, *se_new;
3211 int start_ofs, timeline_frame, frame_end;
3212 int step = RNA_int_get(op->ptr, "length");
3213
3214 strip = seqbase->first(); /* Poll checks this is valid. */
3215
3216 seq::prefetch_stop(scene);
3217
3218 VectorSet<Strip *> new_strips;
3219 while (strip) {
3220 if ((strip->flag & SEQ_SELECT) && (strip->type == STRIP_TYPE_IMAGE) &&
3221 (strip->content_length() > 1))
3222 {
3223 Strip *strip_next;
3224
3225 /* TODO: remove f-curve and assign to split image strips.
3226 * The old animation system would remove the user of `strip->ipo_legacy`. */
3227
3228 start_ofs = timeline_frame = strip->left_handle();
3229 frame_end = strip->right_handle(scene);
3230
3231 while (timeline_frame < frame_end) {
3232 /* New strip. */
3233 se = seq::render_give_stripelem(scene, strip, timeline_frame);
3234
3236 bmain, scene, scene, seqbase, strip, seq::StripDuplicate::UniqueName);
3237
3238 strip_new->start = start_ofs;
3239 strip_new->type = STRIP_TYPE_IMAGE;
3240 strip_new->content_length_set(1);
3241 strip_new->flag |= SEQ_SINGLE_FRAME_CONTENT;
3242 strip_new->end_offset_set(1 - step);
3243 /* This strip represents a single already-selected image, not a trimmed view into
3244 * the original strip's content, so the copied trim offsets no longer apply. */
3245 strip_new->anim_startofs = 0;
3246 strip_new->anim_endofs = 0;
3247
3248 /* New strip. */
3249 StripData *data_new = strip_new->data;
3250
3251 /* New stripdata, only one element now. */
3252 /* Note this assume all elements (images) have the same dimension,
3253 * since we only copy the name here. */
3254 se_new = static_cast<StripElem *>(
3255 MEM_realloc_uninitialized(data_new->stripdata, sizeof(*se_new)));
3256 STRNCPY(se_new->filename, se->filename);
3257 data_new->stripdata = se_new;
3258 data_new->stripdata_num = 1;
3259
3260 new_strips.add(strip_new);
3261
3262 /* XXX, COPY FCURVES */
3263
3264 timeline_frame++;
3265 start_ofs += step;
3266 }
3267
3268 strip_next = static_cast<Strip *>(strip->next);
3269 seq::edit_flag_for_removal(scene, strip);
3270 strip = strip_next;
3271 }
3272 else {
3273 strip = strip->next;
3274 }
3275 }
3276
3277 seq::edit_remove_flagged_strips(scene, seqbase);
3278 if (step > 1) {
3279 seq::transform_handle_overlap(scene, seqbase, new_strips, false);
3280 }
3282
3283 return OPERATOR_FINISHED;
3284}
3285
3287 wmOperator *op,
3288 const wmEvent *event)
3289{
3291 C, op, event, IFACE_("Separate Sequence Images"), IFACE_("Separate"));
3292}
3293
3295{
3296 /* Identifiers. */
3297 ot->name = "Separate Images";
3298 ot->idname = "SEQUENCER_OT_images_separate";
3299 ot->description = "On image sequence strips, it returns a strip for each image";
3300
3301 /* API callbacks. */
3305
3306 /* Flags. */
3308
3309 RNA_def_int(ot->srna, "length", 1, 1, INT_MAX, "Length", "Length of each frame", 1, 1000);
3310}
3311
3313
3314/* -------------------------------------------------------------------- */
3317
3319{
3321 Editing *ed = seq::editing_get(scene);
3322 Strip *active_strip = seq::select_active_get(scene);
3323
3324 seq::prefetch_stop(scene);
3325
3326 if (active_strip && active_strip->type == STRIP_TYPE_META && active_strip->flag & SEQ_SELECT) {
3327 /* Deselect active meta strip. */
3328 seq::select_active_set(scene, nullptr);
3329 seq::meta_stack_set(scene, active_strip);
3330 /* Invalidate the cache of the meta strip when going in and out of it.
3331 * The cache does not consider if we are inside of a meta strip or not,
3332 * so we have to make sure that we recache so it is not using outdated data.
3333 */
3334 seq::relations_invalidate_cache(scene, active_strip);
3335 }
3336 else {
3337 /* Exit meta-strip if possible. */
3338 if (ed->metastack.is_empty()) {
3339 return OPERATOR_CANCELLED;
3340 }
3341
3342 /* Display parent meta. */
3343 Strip *meta_parent = seq::meta_stack_pop(ed);
3344 seq::select_active_set(scene, meta_parent);
3345 /* Invalidate the cache of the meta strip when going in and out of it.
3346 * The cache does not consider if we are inside of a meta strip or not,
3347 * so we have to make sure that we recache so it is not using outdated data.
3348 */
3349 seq::relations_invalidate_cache(scene, meta_parent);
3350 }
3351
3354
3355 return OPERATOR_FINISHED;
3356}
3357
3359{
3360 /* Identifiers. */
3361 ot->name = "Toggle Meta Strip";
3362 ot->idname = "SEQUENCER_OT_meta_toggle";
3363 ot->description = "Toggle a meta-strip (to edit enclosed strips)";
3364
3365 /* API callbacks. */
3368
3369 /* Flags. */
3371}
3372
3374
3375/* -------------------------------------------------------------------- */
3378
3380{
3382 Editing *ed = seq::editing_get(scene);
3383 Strip *active_strip = seq::select_active_get(scene);
3384 ListBaseT<Strip> *active_seqbase = seq::active_seqbase_get(ed);
3385
3386 VectorSet<Strip *> selected = seq::query_selected_strips(active_seqbase);
3387
3388 if (selected.is_empty()) {
3389 return OPERATOR_CANCELLED;
3390 }
3391
3392 seq::prefetch_stop(scene);
3393
3394 int channel_max = 1, channel_min = std::numeric_limits<int>::max(), meta_start_frame = MAXFRAME,
3395 meta_end_frame = std::numeric_limits<int>::min();
3396 Strip *strip_meta = seq::strip_alloc(active_seqbase, 1, 1, STRIP_TYPE_META);
3397
3398 /* Remove all selected from main list, and put in meta.
3399 * Strip is moved within the same edit, no need to re-generate the UID. */
3400 VectorSet<Strip *> strips_to_move;
3401 strips_to_move.add_multiple(selected);
3403
3404 for (Strip *strip : strips_to_move) {
3405 seq::relations_invalidate_cache(scene, strip);
3406 BLI_remlink(active_seqbase, strip);
3407 BLI_addtail(&strip_meta->seqbase, strip);
3408 channel_max = max_ii(strip->channel, channel_max);
3409 channel_min = min_ii(strip->channel, channel_min);
3410 meta_start_frame = min_ii(strip->left_handle(), meta_start_frame);
3411 meta_end_frame = max_ii(strip->right_handle(scene), meta_end_frame);
3412 strip->flag &= ~STRIP_ALLSEL;
3413 }
3414
3415 ListBaseT<SeqTimelineChannel> *channels_cur = seq::channels_displayed_get(ed);
3416 ListBaseT<SeqTimelineChannel> *channels_meta = &strip_meta->channels;
3417 for (int i = channel_min; i <= channel_max; i++) {
3418 SeqTimelineChannel *channel_cur = seq::channel_get_by_index(channels_cur, i);
3419 SeqTimelineChannel *channel_meta = seq::channel_get_by_index(channels_meta, i);
3420 STRNCPY_UTF8(channel_meta->name, channel_cur->name);
3421 channel_meta->flag = channel_cur->flag;
3422 }
3423
3424 const int channel = active_strip ? active_strip->channel : channel_max;
3425 strip_meta->channel_set(channel);
3426 BLI_strncpy_utf8(strip_meta->name + 2, DATA_("MetaStrip"), sizeof(strip_meta->name) - 2);
3427 seq::strip_unique_name_set(scene, &ed->seqbase, strip_meta);
3428 strip_meta->start = meta_start_frame;
3429 strip_meta->content_length_set(meta_end_frame - meta_start_frame);
3430 seq::select_active_set(scene, strip_meta);
3431 VectorSet<Strip *> meta_strips;
3432 meta_strips.add(strip_meta);
3433 seq::transform_handle_overlap(scene, active_seqbase, meta_strips, false);
3434
3438
3439 return OPERATOR_FINISHED;
3440}
3441
3443{
3444 /* Identifiers. */
3445 ot->name = "Make Meta Strip";
3446 ot->idname = "SEQUENCER_OT_meta_make";
3447 ot->description = "Group selected strips into a meta-strip";
3448
3449 /* API callbacks. */
3452
3453 /* Flags. */
3455}
3456
3458
3459/* -------------------------------------------------------------------- */
3462
3464{
3466 Editing *ed = seq::editing_get(scene);
3467 Strip *active_strip = seq::select_active_get(scene);
3468
3469 if (active_strip == nullptr || active_strip->type != STRIP_TYPE_META) {
3470 return OPERATOR_CANCELLED;
3471 }
3472
3473 seq::prefetch_stop(scene);
3474
3475 for (Strip &strip : active_strip->seqbase) {
3476 /* Expand selection to meta strip's old contents. */
3477 strip.flag &= ~STRIP_ALLSEL;
3478 strip.flag |= SEQ_SELECT;
3479
3480 seq::relations_invalidate_cache(scene, &strip);
3481 }
3482
3483 /* Remove all selected from meta, and put in main list.
3484 * Strip is moved within the same edit, no need to re-generate the UID. */
3485 BLI_movelisttolist(ed->current_strips(), &active_strip->seqbase);
3486 active_strip->seqbase.clear_no_delete();
3487
3488 ListBaseT<Strip> *active_seqbase = seq::active_seqbase_get(ed);
3489 seq::edit_flag_for_removal(scene, active_strip);
3490 seq::edit_remove_flagged_strips(scene, active_seqbase);
3491
3492 /* Test for effects and overlap. */
3493 VectorSet<Strip *> separated_strips;
3494 for (Strip &strip : *active_seqbase) {
3495 if (strip.flag & SEQ_SELECT) {
3496 separated_strips.add(&strip);
3497 }
3498 }
3499 seq::transform_handle_overlap(scene, active_seqbase, separated_strips, false);
3500
3503
3504 return OPERATOR_FINISHED;
3505}
3506
3508{
3509 /* Identifiers. */
3510 ot->name = "UnMeta Strip";
3511 ot->idname = "SEQUENCER_OT_meta_separate";
3512 ot->description = "Put the contents of a meta-strip back in the sequencer";
3513
3514 /* API callbacks. */
3517
3518 /* Flags. */
3520}
3521
3523
3524/* -------------------------------------------------------------------- */
3527
3528static bool strip_jump_internal(Scene *scene,
3529 const seq::Side side,
3530 const bool do_skip_mute,
3531 const bool do_center)
3532{
3533 bool changed = false;
3534 int timeline_frame = scene->r.cfra;
3535 int next_frame = seq::time_find_next_prev_edit(
3536 scene, timeline_frame, side, do_skip_mute, do_center, false);
3537
3538 if (next_frame != timeline_frame) {
3539 scene->r.cfra = next_frame;
3540 changed = true;
3541 }
3542
3543 return changed;
3544}
3545
3547{
3548 /* Prevent changes during render. */
3549 if (G.is_rendering) {
3550 return false;
3551 }
3552
3553 return sequencer_edit_poll(C);
3554}
3555
3557{
3559 const bool next = RNA_boolean_get(op->ptr, "next");
3560 const bool center = RNA_boolean_get(op->ptr, "center");
3561
3562 /* Currently do_skip_mute is always true. */
3563 if (!strip_jump_internal(scene, next ? seq::Side::Right : seq::Side::Left, true, center)) {
3564 return OPERATOR_CANCELLED;
3565 }
3566
3568
3571
3572 return OPERATOR_FINISHED;
3573}
3574
3576{
3577 /* Identifiers. */
3578 ot->name = "Jump to Strip";
3579 ot->idname = "SEQUENCER_OT_strip_jump";
3580 ot->description =
3581 "Move playhead to the next or previous edit point, which may be a strip handle or its "
3582 "center";
3583
3584 /* API callbacks. */
3587
3588 /* Flags. */
3589 ot->flag = OPTYPE_UNDO;
3590
3591 /* Properties. */
3593 "next",
3594 true,
3595 "Next Strip",
3596 "Jump to the next handle or center, else the previous");
3598 "center",
3599 true,
3600 "Use Strip Center",
3601 "Jump to the center of the strip rather than its handles");
3602}
3603
3605
3606/* -------------------------------------------------------------------- */
3609
3611 {int(seq::Side::Left), "LEFT", 0, "Left", ""},
3612 {int(seq::Side::Right), "RIGHT", 0, "Right", ""},
3613 {0, nullptr, 0, nullptr, nullptr},
3614};
3615
3616static void swap_strips(Scene *scene, Strip *strip_a, Strip *strip_b)
3617{
3618 int gap = strip_b->left_handle() - strip_a->right_handle(scene);
3619 int strip_a_start;
3620 int strip_b_start;
3621
3622 strip_b_start = (strip_b->start - strip_b->left_handle()) + strip_a->left_handle();
3623 seq::transform_translate_strip(scene, strip_b, strip_b_start - strip_b->start);
3624 seq::relations_invalidate_cache(scene, strip_b);
3625
3626 strip_a_start = (strip_a->start - strip_a->left_handle()) + strip_b->right_handle(scene) + gap;
3627 seq::transform_translate_strip(scene, strip_a, strip_a_start - strip_a->start);
3628 seq::relations_invalidate_cache(scene, strip_a);
3629}
3630
3631static Strip *find_next_prev_strip(Scene *scene, Strip *test, seq::Side lr, int sel)
3632{
3633 /* sel: 0==unselected, 1==selected, -1==don't care. */
3634 Strip *strip, *best_strip = nullptr;
3635 Editing *ed = seq::editing_get(scene);
3636
3637 int dist, best_dist;
3638 best_dist = MAXFRAME * 2;
3639
3640 if (ed == nullptr) {
3641 return nullptr;
3642 }
3643
3644 strip = ed->current_strips()->first();
3645 while (strip) {
3646 if ((strip != test) && (test->channel == strip->channel) &&
3647 ((sel == -1) || (sel == (strip->flag & SEQ_SELECT))))
3648 {
3649 dist = MAXFRAME * 2;
3650
3651 switch (lr) {
3652 case seq::Side::Left:
3653 if (strip->right_handle(scene) <= test->left_handle()) {
3654 dist = test->right_handle(scene) - strip->left_handle();
3655 }
3656 break;
3657 case seq::Side::Right:
3658 if (strip->left_handle() >= test->right_handle(scene)) {
3659 dist = strip->left_handle() - test->right_handle(scene);
3660 }
3661 break;
3662 default:
3663 break;
3664 }
3665
3666 if (dist == 0) {
3667 best_strip = strip;
3668 break;
3669 }
3670 if (dist < best_dist) {
3671 best_dist = dist;
3672 best_strip = strip;
3673 }
3674 }
3675 strip = static_cast<Strip *>(strip->next);
3676 }
3677 return best_strip; /* Can be nullptr. */
3678}
3679
3680static bool strip_is_parent(const Strip *par, const Strip *strip)
3681{
3682 return ((par->input1 == strip) || (par->input2 == strip));
3683}
3684
3686{
3688 Editing *ed = seq::editing_get(scene);
3689 Strip *active_strip = seq::select_active_get(scene);
3690 ListBaseT<Strip> *seqbase = seq::active_seqbase_get(ed);
3691 Strip *strip;
3692 auto side = seq::Side(RNA_enum_get(op->ptr, "side"));
3693
3694 if (active_strip == nullptr) {
3695 return OPERATOR_CANCELLED;
3696 }
3697
3698 strip = find_next_prev_strip(scene, active_strip, side, -1);
3699
3700 if (strip) {
3701
3702 /* Disallow effect strips. */
3703 if (strip->is_effect_with_inputs() && (strip->effectdata || strip->input1 || strip->input2)) {
3704 return OPERATOR_CANCELLED;
3705 }
3706 if (active_strip->is_effect_with_inputs() &&
3707 (active_strip->effectdata || active_strip->input1 || active_strip->input2))
3708 {
3709 return OPERATOR_CANCELLED;
3710 }
3711
3712 const ListBaseT<SeqTimelineChannel> *channels = seq::channels_displayed_get(
3713 seq::editing_get(scene));
3714 if (seq::transform_is_locked(channels, strip) ||
3715 seq::transform_is_locked(channels, active_strip))
3716 {
3717 return OPERATOR_CANCELLED;
3718 }
3719
3720 switch (side) {
3721 case seq::Side::Left:
3722 swap_strips(scene, strip, active_strip);
3723 break;
3724 case seq::Side::Right:
3725 swap_strips(scene, active_strip, strip);
3726 break;
3727 default:
3728 break;
3729 }
3730
3731 /* Do this in a new loop since both effects need to be calculated first. */
3732 for (Strip &istrip : *seqbase) {
3733 if (istrip.is_effect() &&
3734 (strip_is_parent(&istrip, active_strip) || strip_is_parent(&istrip, strip)))
3735 {
3736 /* This may now overlap. */
3737 seq::transform_shuffle_vertical(seqbase, {&istrip}, scene);
3738 }
3739 }
3740
3742 return OPERATOR_FINISHED;
3743 }
3744
3745 return OPERATOR_CANCELLED;
3746}
3747
3749{
3750 /* Identifiers. */
3751 ot->name = "Swap Strip";
3752 ot->idname = "SEQUENCER_OT_swap";
3753 ot->description = "Swap active strip with strip to the right or left";
3754
3755 /* API callbacks. */
3758
3759 /* Flags. */
3761
3762 /* Properties. */
3763 RNA_def_enum(ot->srna,
3764 "side",
3766 int(seq::Side::Right),
3767 "Side",
3768 "Side of the strip to swap");
3769}
3770
3772
3773/* -------------------------------------------------------------------- */
3776
3778{
3780 Strip *active_strip = seq::select_active_get(scene);
3781
3782 if (active_strip == nullptr || active_strip->data == nullptr ||
3783 active_strip->type == STRIP_TYPE_SOUND)
3784 {
3785 return OPERATOR_CANCELLED;
3786 }
3787
3788 const int2 old_size(scene->r.xsch, scene->r.ysch);
3789 const int2 size = seq::image_transform_box_size_get(scene, active_strip);
3790
3791 /* Prevent setting the render size if values aren't initialized. */
3792 if (size.x <= 0 || size.y <= 0) {
3793 return OPERATOR_CANCELLED;
3794 }
3795
3796 scene->r.xsch = size.x;
3797 scene->r.ysch = size.y;
3798
3799 active_strip->data->transform->scale_x = active_strip->data->transform->scale_y = 1.0f;
3800 active_strip->data->transform->xofs = active_strip->data->transform->yofs = 0.0f;
3801
3802 /* Reset properties that are relative to the scene resolution so they match the new size. */
3803 if (active_strip->type == STRIP_TYPE_TEXT) {
3805 *static_cast<TextVars *>(active_strip->effectdata), old_size, size);
3806 }
3807
3808 seq::relations_invalidate_cache(scene, active_strip);
3811
3812 return OPERATOR_FINISHED;
3813}
3814
3816{
3817 /* Identifiers. */
3818 ot->name = "Set Render Size";
3819 ot->idname = "SEQUENCER_OT_rendersize";
3820 ot->description = "Set render size and aspect from active strip";
3821
3822 /* API callbacks. */
3825
3826 /* Flags. */
3828}
3829
3831
3832/* -------------------------------------------------------------------- */
3835
3837{
3838 /* Identifiers. */
3839 ot->name = "Copy";
3840 ot->idname = "SEQUENCER_OT_copy";
3841 ot->description = "Copy the selected strips to the internal clipboard";
3842
3843 /* API callbacks. */
3846
3847 /* Flags. */
3848 ot->flag = OPTYPE_REGISTER;
3849}
3850
3852
3853/* -------------------------------------------------------------------- */
3856
3858{
3859 /* Identifiers. */
3860 ot->name = "Paste";
3861 ot->idname = "SEQUENCER_OT_paste";
3862 ot->description = "Paste strips from the internal clipboard";
3863
3864 /* API callbacks. */
3868
3869 /* Flags. */
3871
3872 /* Properties. */
3874 ot->srna,
3875 "keep_offset",
3876 false,
3877 "Keep Offset",
3878 "Keep strip offset relative to the current frame when pasting");
3880 prop = RNA_def_int(ot->srna, "x", 0, INT_MIN, INT_MAX, "X", "", INT_MIN, INT_MAX);
3882 prop = RNA_def_int(ot->srna, "y", 0, INT_MIN, INT_MAX, "Y", "", INT_MIN, INT_MAX);
3884}
3885
3887
3888/* -------------------------------------------------------------------- */
3891
3893{
3895 Strip *strip_act;
3896 Strip *strip_other;
3897 const char *error_msg;
3898
3899 if (seq::select_active_get_pair(scene, &strip_act, &strip_other) == false) {
3900 BKE_report(op->reports, RPT_ERROR, "Please select two strips");
3901 return OPERATOR_CANCELLED;
3902 }
3903
3904 if (seq::edit_strip_swap(scene, strip_act, strip_other, &error_msg) == false) {
3905 BKE_report(op->reports, RPT_ERROR, error_msg);
3906 return OPERATOR_CANCELLED;
3907 }
3908
3909 strip_act->runtime->remove_scene_sound(scene);
3910 strip_other->runtime->remove_scene_sound(scene);
3911
3912 strip_act->runtime->clear_sound_time_stretch();
3913 strip_other->runtime->clear_sound_time_stretch();
3914
3915 if (strip_act->sound) {
3916 BKE_sound_add_scene_sound(scene, strip_act);
3917 }
3918 if (strip_other->sound) {
3919 BKE_sound_add_scene_sound(scene, strip_other);
3920 }
3921
3922 seq::relations_invalidate_cache_raw(scene, strip_act);
3923 seq::relations_invalidate_cache_raw(scene, strip_other);
3924
3926
3927 return OPERATOR_FINISHED;
3928}
3929
3931{
3932 /* Identifiers. */
3933 ot->name = "Sequencer Swap Data";
3934 ot->idname = "SEQUENCER_OT_swap_data";
3935 ot->description = "Swap 2 sequencer strips";
3936
3937 /* API callbacks. */
3940
3941 /* Flags. */
3943}
3944
3946
3947/* -------------------------------------------------------------------- */
3950
3952 {STRIP_TYPE_CROSS, "CROSS", 0, "Crossfade", "Fade out of one video, fading into another"},
3953 {STRIP_TYPE_ADD, "ADD", 0, "Add", "Add together color channels from two videos"},
3954 {STRIP_TYPE_SUB, "SUBTRACT", 0, "Subtract", "Subtract one strip's color from another"},
3955 {STRIP_TYPE_ALPHAOVER, "ALPHA_OVER", 0, "Alpha Over", "Blend alpha on top of another video"},
3956 {STRIP_TYPE_ALPHAUNDER, "ALPHA_UNDER", 0, "Alpha Under", "Blend alpha below another video"},
3957 {STRIP_TYPE_GAMCROSS, "GAMMA_CROSS", 0, "Gamma Crossfade", "Crossfade with color correction"},
3958 {STRIP_TYPE_MUL, "MULTIPLY", 0, "Multiply", "Multiply color channels from two videos"},
3959 {STRIP_TYPE_WIPE, "WIPE", 0, "Wipe", "Sweep a transition line across the frame"},
3960 {STRIP_TYPE_GLOW, "GLOW", 0, "Glow", "Add blur and brightness to light areas"},
3961 {STRIP_TYPE_COLOR, "COLOR", 0, "Color", "Add a simple color strip"},
3962 {STRIP_TYPE_SPEED, "SPEED", 0, "Speed", "Timewarp video strips, modifying playback speed"},
3963 {STRIP_TYPE_MULTICAM, "MULTICAM", 0, "Multicam Selector", "Control active camera angles"},
3964 {STRIP_TYPE_ADJUSTMENT, "ADJUSTMENT", 0, "Adjustment Layer", "Apply nondestructive effects"},
3965 {STRIP_TYPE_GAUSSIAN_BLUR, "GAUSSIAN_BLUR", 0, "Gaussian Blur", "Soften details along axes"},
3966 {STRIP_TYPE_TEXT, "TEXT", 0, "Text", "Add a simple text strip"},
3967 {STRIP_TYPE_COLORMIX, "COLORMIX", 0, "Color Mix", "Combine two strips using blend modes"},
3968 {STRIP_TYPE_COMPOSITOR, "COMPOSITOR", 0, "Compositor", "Compositor based effect"},
3969 {0, nullptr, 0, nullptr, nullptr},
3970};
3971
3973{
3975 Strip *strip = seq::select_active_get(scene);
3976 const StripType old_type = strip->type;
3977 const int have_inputs = strip->effect_num_inputs_get();
3978 const StripType new_type = StripType(RNA_enum_get(op->ptr, "type"));
3979
3980 if (!strip->is_effect()) {
3981 return OPERATOR_CANCELLED;
3982 }
3983
3984 /* Note: allow changing to compositor effect; it can have any number of inputs. */
3985 if (new_type != STRIP_TYPE_COMPOSITOR) {
3986 if (have_inputs != seq::effect_type_get_min_num_inputs(new_type)) {
3987 BKE_report(op->reports, RPT_ERROR, "New effect takes less or more inputs");
3988 return OPERATOR_CANCELLED;
3989 }
3990 }
3991
3992 /* Free previous effect. */
3993 seq::effect_free(strip);
3994
3995 strip->type = new_type;
3996
3997 /* If the strip's name is the default (equal to the old effect type),
3998 * rename to the new type to avoid confusion. */
3999 char name_base[MAX_ID_NAME];
4000 int name_num;
4001 BLI_string_split_name_number(strip->name + 2, '.', name_base, &name_num);
4002 if (STREQ(name_base, seq::get_default_stripname_by_type(old_type))) {
4003 seq::edit_strip_name_set(scene, strip, seq::strip_give_name(strip));
4005 }
4006
4007 /* Init new effect. */
4009
4010 seq::relations_invalidate_cache(scene, strip);
4012
4013 return OPERATOR_FINISHED;
4014}
4015
4017{
4018 /* Identifiers. */
4019 ot->name = "Change Effect Type";
4020 ot->idname = "SEQUENCER_OT_change_effect_type";
4021 ot->description = "Replace effect strip with another that takes the same number of inputs";
4022
4023 /* API callbacks. */
4026
4027 /* Flags. */
4029
4030 ot->prop = RNA_def_enum(ot->srna,
4031 "type",
4034 "Type",
4035 "Strip effect type");
4037}
4038
4040
4041/* -------------------------------------------------------------------- */
4044
4046{
4047 if ((op->flag & OP_IS_INVOKE) && !WM_operator_poll_or_report_error(C, op->type, op->reports)) {
4048 return OPERATOR_CANCELLED;
4049 }
4050
4051 Main *bmain = CTX_data_main(C);
4053 Strip *strip = seq::select_active_get(scene);
4054 const bool is_relative_path = RNA_boolean_get(op->ptr, "relative_path");
4055 const bool use_placeholders = RNA_boolean_get(op->ptr, "use_placeholders");
4056
4057 if (strip->type == STRIP_TYPE_IMAGE) {
4058 char directory[FILE_MAX];
4059 int len = 0;
4060 StripElem *se;
4061
4062 const char *blendfile_path = BKE_main_blendfile_path(bmain);
4063 ListBaseT<ImageFrameRange> ranges = ED_image_filesel_detect_sequences(
4064 blendfile_path, blendfile_path, op, false);
4065 for (ImageFrameRange &range : ranges) {
4066 len += use_placeholders ? range.max_framenr - range.offset + 1 : range.frames.count();
4067 }
4068
4069 if (len == 0) {
4070 return OPERATOR_CANCELLED;
4071 }
4072
4073 RNA_string_get(op->ptr, "directory", directory);
4074 if (is_relative_path) {
4075 /* TODO(@ideasman42): shouldn't this already be relative from the filesel?
4076 * (as the 'filepath' is) for now just make relative here,
4077 * but look into changing after 2.60. */
4078 BLI_path_rel(directory, BKE_main_blendfile_path(bmain));
4079 }
4080 STRNCPY(strip->data->dirpath, directory);
4081
4082 if (strip->data->stripdata) {
4083 MEM_delete(strip->data->stripdata);
4084 }
4085 strip->data->stripdata = se = MEM_new_array<StripElem>(len, "stripelem");
4086 strip->data->stripdata_num = len;
4087
4088 for (ImageFrameRange &range : ranges) {
4089 int framenr, numdigits;
4090 if (!BLI_path_frame_get(range.filepath, &framenr, &numdigits)) {
4091 numdigits = 0;
4092 }
4093 char ext[FILE_MAX];
4094 char filename_stripped[FILE_MAX];
4095 BLI_path_split_file_part(range.filepath, filename_stripped, sizeof(filename_stripped));
4096 BLI_path_frame_strip(filename_stripped, ext, sizeof(ext));
4097
4098 if (use_placeholders) {
4099 for (const int i : IndexRange::from_begin_end(range.offset, range.max_framenr + 1)) {
4101 se->filename, sizeof(se->filename), filename_stripped, i, numdigits, ext);
4102 se++;
4103 }
4104 }
4105 else {
4106 for (ImageFrame &frame : range.frames) {
4108 sizeof(se->filename),
4109 filename_stripped,
4110 frame.framenr,
4111 numdigits,
4112 ext);
4113 se++;
4114 }
4115 }
4116 range.frames.free_no_destruct();
4117 }
4118 ranges.free_no_destruct();
4119
4120 if (len == 1) {
4121 strip->flag |= SEQ_SINGLE_FRAME_CONTENT;
4122 }
4123 else {
4124 strip->flag &= ~SEQ_SINGLE_FRAME_CONTENT;
4125 }
4126
4127 /* Reset these else we won't see all the images. */
4128 strip->anim_startofs = strip->anim_endofs = 0;
4129
4130 /* Correct start/end frames so we don't move.
4131 * Also sets `strip->len` from `strip->data->stripdata_num`. */
4132 seq::add_reload_new_file(bmain, scene, strip, true);
4133 }
4134 else if (strip->type == STRIP_TYPE_SOUND) {
4135 bSound *sound = strip->sound;
4136 if (sound == nullptr) {
4137 return OPERATOR_CANCELLED;
4138 }
4139 char filepath[FILE_MAX];
4140 RNA_string_get(op->ptr, "filepath", filepath);
4141 STRNCPY(sound->filepath, filepath);
4142 BKE_sound_load(bmain, sound);
4143 }
4144 else {
4145 /* Lame, set rna filepath. */
4146 PropertyRNA *prop;
4147 char filepath[FILE_MAX];
4148
4149 PointerRNA strip_ptr = RNA_pointer_create_discrete(&scene->id, RNA_Strip, strip);
4150
4151 RNA_string_get(op->ptr, "filepath", filepath);
4152 prop = RNA_struct_find_property(&strip_ptr, "filepath");
4153 RNA_property_string_set(&strip_ptr, prop, filepath);
4154 RNA_property_update(C, &strip_ptr, prop);
4155 }
4156
4159
4160 return OPERATOR_FINISHED;
4161}
4162
4164 wmOperator *op,
4165 const wmEvent * /*event*/)
4166{
4168 Strip *strip = seq::select_active_get(scene);
4169 char filepath[FILE_MAX];
4170
4172 filepath, sizeof(filepath), strip->data->dirpath, strip->data->stripdata->filename);
4173
4174 RNA_string_set(op->ptr, "directory", strip->data->dirpath);
4175 RNA_string_set(op->ptr, "filepath", filepath);
4176
4177 /* Set default display depending on strip type. */
4178 if (strip->type == STRIP_TYPE_IMAGE) {
4179 RNA_boolean_set(op->ptr, "filter_movie", false);
4180 }
4181 else {
4182 RNA_boolean_set(op->ptr, "filter_image", false);
4183 }
4184
4186
4188}
4189
4191 PropertyRNA *prop,
4192 void *user_data)
4193{
4194 wmOperator *op = static_cast<wmOperator *>(user_data);
4195 const char *prop_id = RNA_property_identifier(prop);
4196 if (prop_id == StringRef("use_placeholders")) {
4197 return RNA_boolean_get(op->ptr, "use_sequence_detection");
4198 }
4199 return true;
4200}
4201
4203{
4204 uiDefAutoButsRNA(op->layout,
4205 op->ptr,
4207 op,
4208 nullptr,
4210 false);
4211}
4212
4214{
4215 /* Identifiers. */
4216 ot->name = "Change Data/Files";
4217 ot->idname = "SEQUENCER_OT_change_path";
4218
4219 /* API callbacks. */
4224
4225 /* Flags. */
4227
4236
4237 /* Required for `ED_image_filesel_detect_sequences`. */
4239 ot->srna,
4240 "use_sequence_detection",
4241 true,
4242 "Detect Sequences",
4243 "Automatically detect animated sequences in selected images (based on file names)");
4244
4246 "use_placeholders",
4247 false,
4248 "Use Placeholders",
4249 "Use placeholders for missing frames of the strip");
4250}
4251
4253
4254/* -------------------------------------------------------------------- */
4257
4259{
4261 if (ed == nullptr) {
4262 return false;
4263 }
4264 Strip *strip = ed->act_strip;
4265 return ((strip != nullptr) && (strip->type == STRIP_TYPE_SCENE));
4266}
4268{
4269 Main *bmain = CTX_data_main(C);
4271 Scene *scene_seq = static_cast<Scene *>(
4272 BLI_findlink(&bmain->scenes, RNA_enum_get(op->ptr, "scene")));
4273
4274 if (scene_seq == nullptr) {
4275 BKE_report(op->reports, RPT_ERROR, "Scene not found");
4276 return OPERATOR_CANCELLED;
4277 }
4278
4279 /* Assign new scene. */
4280 Strip *strip = seq::select_active_get(scene);
4281 if (strip) {
4282 strip->scene = scene_seq;
4283 /* Do a refresh of the sequencer data. */
4287 }
4288
4291
4292 return OPERATOR_FINISHED;
4293}
4294
4296 wmOperator *op,
4297 const wmEvent *event)
4298{
4299 if (!RNA_struct_property_is_set(op->ptr, "scene")) {
4300 return WM_enum_search_invoke(C, op, event);
4301 }
4302
4303 return sequencer_change_scene_exec(C, op);
4304}
4305
4307{
4308 PropertyRNA *prop;
4309
4310 /* Identifiers. */
4311 ot->name = "Change Scene";
4312 ot->idname = "SEQUENCER_OT_change_scene";
4313 ot->description = "Change Scene assigned to Strip";
4314
4315 /* API callbacks. */
4319
4320 /* Flags. */
4322
4323 /* Properties. */
4324 prop = RNA_def_enum(
4325 ot->srna, "scene", rna_enum_dummy_NULL_items, 0, "Scene", "Scene to assign to the strip");
4328 ot->prop = prop;
4329}
4330
4332
4333/* -------------------------------------------------------------------- */
4336
4338static int strip_cmp_time_startdisp_channel(void * /*thunk*/, const void *a, const void *b)
4339{
4340 const Strip *strip_a = static_cast<const Strip *>(a);
4341 const Strip *strip_b = static_cast<const Strip *>(b);
4342
4343 int strip_a_start = strip_a->left_handle();
4344 int strip_b_start = strip_b->left_handle();
4345
4346 /* If strips have the same start frame favor the one with a higher channel. */
4347 if (strip_a_start == strip_b_start) {
4348 return strip_a->channel > strip_b->channel;
4349 }
4350
4351 return (strip_a_start > strip_b_start);
4352}
4353
4355 wmOperator *op,
4356 const wmEvent * /*event*/)
4357{
4359
4361
4363}
4364
4366 ListBaseT<Strip> *text_seq;
4368};
4369
4370static bool strip_get_text_strip_cb(Strip *strip, void *user_data)
4371{
4372 Seq_get_text_cb_data *cd = static_cast<Seq_get_text_cb_data *>(user_data);
4374 ListBaseT<SeqTimelineChannel> *channels = seq::channels_displayed_get(ed);
4375 /* Only text strips that are not muted and don't end with negative frame. */
4376 if ((strip->type == STRIP_TYPE_TEXT) && !seq::render_is_muted(channels, strip) &&
4377 (strip->right_handle(cd->scene) > cd->scene->r.sfra))
4378 {
4379 BLI_addtail(cd->text_seq, MEM_dupalloc(strip));
4380 }
4381 return true;
4382}
4383
4385{
4386 if ((op->flag & OP_IS_INVOKE) && !WM_operator_poll_or_report_error(C, op->type, op->reports)) {
4387 return OPERATOR_CANCELLED;
4388 }
4389
4391 Strip *strip, *strip_next;
4392 Editing *ed = seq::editing_get(scene);
4393 ListBaseT<Strip> text_seq = {nullptr};
4394 int iter = 1; /* Sequence numbers in `.srt` files are 1-indexed. */
4395 FILE *file;
4396 char filepath[FILE_MAX];
4397
4398 if (!RNA_struct_property_is_set_ex(op->ptr, "filepath", false)) {
4399 BKE_report(op->reports, RPT_ERROR, "No filepath given");
4400 return OPERATOR_CANCELLED;
4401 }
4402
4403 RNA_string_get(op->ptr, "filepath", filepath);
4404 BLI_path_extension_ensure(filepath, sizeof(filepath), ".srt");
4405
4406 /* Avoid File write exceptions. */
4407 if (!BLI_exists(filepath)) {
4409 if (!BLI_file_touch(filepath)) {
4410 BKE_report(op->reports, RPT_ERROR, "Cannot create subtitle file");
4411 return OPERATOR_CANCELLED;
4412 }
4413 }
4414 else if (!BLI_file_is_writable(filepath)) {
4415 BKE_report(op->reports, RPT_ERROR, "Cannot overwrite export file");
4416 return OPERATOR_CANCELLED;
4417 }
4418
4419 if (ed != nullptr) {
4420 Seq_get_text_cb_data cb_data = {&text_seq, scene};
4421 seq::foreach_strip(&ed->seqbase, strip_get_text_strip_cb, &cb_data);
4422 }
4423
4424 if (text_seq.is_empty()) {
4425 BKE_report(op->reports, RPT_ERROR, "No subtitles (text strips) to export");
4426 return OPERATOR_CANCELLED;
4427 }
4428
4430
4431 /* Open and write file. */
4432 file = BLI_fopen(filepath, "w");
4433
4434 for (strip = text_seq.first(); strip; strip = strip_next) {
4435 TextVars *data = static_cast<TextVars *>(strip->effectdata);
4436 char timecode_str_start[32];
4437 char timecode_str_end[32];
4438
4439 /* Write time-code relative to start frame of scene. Don't allow negative time-codes. */
4440 BLI_timecode_string_from_time(timecode_str_start,
4441 sizeof(timecode_str_start),
4442 -2,
4443 FRA2TIME(max_ii(strip->left_handle() - scene->r.sfra, 0)),
4444 scene->frames_per_second(),
4446 BLI_timecode_string_from_time(timecode_str_end,
4447 sizeof(timecode_str_end),
4448 -2,
4449 FRA2TIME(strip->right_handle(scene) - scene->r.sfra),
4450 scene->frames_per_second(),
4452
4453 fprintf(file,
4454 "%d\n%s --> %s\n%s\n\n",
4455 iter++,
4456 timecode_str_start,
4457 timecode_str_end,
4458 data->text_ptr);
4459
4460 strip_next = static_cast<Strip *>(strip->next);
4461 MEM_delete(strip);
4462 }
4463
4464 fclose(file);
4465
4466 return OPERATOR_FINISHED;
4467}
4468
4470{
4472 if (!scene) {
4473 CTX_wm_operator_poll_msg_set(C, "Context missing sequencer scene");
4474 return false;
4475 }
4476 Editing *ed = seq::editing_get(scene);
4477 if (!ed) {
4478 return false;
4479 }
4480 Strip *strip = ed->act_strip;
4481 if (!strip) {
4482 return false;
4483 }
4484 return strip->type == STRIP_TYPE_TEXT;
4485}
4486
4488{
4489 /* Identifiers. */
4490 ot->name = "Export Subtitles";
4491 ot->idname = "SEQUENCER_OT_export_subtitles";
4492 ot->description = "Export .srt file containing text strips";
4493
4494 /* API callbacks. */
4498
4499 /* Flags. */
4501
4505 FILE_SAVE,
4509}
4510
4512
4513/* -------------------------------------------------------------------- */
4516
4518{
4520 Editing *ed = seq::editing_get(scene);
4521
4522 int sfra = MAXFRAME;
4523 int efra = -MAXFRAME;
4524 bool selected = false;
4525 const bool preview = RNA_boolean_get(op->ptr, "preview");
4526
4527 for (Strip &strip : *ed->current_strips()) {
4528 if (strip.flag & SEQ_SELECT) {
4529 selected = true;
4530 sfra = min_ii(sfra, strip.left_handle());
4531 /* Offset of -1 is needed because in the sequencer every frame has width.
4532 * Range from 1 to 1 is drawn as range 1 to 2, because 1 frame long strip starts at frame 1
4533 * and ends at frame 2. See #106480. */
4534 efra = max_ii(efra, strip.right_handle(scene) - 1);
4535 }
4536 }
4537
4538 if (!selected) {
4539 BKE_report(op->reports, RPT_WARNING, "Select one or more strips");
4540 return OPERATOR_CANCELLED;
4541 }
4542 if (efra < 0) {
4543 BKE_report(op->reports, RPT_ERROR, "Cannot set a negative range");
4544 return OPERATOR_CANCELLED;
4545 }
4546
4547 if (preview) {
4548 scene->r.flag |= SCER_PRV_RANGE;
4549 scene->r.psfra = max_ii(0, sfra);
4550 scene->r.pefra = efra;
4551 }
4552 else {
4553 scene->r.flag &= ~SCER_PRV_RANGE;
4554 scene->r.sfra = max_ii(0, sfra);
4555 scene->r.efra = efra;
4556 }
4557
4560
4561 return OPERATOR_FINISHED;
4562}
4563
4565{
4566 PropertyRNA *prop;
4567
4568 /* Identifiers. */
4569 ot->name = "Set Range to Strips";
4570 ot->idname = "SEQUENCER_OT_set_range_to_strips";
4571 ot->description = "Set the frame range to the selected strips start and end";
4572
4573 /* API callbacks. */
4576
4577 /* Flags. */
4579
4580 prop = RNA_def_boolean(ot->srna, "preview", false, "Preview", "Set the preview range instead");
4582}
4583
4585
4586/* -------------------------------------------------------------------- */
4589
4590enum {
4595};
4596
4598 {STRIP_TRANSFORM_POSITION, "POSITION", 0, "Position", "Reset strip transform location"},
4599 {STRIP_TRANSFORM_SCALE, "SCALE", 0, "Scale", "Reset strip transform scale"},
4600 {STRIP_TRANSFORM_ROTATION, "ROTATION", 0, "Rotation", "Reset strip transform rotation"},
4601 {STRIP_TRANSFORM_ALL, "ALL", 0, "All", "Reset strip transform location, scale and rotation"},
4602 {0, nullptr, 0, nullptr, nullptr},
4603};
4604
4606{
4608 const Editing *ed = seq::editing_get(scene);
4609 const int property = RNA_enum_get(op->ptr, "property");
4610
4611 const bool use_autokeyframe = animrig::is_autokey_on(scene);
4612 const bool only_when_keyed = animrig::is_keying_flag(scene, AUTOKEY_FLAG_INSERTAVAILABLE);
4613
4614 for (Strip &strip : *ed->current_strips()) {
4615 if (strip.flag & SEQ_SELECT && strip.type != STRIP_TYPE_SOUND) {
4616 StripTransform *transform = strip.data->transform;
4617 PropertyRNA *prop;
4618 PointerRNA ptr = RNA_pointer_create_discrete(&scene->id, RNA_StripTransform, transform);
4619 switch (property) {
4621 transform->xofs = 0;
4622 transform->yofs = 0;
4623 if (use_autokeyframe) {
4624 prop = RNA_struct_find_property(&ptr, "offset_x");
4626 C, scene, &ptr, prop, -1, scene->r.cfra, only_when_keyed);
4627 prop = RNA_struct_find_property(&ptr, "offset_y");
4629 C, scene, &ptr, prop, -1, scene->r.cfra, only_when_keyed);
4630 }
4631 break;
4633 transform->scale_x = 1.0f;
4634 transform->scale_y = 1.0f;
4635 if (use_autokeyframe) {
4636 prop = RNA_struct_find_property(&ptr, "scale_x");
4638 C, scene, &ptr, prop, -1, scene->r.cfra, only_when_keyed);
4639 prop = RNA_struct_find_property(&ptr, "scale_y");
4641 C, scene, &ptr, prop, -1, scene->r.cfra, only_when_keyed);
4642 }
4643 break;
4645 transform->rotation = 0.0f;
4646 if (use_autokeyframe) {
4647 prop = RNA_struct_find_property(&ptr, "rotation");
4649 C, scene, &ptr, prop, -1, scene->r.cfra, only_when_keyed);
4650 }
4651 break;
4653 transform->xofs = 0;
4654 transform->yofs = 0;
4655 transform->scale_x = 1.0f;
4656 transform->scale_y = 1.0f;
4657 transform->rotation = 0.0f;
4658 if (use_autokeyframe) {
4659 prop = RNA_struct_find_property(&ptr, "offset_x");
4661 C, scene, &ptr, prop, -1, scene->r.cfra, only_when_keyed);
4662 prop = RNA_struct_find_property(&ptr, "offset_y");
4664 C, scene, &ptr, prop, -1, scene->r.cfra, only_when_keyed);
4665 prop = RNA_struct_find_property(&ptr, "scale_x");
4667 C, scene, &ptr, prop, -1, scene->r.cfra, only_when_keyed);
4668 prop = RNA_struct_find_property(&ptr, "scale_y");
4670 C, scene, &ptr, prop, -1, scene->r.cfra, only_when_keyed);
4671 prop = RNA_struct_find_property(&ptr, "rotation");
4673 C, scene, &ptr, prop, -1, scene->r.cfra, only_when_keyed);
4674 }
4675 break;
4676 }
4677 seq::relations_invalidate_cache(scene, &strip);
4678 }
4679 }
4680
4682 return OPERATOR_FINISHED;
4683}
4684
4686{
4687 /* Identifiers. */
4688 ot->name = "Clear Strip Transform";
4689 ot->idname = "SEQUENCER_OT_strip_transform_clear";
4690 ot->description = "Reset image transformation to default value";
4691
4692 /* API callbacks. */
4695
4696 /* Flags. */
4698
4699 ot->prop = RNA_def_enum(ot->srna,
4700 "property",
4703 "Property",
4704 "Strip transform property to be reset");
4705}
4706
4708
4709/* -------------------------------------------------------------------- */
4712
4714{
4716 const Editing *ed = seq::editing_get(scene);
4717 const eSeqImageFitMethod fit_method = eSeqImageFitMethod(RNA_enum_get(op->ptr, "fit_method"));
4718
4719 for (Strip &strip : *ed->current_strips()) {
4720 if (strip.flag & SEQ_SELECT && strip.type != STRIP_TYPE_SOUND) {
4721 const int2 size = seq::image_transform_box_size_get(scene, &strip);
4722 seq::set_scale_to_fit(&strip, size.x, size.y, scene->r.xsch, scene->r.ysch, fit_method);
4723 seq::relations_invalidate_cache(scene, &strip);
4724 }
4725 }
4726
4728 return OPERATOR_FINISHED;
4729}
4730
4732{
4733 /* Identifiers. */
4734 ot->name = "Strip Transform Set Fit";
4735 ot->idname = "SEQUENCER_OT_strip_transform_fit";
4736
4737 /* API callbacks. */
4740
4741 /* Flags. */
4743
4744 ot->prop = RNA_def_enum(ot->srna,
4745 "fit_method",
4748 "Fit Method",
4749 "Mode for fitting the image to the canvas");
4750}
4751
4753{
4755 const Editing *ed = seq::editing_get(scene);
4756 const StripColorTag color_tag = StripColorTag(RNA_enum_get(op->ptr, "color"));
4757
4758 VectorSet<Strip *> selected = seq::query_selected_strips(ed->current_strips());
4759 if (selected.is_empty()) {
4760 BKE_report(op->reports, RPT_ERROR, "No strips selected");
4761 return OPERATOR_CANCELLED;
4762 }
4763 for (Strip *strip : selected) {
4764 strip->color_tag = color_tag;
4765 }
4766
4768 return OPERATOR_FINISHED;
4769}
4770
4772 PointerRNA *properties)
4773{
4774 const int color = RNA_enum_get(properties, "color");
4775 if (color == STRIP_COLOR_NONE) {
4776 return TIP_("Remove Color Tag");
4777 }
4778 return CTX_IFACE_(ot->translation_context, ot->name);
4779}
4780
4782 wmOperatorType *ot,
4783 PointerRNA *properties)
4784{
4785 const int color = RNA_enum_get(properties, "color");
4786 if (color == STRIP_COLOR_NONE) {
4787 return TIP_("Remove color tag from the selected strips");
4788 }
4789 return ot->description ? CTX_IFACE_(ot->translation_context, ot->description) : "";
4790}
4791
4793{
4794 /* Identifiers. */
4795 ot->name = "Set Color Tag";
4796 ot->idname = "SEQUENCER_OT_strip_color_tag_set";
4797 ot->description = "Set a color tag for the selected strips";
4798
4799 /* API callbacks. */
4804
4805 /* Flags. */
4807
4808 RNA_def_enum(ot->srna,
4809 "color",
4812 "Color Tag",
4813 "Color used to tag strips for organizing them in the timeline");
4814}
4815
4817
4818/* -------------------------------------------------------------------- */
4821
4823{
4825 SpaceSeq *sseq = CTX_wm_space_seq(C);
4826
4827 float cursor_pixel[2];
4828 RNA_float_get_array(op->ptr, "location", cursor_pixel);
4829
4830 float2 cursor_region = seq::image_preview_unit_from_px(scene, cursor_pixel);
4831 copy_v2_v2(sseq->cursor, cursor_region);
4832
4834
4835 /* Use pass-through to allow click-drag to transform the cursor. */
4837}
4838
4840 wmOperator *op,
4841 const wmEvent *event)
4842{
4843 ARegion *region = CTX_wm_region(C);
4844 float cursor_pixel[2];
4846 &region->v2d, event->mval[0], event->mval[1], &cursor_pixel[0], &cursor_pixel[1]);
4847
4848 RNA_float_set_array(op->ptr, "location", cursor_pixel);
4849
4850 return sequencer_set_2d_cursor_exec(C, op);
4851}
4852
4854{
4855 /* identifiers */
4856 ot->name = "Set 2D Cursor";
4857 ot->description = "Set 2D cursor location";
4858 ot->idname = "SEQUENCER_OT_cursor_set";
4859
4860 /* API callbacks. */
4864
4865 /* flags */
4867
4868 /* properties */
4870 "location",
4871 2,
4872 nullptr,
4873 -FLT_MAX,
4874 FLT_MAX,
4875 "Location",
4876 "Cursor location in normalized preview coordinates",
4877 -10.0f,
4878 10.0f);
4879}
4880
4882
4883/* -------------------------------------------------------------------- */
4886
4888 wmOperator * /*op*/)
4889{
4890 CLOG_WARN(&LOG,
4891 "SEQUENCER_OT_scene_frame_range_update is deprecated and will be removed in 6.0. "
4892 "Operator has no effect.");
4893 return OPERATOR_FINISHED;
4894}
4895
4897{
4898 /* Operator is deprecated but logic is kept for backward compatibility. */
4900 return (ed != nullptr && ed->act_strip != nullptr && ed->act_strip->type == STRIP_TYPE_SCENE);
4901}
4902
4903/* Todo: remove in 6.0. */
4905{
4906 /* identifiers */
4907 ot->name = "Update Scene Frame Range";
4908 ot->description =
4909 "Update frame range of scene strip. Deprecated. Has no effect, will be removed in 6.0.";
4910 ot->idname = "SEQUENCER_OT_scene_frame_range_update";
4911
4912 /* API callbacks. */
4915
4916 /* flags */
4918}
4919
4921
4922} // namespace blender::ed::vse
Functions to work with AnimData.
File and directory operations.
#define FILE_MAX
#define BLI_path_join(...)
#define SNPRINTF_UTF8(dst, format,...)
#define STRNCPY_UTF8(dst, src)
#define RPT_(msgid)
#define BLT_I18NCONTEXT_ID_SEQUENCE
#define TIP_(msgid)
#define CTX_IFACE_(context, msgid)
#define IFACE_(msgid)
#define DATA_(msgid)
#define CLOG_WARN(clg_ref,...)
Definition CLG_log.h:189
#define MAX_ID_NAME
Definition DNA_ID.h:367
#define ID_IS_EDITABLE(_id)
Definition DNA_ID.h:708
#define FRA2TIME(a)
#define MAXFRAME
#define STRIP_HAS_PATH(_strip)
#define FRAMENUMBER_MIN_CLAMP(cfra)
#define NUM_STR_REP_LEN
Read Blender memory allocation and freeing.
#define C
Definition RandGen.cpp:29
#define UI_ITEM_NONE
#define UI_MAX_DRAW_STR
#define ND_SEQUENCER
Definition WM_types.hh:456
#define ND_SPACE_SEQUENCER
Definition WM_types.hh:578
#define NC_WINDOW
Definition WM_types.hh:388
#define ND_RENDER_OPTIONS
Definition WM_types.hh:454
#define NC_SCENE
Definition WM_types.hh:391
#define ND_FRAME_RANGE
Definition WM_types.hh:470
#define ND_FRAME
Definition WM_types.hh:453
#define NA_REMOVED
Definition WM_types.hh:637
#define ND_SCENEBROWSE
Definition WM_types.hh:451
#define ND_ANIMCHAN
Definition WM_types.hh:539
#define NC_SPACE
Definition WM_types.hh:405
#define SET_FLAG_FROM_TEST(value, test, flag)
#define ELEM(...)
#define STREQ(a, b)
#define MEM_realloc_uninitialized(vmemh, len)
static constexpr IndexRange from_begin_end(const int64_t begin, const int64_t end)
int64_t size() const
Definition BLI_set.hh:606
bool add(const Key &key)
Definition BLI_set.hh:248
constexpr StringRef()
bool add(const Key &key)
void add_multiple(Span< Key > keys)
int64_t size() const
int64_t remove_if(Predicate &&predicate)
void append(const T &value)
bool is_empty() const
void item(std::string text, int icon1, int icon2=0)
Definition area.cc:1076
void opmodal(std::string text, const wmOperatorType *ot, int propvalue, bool inverted=false)
Definition area.cc:1107
const T & data(const Action &owning_action) const
CCL_NAMESPACE_BEGIN struct Options options
IMETHOD Vector diff(const Vector &a, const Vector &b, double dt)
Definition frames.inl:1166
#define FLT_MAX
#define INT_MAX
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
void camera(KernelGlobals &kg, const ShadingData &sd, float3 &outview, float &outdepth, float &outdist)
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
Definition math_dual.h:263
bool is_autokey_on(const Scene *scene)
Span< FCurve * > fcurves_for_assigned_action(AnimData *adt)
Definition animdata.cc:349
bool autokeyframe_property(bContext *C, Scene *scene, PointerRNA *ptr, PropertyRNA *prop, int rnaindex, float cfra, bool only_if_property_keyed)
bool is_keying_flag(const Scene *scene, eKeying_Flag flag)
bool mode_set(bContext *C, eObjectMode mode)
static wmOperatorStatus sequencer_split_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static wmOperatorStatus sequencer_scene_frame_range_update_exec(bContext *, wmOperator *)
static wmOperatorStatus sequencer_unmute_exec(bContext *C, wmOperator *op)
VectorSet< Strip * > selected_strips_from_context(bContext *C)
static float slip_apply_clamp(const Scene *scene, const SlipData *data, float *r_offset)
void SEQUENCER_OT_meta_toggle(wmOperatorType *ot)
static void slip_update_header(const Scene *scene, ScrArea *area, SlipData *data, const float offset)
static eSeqRippleFlag ripple_flag_from_properties(wmOperator *op)
static bool sequencer_box_blade_poll(bContext *C)
bool sequencer_edit_poll(bContext *C)
void SEQUENCER_OT_meta_make(wmOperatorType *ot)
static void sequencer_split_ui(bContext *, wmOperator *op)
static wmOperatorStatus sequencer_slip_modal(bContext *C, wmOperator *op, const wmEvent *event)
static wmOperatorStatus sequencer_export_subtitles_exec(bContext *C, wmOperator *op)
void SEQUENCER_OT_images_separate(wmOperatorType *ot)
void SEQUENCER_OT_snap(wmOperatorType *ot)
static bool sequencer_strip_change_scene_poll(bContext *C)
void SEQUENCER_OT_swap_inputs(wmOperatorType *ot)
static wmOperatorStatus sequencer_split_exec(bContext *C, wmOperator *op)
static wmOperatorStatus sequencer_add_duplicate_exec(bContext *C, wmOperator *op)
static wmOperatorStatus sequencer_export_subtitles_invoke(bContext *C, wmOperator *op, const wmEvent *)
const EnumPropertyItem prop_snap_side_types[]
static wmOperatorStatus sequencer_delete_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void SEQUENCER_OT_offset_clear(wmOperatorType *ot)
static void sequencer_delete_strip_data(bContext *C, Strip *strip)
static void ripple_properties_from_tool_settings(bContext *C, wmOperator *op)
void SEQUENCER_OT_box_blade(wmOperatorType *ot)
static wmOperatorStatus sequencer_box_blade_exec(bContext *C, wmOperator *op)
static wmOperatorStatus sequencer_box_blade_modal(bContext *C, wmOperator *op, const wmEvent *event)
static void slip_cleanup(bContext *C, wmOperator *op, Scene *scene)
bool has_playback_animation(const Scene *scene)
rctf strip_bounds_get(const Scene *scene, const Strip *strip)
bool check_show_strip(const SpaceSeq &sseq)
void SEQUENCER_OT_copy(wmOperatorType *ot)
static wmOperatorStatus sequencer_mute_exec(bContext *C, wmOperator *op)
static wmOperatorStatus sequencer_separate_images_invoke(bContext *C, wmOperator *op, const wmEvent *event)
wmOperatorStatus sequencer_clipboard_copy_exec(bContext *C, wmOperator *op)
void operator_properties_ripple(wmOperatorType *ot, eSeqRippleFlag options)
static wmOperatorStatus sequencer_gap_insert_exec(bContext *C, wmOperator *op)
static wmOperatorStatus sequencer_ripple_trim_exec(bContext *C, wmOperator *op)
void SEQUENCER_OT_gap_remove(wmOperatorType *ot)
static std::string sequencer_strip_color_tag_set_get_name(wmOperatorType *ot, PointerRNA *properties)
static void slip_handle_num_input(bContext *C, wmOperator *op, ScrArea *area, SlipData *data, Scene *scene)
static CLG_LogRef LOG
static wmOperatorStatus sequencer_ripple_delete_exec(bContext *C, wmOperator *op)
static wmOperatorStatus sequencer_ripple_delete_invoke(bContext *C, wmOperator *op, const wmEvent *)
void SEQUENCER_OT_gap_insert(wmOperatorType *ot)
static wmOperatorStatus sequencer_separate_images_exec(bContext *C, wmOperator *op)
void SEQUENCER_OT_change_scene(wmOperatorType *ot)
static wmOperatorStatus sequencer_swap_inputs_exec(bContext *C, wmOperator *op)
static void ripple_range_clear(Scene *scene, ListBaseT< Strip > *seqbasep, const ListBaseT< SeqTimelineChannel > *channels, const seq::RippleRange &range, const bool all_channels)
void SEQUENCER_OT_refresh_all(wmOperatorType *ot)
static wmOperatorStatus sequencer_change_path_exec(bContext *C, wmOperator *op)
bool is_scene_time_sync_needed(const bContext &C)
static const EnumPropertyItem transform_reset_properties[]
static wmOperatorStatus sequencer_reload_exec(bContext *C, wmOperator *op)
static bool sequencer_strip_is_text_poll(bContext *C)
void SEQUENCER_OT_strip_transform_clear(wmOperatorType *ot)
static wmOperatorStatus sequencer_snap_exec(bContext *C, wmOperator *op)
static std::string sequencer_strip_color_tag_set_get_description(bContext *, wmOperatorType *ot, PointerRNA *properties)
const Strip * get_scene_strip_for_time_sync(const Scene *sequencer_scene)
void SEQUENCER_OT_lock(wmOperatorType *ot)
static wmOperatorStatus sequencer_delete_exec(bContext *C, wmOperator *op)
void sequencer_blade_tooltip_show(bContext *C)
const EnumPropertyItem sequencer_prop_effect_types[]
static wmOperatorStatus sequencer_set_2d_cursor_exec(bContext *C, wmOperator *op)
static wmOperatorStatus sequencer_set_2d_cursor_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void SEQUENCER_OT_mute(wmOperatorType *ot)
static SlipData * slip_data_init(bContext *C, const wmOperator *op, const wmEvent *event)
static wmOperatorStatus sequencer_change_scene_exec(bContext *C, wmOperator *op)
static const EnumPropertyItem prop_side_lr_types[]
static wmOperatorStatus sequencer_refresh_all_exec(bContext *C, wmOperator *)
bool maskedit_poll(bContext *C)
bool sequencer_editing_initialized_and_active(bContext *C)
static wmOperatorStatus sequencer_gap_remove_exec(bContext *C, wmOperator *op)
static void sequencer_report_duplicates(wmOperator *op, ListBaseT< Strip > *duplicated_strips)
static bool sequencer_fcurves_targets_color_strip(const FCurve *fcurve)
void sync_active_scene_and_time_with_scene_strip(bContext &C)
static Strip * find_next_prev_strip(Scene *scene, Strip *test, seq::Side lr, int sel)
static bool strip_get_text_strip_cb(Strip *strip, void *user_data)
static wmOperatorStatus sequencer_slip_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static wmOperatorStatus sequencer_change_path_invoke(bContext *C, wmOperator *op, const wmEvent *)
void SEQUENCER_OT_strip_color_tag_set(wmOperatorType *ot)
VectorSet< Strip * > strip_effect_get_new_inputs(const Scene *scene, StripType effect_type, bool ignore_active)
void SEQUENCER_OT_ripple_trim(wmOperatorType *ot)
void SEQUENCER_OT_slip(wmOperatorType *ot)
static wmOperatorStatus sequencer_disconnect_exec(bContext *C, wmOperator *)
void SEQUENCER_OT_unmute(wmOperatorType *ot)
static bool strip_jump_internal(Scene *scene, const seq::Side side, const bool do_skip_mute, const bool do_center)
static void sequencer_box_blade_ui(bContext *, wmOperator *op)
static wmOperatorStatus sequencer_change_effect_type_exec(bContext *C, wmOperator *op)
void SEQUENCER_OT_connect(wmOperatorType *ot)
static wmOperatorStatus sequencer_strip_transform_fit_exec(bContext *C, wmOperator *op)
static seq::Side sequence_split_side_for_exec_get(wmOperator *op)
void SEQUENCER_OT_change_effect_type(wmOperatorType *ot)
void SEQUENCER_OT_paste(wmOperatorType *ot)
bool effect_inputs_validate(int have_inputs, int num_inputs, ReportList *reports)
bool sequencer_edit_with_channel_region_poll(bContext *C)
Strip * strip_under_mouse_get(const Scene *scene, const View2D *v2d, const int mval[2])
static wmOperatorStatus sequencer_meta_separate_exec(bContext *C, wmOperator *)
rctf box_blade_rect_get(wmOperator *op, const View2D *v2d)
bool sequencer_strip_editable_and_selected_poll(bContext *C)
void SEQUENCER_OT_rendersize(wmOperatorType *ot)
void SEQUENCER_OT_scene_frame_range_update(wmOperatorType *ot)
static Scene * get_sequencer_scene_for_time_sync(const bContext &C)
void sequencer_select_do_updates(const bContext *C, Scene *scene)
void SEQUENCER_OT_reload(wmOperatorType *ot)
void SEQUENCER_OT_strip_transform_fit(wmOperatorType *ot)
bool sequencer_view_preview_only_poll(const bContext *C)
void frame_filename_set(char *dst, size_t dst_maxncpy, const char *filename_stripped, const int frame, const int numdigits, const char *ext)
bool sequencer_strip_editable_poll(bContext *C)
void SEQUENCER_OT_change_path(wmOperatorType *ot)
static wmOperatorStatus sequencer_rendersize_exec(bContext *C, wmOperator *)
static void slip_strips_delta(bContext *C, wmOperator *op, Scene *scene, SlipData *data, const float delta)
static wmOperatorStatus sequencer_strip_jump_exec(bContext *C, wmOperator *op)
static void swap_strips(Scene *scene, Strip *strip_a, Strip *strip_b)
bool maskedit_mask_poll(bContext *C)
static wmOperatorStatus sequencer_offset_clear_exec(bContext *C, wmOperator *)
static wmOperatorStatus sequencer_connect_exec(bContext *C, wmOperator *op)
static wmOperatorStatus sequencer_meta_make_exec(bContext *C, wmOperator *)
static void sequencer_change_path_draw(bContext *, wmOperator *op)
static void slip_draw_status(bContext *C, const wmOperator *op)
void SEQUENCER_OT_set_range_to_strips(wmOperatorType *ot)
void SEQUENCER_OT_reassign_inputs(wmOperatorType *ot)
void SEQUENCER_OT_unlock(wmOperatorType *ot)
bool deselect_all_strips(const Scene *scene)
static bool sequencer_strip_jump_poll(bContext *C)
static wmOperatorStatus sequencer_set_range_to_strips_exec(bContext *C, wmOperator *op)
bool sequencer_view_has_preview_poll(bContext *C)
bool check_show_imbuf(const SpaceSeq &sseq)
static Vector< Bounds< int > > ripple_gaps_get(const Scene *scene, ListBaseT< Strip > *seqbasep, const ListBaseT< SeqTimelineChannel > *channels, const seq::RippleRange &range, const bool all_channels)
static wmOperatorStatus sequencer_reassign_inputs_exec(bContext *C, wmOperator *op)
static seq::Side mouse_frame_side_get(View2D *v2d, short mouse_x, int frame)
static wmOperatorStatus sequencer_meta_toggle_exec(bContext *C, wmOperator *)
static bool should_ripple_strip(const ListBaseT< SeqTimelineChannel > *channels, const seq::RippleRange &range, const Strip *strip, const bool all_channels)
void SEQUENCER_OT_swap(wmOperatorType *ot)
void SEQUENCER_OT_duplicate(wmOperatorType *ot)
static const EnumPropertyItem prop_split_types[]
wmOperatorStatus sequencer_clipboard_paste_exec(bContext *C, wmOperator *op)
wmOperatorStatus sequencer_clipboard_paste_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static bool sequencer_change_path_draw_check_prop(PointerRNA *, PropertyRNA *prop, void *user_data)
static bool sequencer_scene_frame_range_update_poll(bContext *C)
void SEQUENCER_OT_delete(wmOperatorType *ot)
static wmOperatorStatus sequencer_strip_transform_clear_exec(bContext *C, wmOperator *op)
void SEQUENCER_OT_meta_separate(wmOperatorType *ot)
static bool sequencer_effect_poll(bContext *C)
bool sequencer_view_strips_poll(bContext *C)
static wmOperatorStatus sequencer_lock_exec(bContext *C, wmOperator *)
static bool strip_is_parent(const Strip *par, const Strip *strip)
static wmOperatorStatus sequencer_ripple_trim_invoke(bContext *C, wmOperator *op, const wmEvent *)
static int strip_cmp_time_startdisp_channel(void *, const void *a, const void *b)
const EnumPropertyItem prop_split_side_types[]
void slip_modal_keymap(wmKeyConfig *keyconf)
static wmOperatorStatus sequencer_slip_exec(bContext *C, wmOperator *op)
void SEQUENCER_OT_export_subtitles(wmOperatorType *ot)
static bool sequencer_swap_inputs_poll(bContext *C)
void SEQUENCER_OT_ripple_delete(wmOperatorType *ot)
static void ripple_gaps_close(Scene *scene, ListBaseT< Strip > *seqbasep, const ListBaseT< SeqTimelineChannel > *channels, const seq::RippleRange &range, const eSeqRippleFlag ripple_flag)
static wmOperatorStatus sequencer_change_scene_invoke(bContext *C, wmOperator *op, const wmEvent *event)
bool split_only_selected_get(wmOperator *op)
static wmOperatorStatus sequencer_unlock_exec(bContext *C, wmOperator *)
VectorSet< Strip * > all_strips_from_context(bContext *C)
static void sequencer_box_blade_cancel(bContext *C, wmOperator *op)
bool sequencer_strip_has_path_poll(bContext *C)
static wmOperatorStatus sequencer_swap_exec(bContext *C, wmOperator *op)
void SEQUENCER_OT_swap_data(wmOperatorType *ot)
void SEQUENCER_OT_disconnect(wmOperatorType *ot)
static wmOperatorStatus sequencer_snap_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void SEQUENCER_OT_split(wmOperatorType *ot)
bool check_show_maskedit(SpaceSeq *sseq, Scene *scene)
static bool sequencer_refresh_all_poll(bContext *C)
static wmOperatorStatus sequencer_swap_data_exec(bContext *C, wmOperator *op)
void SEQUENCER_OT_cursor_set(wmOperatorType *ot)
void SEQUENCER_OT_strip_jump(wmOperatorType *ot)
static wmOperatorStatus sequencer_strip_color_tag_set_exec(bContext *C, wmOperator *op)
T min(const T &a, const T &b)
T max(const T &a, const T &b)
T abs(const T &a)
void prefetch_stop(Scene *scene)
Definition prefetch.cc:336
Vector< RippleRange > transform_ripple_ranges_get(const Scene *scene, Span< Strip * > strips)
int2 image_transform_box_size_get(const Scene *scene, const Strip *strip)
int time_find_next_prev_edit(Scene *scene, int timeline_frame, const Side side, const bool do_skip_mute, const bool do_center, const bool do_unselected)
void effect_ensure_initialized(Strip *strip)
Definition effects.cc:137
bool disconnect(Strip *strip)
void relations_invalidate_cache(Scene *scene, Strip *strip)
void seqbase_duplicate_recursive(Main *bmain, const Scene *scene_src, Scene *scene_dst, ListBaseT< Strip > *seqbase_dst, const ListBaseT< Strip > *seqbase_src, const StripDuplicate dupe_flag, const int copy_flag)
Definition sequencer.cc:861
VectorSet< Strip * > query_selected_strips(ListBaseT< Strip > *seqbase)
Definition iterator.cc:164
bool relations_render_loop_check(Strip *strip_main, Strip *strip)
void thumbnail_cache_invalidate_strip(Scene *scene, const Strip *strip)
void transform_translate_strip(Scene *evil_scene, Strip *strip, int delta)
ListBaseT< Strip > * active_seqbase_get(const Editing *ed)
Definition sequencer.cc:463
void foreach_strip(ListBaseT< Strip > *seqbase, ForEachFunc callback, void *user_data)
Definition iterator.cc:60
void transform_handle_overlap(Scene *scene, ListBaseT< Strip > *seqbasep, Span< Strip * > source_strips, bool use_sync_markers, Span< Strip * > time_dependent_strips)
void strip_unique_name_set(Scene *scene, ListBaseT< Strip > *seqbasep, Strip *strip)
bool are_strips_connected_together(VectorSet< Strip * > &strip_list)
float give_frame_index(const Scene *scene, const Strip *strip, float timeline_frame)
Definition strip_time.cc:43
bool render_is_muted(const ListBaseT< SeqTimelineChannel > *channels, const Strip *strip)
Definition render.cc:2241
Editing * editing_get(const Scene *scene)
Definition sequencer.cc:304
void meta_stack_set(const Scene *scene, Strip *dst)
Definition sequencer.cc:493
void edit_strip_name_set(Scene *scene, Strip *strip, const char *new_name)
void edit_remove_flagged_strips(Scene *scene, ListBaseT< Strip > *seqbase)
void animation_duplicate_backup_to_scene(Scene *scene, Strip *strip, AnimationBackup *backup)
Definition animation.cc:187
bool effect_is_transition(StripType type)
Definition effects.cc:381
void effect_free(Strip *strip)
Definition effects.cc:147
void offset_animdata(const Scene *scene, Strip *strip, float ofs)
Definition animation.cc:42
Vector< Strip * > edit_split_strips_get(Scene *scene, const int frame, const std::optional< int > channel, const bool only_selected)
const char * strip_give_name(const Strip *strip)
void relations_invalidate_cache_raw(Scene *scene, Strip *strip)
void expand_strips(Editing *ed, VectorSet< Strip * > &strips, const StripRelation include)
Definition iterator.cc:70
void connect(Strip *strip1, Strip *strip2)
bool transform_single_image_check(const Strip *strip)
Vector< Strip * > edit_strips_split(Main *bmain, Scene *scene, ListBaseT< Strip > *seqbase, const Span< Strip * > strips_to_split, const int timeline_frame, const eSplitMethod method, const StripRelation include, const char **r_error)
VectorSet< Strip * > query_strips_recursive_at_frame(const Scene *scene, const ListBaseT< Strip > *seqbase, const int timeline_frame)
Definition iterator.cc:146
void add_reload_new_file(Main *bmain, Scene *scene, Strip *strip, const bool lock_range)
Definition strip_add.cc:644
Strip * select_active_get(const Scene *scene)
void ensure_unique_name(Strip *strip, Scene *scene, const DriverMap &driver_map)
bool select_active_get_pair(Scene *scene, Strip **r_strip_act, Strip **r_strip_other)
void time_slip_strip(const Scene *scene, Strip *strip, int frame_delta, float subframe_delta, bool slip_keyframes)
void text_effect_adjust_relative(TextVars &text, const int2 old_size, const int2 new_size)
Strip * strip_alloc(ListBaseT< Strip > *lb, int timeline_frame, int channel, StripType type)
Definition sequencer.cc:131
void relations_refresh_all(Scene *scene)
const char * get_default_stripname_by_type(int type)
void edit_flag_for_removal(Scene *scene, Strip *strip)
void animation_backup_original(Scene *scene, AnimationBackup *backup)
Definition animation.cc:91
Strip * edit_strip_split(Main *bmain, Scene *scene, ListBaseT< Strip > *seqbase, Strip *strip, const int timeline_frame, const eSplitMethod method, const bool ignore_connections, const char **r_error)
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
bool edit_remove_gaps(Scene *scene, ListBaseT< Strip > *seqbase, const int initial_frame, const bool remove_all_gaps)
bool edit_strip_swap(Scene *scene, Strip *strip_a, Strip *strip_b, const char **r_error_str)
Definition strip_edit.cc:45
Strip * strip_duplicate_recursive(Main *bmain, const Scene *scene_src, Scene *scene_dst, ListBaseT< Strip > *seqbase_dst, Strip *strip, const StripDuplicate dupe_flag)
Definition sequencer.cc:822
VectorSet< Strip * > connected_strips_get(const Strip *strip)
void animation_restore_original(Scene *scene, AnimationBackup *backup)
Definition animation.cc:110
void transform_strips_after_frame(Scene *scene, ListBaseT< Strip > *seqbase, const int timeline_frame, const int delta)
float2 image_preview_unit_from_px(const Scene *scene, const float2 co_src)
bool transform_strip_is_on_rippled_channel(const RippleRange &range, const Strip *strip, const bool all_channels)
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
bool transform_is_locked(const ListBaseT< SeqTimelineChannel > *channels, const Strip *strip)
Strip * meta_stack_pop(Editing *ed)
Definition sequencer.cc:514
ListBaseT< SeqTimelineChannel > * channels_displayed_get(const Editing *ed)
Definition channels.cc:26
bool transform_strip_can_be_translated(const Strip *strip)
void strip_lookup_invalidate(const Editing *ed)
Mask * active_mask_get(Scene *scene)
void set_scale_to_fit(const Strip *strip, const int image_width, const int image_height, const int preview_width, const int preview_height, const eSeqImageFitMethod fit_method)
StripElem * render_give_stripelem(const Scene *scene, const Strip *strip, int timeline_frame)
Definition render.cc:220
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
float view2d_region_to_view_x(const View2D *v2d, float x)
Definition view2d.cc:1640
float view2d_scale_get_x(const View2D *v2d)
Definition view2d.cc:1902
void view2d_region_to_view_rctf(const View2D *v2d, const rctf *rect_src, rctf *rect_dst) ATTR_NONNULL()
Definition view2d.cc:1657
View2D * view2d_fromcontext(const bContext *C)
Definition view2d.cc:1836
const char * BKE_idtype_idcode_to_name(short idcode)
Definition idtype.cc:261
UserDef U
Definition blender.cc:58
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void RNA_float_set_array(PointerRNA *ptr, const char *name, const float *values)
void RNA_def_enum_funcs(PropertyRNA *prop, EnumPropertyItemFunc itemfunc)
void WM_window_set_active_scene(Main *bmain, bContext *C, wmWindow *win, Scene *scene)
ScrArea * CTX_wm_area(const bContext *C)
char * STRNCPY(char(&dst)[N], const char *src)
int RNA_enum_get(PointerRNA *ptr, const char *name)
Object * BKE_view_layer_active_object_get(const ViewLayer *view_layer)
@ RPT_WARNING
Definition BKE_report.hh:40
Scene * CTX_data_sequencer_scene(const bContext *C)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
void RNA_property_update(bContext *C, PointerRNA *ptr, PropertyRNA *prop)
wmKeyMap * WM_modalkeymap_find(wmKeyConfig *keyconf, const char *idname)
Definition wm_keymap.cc:999
wmOperatorStatus WM_gesture_box_invoke(bContext *C, wmOperator *op, const wmEvent *event)
bool handleNumInput(bContext *C, NumInput *n, const wmEvent *event)
Definition numinput.cc:344
WorkSpace * CTX_wm_workspace(const bContext *C)
bool WM_operator_poll_or_report_error(bContext *C, wmOperatorType *ot, ReportList *reports)
MINLINE int round_fl_to_int(float a)
PointerRNA RNA_id_pointer_create(ID *id)
const char * RNA_property_identifier(const PropertyRNA *prop)
MINLINE void copy_v2_v2(float r[2], const float a[2])
void RNA_string_set(PointerRNA *ptr, const char *name, const char *value)
bool BLI_exists(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition storage.cc:404
FILE * BLI_fopen(const char *filepath, const char *mode) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
void RNA_int_set(PointerRNA *ptr, const char *name, int value)
char * BLI_strncpy_utf8(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
bool RNA_struct_property_is_set_ex(PointerRNA *ptr, const char *identifier, bool use_ghost)
void void void BLI_movelisttolist(ListBase *dst, ListBase *src) ATTR_NONNULL(1
Definition listbase.cc:32
int RNA_int_get(PointerRNA *ptr, const char *name)
bool hasNumInput(const NumInput *n)
Definition numinput.cc:188
wmWindow * CTX_wm_window(const bContext *C)
void RNA_enum_set(PointerRNA *ptr, const char *name, int value)
MINLINE int max_ii(int a, int b)
@ SEQ_VIEW_SEQUENCE_PREVIEW
void WM_tooltip_clear(bContext *C, wmWindow *win)
Definition wm_tooltip.cc:84
bool BLI_path_frame_get(const char *path, int *r_frame, int *r_digits_len) ATTR_NONNULL(1
ViewLayer * WM_window_get_active_view_layer(const wmWindow *win)
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)
AUD_SequenceEntry BKE_sound_add_scene_sound(Scene *scene, Strip *strip)
SpaceSeq * CTX_wm_space_seq(const bContext *C)
void RNA_def_property_ui_range(PropertyRNA *prop, double min, double max, double step, int precision)
PropertyRNA * RNA_def_float_vector(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)
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
void WM_operator_properties_border_to_rctf(wmOperator *op, rctf *r_rect)
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
void CTX_wm_operator_poll_msg_set(bContext *C, const char *msg)
VecBase< int32_t, 2 > int2
Scene * WM_window_get_active_scene(const wmWindow *win)
VecBase< float, 2 > float2
void RNA_property_string_set(PointerRNA *ptr, PropertyRNA *prop, const char *value)
void void void BLI_listbase_sort_r(ListBase *listbase, int(*cmp)(void *, const void *, const void *), void *thunk) ATTR_NONNULL(1
Definition listbase.cc:328
ListBaseT< ImageFrameRange > ED_image_filesel_detect_sequences(StringRefNull blendfile_path, StringRefNull root_path, wmOperator *op, bool detect_udim)
void BLI_remlink(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:138
void DEG_id_tag_update(ID *id, unsigned int flags)
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:162
BMesh const char void * data
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_FILES
Definition WM_api.hh:1333
@ WM_FILESEL_FILEPATH
Definition WM_api.hh:1332
wmWindowManager * CTX_wm_manager(const bContext *C)
void initNumInput(NumInput *n)
Definition numinput.cc:85
bool ED_scene_delete(bContext *C, Main *bmain, Scene *scene) ATTR_NONNULL()
void ED_fileselect_ensure_default_filepath(bContext *C, wmOperator *op, const char *extension)
Definition filesel.cc:1515
DriverMap BKE_animdata_build_driver_target_map(Main &bmain)
Definition anim_data.cc:980
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)
PointerRNA RNA_pointer_create_discrete(ID *id, StructRNA *type, void *data)
const char * BKE_idtype_idcode_to_name_plural(short idcode)
Definition idtype.cc:268
void WM_operator_properties_gesture_box(wmOperatorType *ot)
bool BLI_file_is_writable(const char *filepath) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition fileops_c.cc:293
void ED_area_status_text(ScrArea *area, const char *str)
Definition area.cc:975
const EnumPropertyItem rna_enum_strip_scale_method_items[]
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
bool BLI_file_touch(const char *filepath) ATTR_NONNULL(1)
Definition fileops_c.cc:318
const EnumPropertyItem rna_enum_dummy_NULL_items[]
Definition rna_rna.cc:28
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void RNA_float_set(PointerRNA *ptr, const char *name, float value)
void RNA_boolean_set(PointerRNA *ptr, const char *name, bool value)
@ SEQ_RIPPLE_CLEAR_RANGES
@ SEQ_RIPPLE_ALL_CHANNELS
bool applyNumInput(NumInput *n, float *vec)
Definition numinput.cc:207
void RNA_def_property_translation_context(PropertyRNA *prop, const char *context)
wmOperatorStatus WM_operator_props_popup_confirm_ex(bContext *C, wmOperator *op, const wmEvent *, std::optional< std::string > title, std::optional< std::string > confirm_text, const bool cancel_default, std::optional< std::string > message)
@ USER_SEQ_ED_CLAMP_STRIPS_BY_DEFAULT
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)
wmOperatorStatus WM_gesture_box_modal(bContext *C, wmOperator *op, const wmEvent *event)
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
size_t BLI_timecode_string_from_time(char *str, size_t maxncpy, int brevity_level, float time_seconds, double fps, short timecode_style) ATTR_NONNULL()
Definition timecode.cc:24
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
Definition report.cc:191
@ FILE_SAVE
Definition WM_api.hh:1342
@ FILE_OPENFILE
Definition WM_api.hh:1341
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:118
Main * CTX_data_main(const bContext *C)
void outputNumInput(NumInput *n, char *str, const UnitSettings &unit_settings)
Definition numinput.cc:104
bool BLI_rctf_isect(const struct rctf *src1, const struct rctf *src2, struct rctf *dest)
const EnumPropertyItem rna_enum_strip_color_items[]
@ ID_RECALC_AUDIO
Definition DNA_ID.h:1132
@ ID_RECALC_ANIMATION_NO_FLUSH
Definition DNA_ID.h:1178
@ ID_RECALC_FRAME_CHANGE
Definition DNA_ID.h:1125
@ ID_RECALC_SEQUENCER_STRIPS
Definition DNA_ID.h:1122
@ PROP_SKIP_SAVE
Definition RNA_types.hh:414
@ PROP_ENUM_NO_TRANSLATE
Definition RNA_types.hh:502
@ PROP_HIDDEN
Definition RNA_types.hh:408
void BKE_sound_load(Main *bmain, bSound *sound)
void WM_gesture_box_cancel(bContext *C, wmOperator *op)
@ G_TRANSFORM_SEQ
void WM_modalkeymap_assign(wmKeyMap *km, const char *opname)
wmOperatorStatus WM_enum_search_invoke(bContext *C, wmOperator *op, const wmEvent *)
void WM_operator_properties_select_operation_simple(wmOperatorType *ot)
void DEG_relations_tag_update(Main *bmain)
void RNA_property_boolean_set(PointerRNA *ptr, PropertyRNA *prop, bool value)
bool void BLI_path_frame_strip(char *path, char *r_ext, size_t ext_maxncpy) ATTR_NONNULL(1
void RNA_pointer_set(PointerRNA *ptr, const char *name, PointerRNA ptr_value)
wmKeyMap * WM_modalkeymap_ensure(wmKeyConfig *keyconf, const char *idname, const EnumPropertyItem *items)
Definition wm_keymap.cc:972
@ OPTYPE_REGISTER
Definition WM_types.hh:188
@ OPTYPE_UNDO
Definition WM_types.hh:190
@ OPTYPE_BLOCKING
Definition WM_types.hh:192
@ OPTYPE_DEPENDS_ON_CURSOR
Definition WM_types.hh:228
@ OPTYPE_GRAB_CURSOR_X
Definition WM_types.hh:198
@ AUTOKEY_FLAG_INSERTAVAILABLE
size_t BLI_string_split_name_number(const char *name, char delim, char *r_name_left, int *r_number) ATTR_NONNULL(1
std::string RNA_string_get(PointerRNA *ptr, const char *name)
bool ED_operator_sequencer_active(bContext *C)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
SpaceProperties * CTX_wm_space_properties(const bContext *C)
bScreen * WM_window_get_active_screen(const wmWindow *win)
MINLINE int min_ii(int a, int b)
PropertyRNA * RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, const float default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
Object * CTX_data_active_object(const bContext *C)
ARegion * CTX_wm_region(const bContext *C)
void ED_workspace_status_text(bContext *C, const char *str)
Definition area.cc:1153
bool BLI_file_ensure_parent_dir_exists(const char *filepath) ATTR_NONNULL(1)
Definition fileops_c.cc:454
float RNA_float_get(PointerRNA *ptr, const char *name)
bScreen * ED_screen_animation_playing(const wmWindowManager *wm)
void WM_event_add_fileselect(bContext *C, wmOperator *op)
void RNA_float_get_array(PointerRNA *ptr, const char *name, float *values)
#define floorf
#define ceilf
eRegion_Type regiontype
ListBaseT< Scene > scenes
Definition BKE_main.hh:386
struct Editing * ed
struct AnimData * adt
ListBaseT< TimeMarker > markers
struct UnitSettings unit
struct RenderData r
struct ToolSettings * toolsettings
ListBaseT< SpaceLink > spacedata
eSpaceSeq_RegionType mainb
eSpaceSeq_Displays view
struct Scene * sequencer_scene
struct wmTimer * animtimer
ListBaseT< struct ScrArea > areabase
char filepath[1024]
VectorSet< Strip * > strips
void use_property_decorate_set(bool is_decorate)
void use_property_split_set(bool is_sep)
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)
void active_set(bool active)
void separator(float factor=1.0f, LayoutSeparatorType type=LayoutSeparatorType::Auto)
Layout & row(bool align)
wmEventType type
Definition WM_types.hh:817
wmOperatorStatus(*) exec(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1125
const char * description
Definition WM_types.hh:1115
void(*) cancel(bContext *C, wmOperator *op)
Definition WM_types.hh:1149
const char * translation_context
Definition WM_types.hh:1113
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
wmOperatorStatus(*) modal(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1157
std::string(*) get_description(bContext *C, wmOperatorType *ot, PointerRNA *ptr)
Definition WM_types.hh:1197
std::string(*) get_name(wmOperatorType *ot, PointerRNA *ptr)
Definition WM_types.hh:1191
struct ReportList * reports
struct wmOperatorType * type