Blender V5.3
rna_sequencer_api.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <cstdlib>
10#include <cstring>
11
12#include "DNA_scene_types.h"
13#include "DNA_sequence_types.h"
14
15#include "RNA_define.hh"
16
17#include "RNA_enum_types.hh"
18#include "SEQ_edit.hh"
19#include "SEQ_sequencer.hh"
20
21#include "rna_internal.hh"
22
23#ifdef RNA_RUNTIME
24
25# include "DNA_mask_types.h"
26
27# include "BLI_listbase.hh"
28# include "BLI_path_utils.hh"
29# include "BLI_string.hh"
30# include "BLI_string_utf8.hh"
31
32# include "BKE_report.hh"
33
34# include "SEQ_add.hh"
35# include "SEQ_effects.hh"
36# include "SEQ_relations.hh"
37# include "SEQ_render.hh"
38# include "SEQ_retiming.hh"
39# include "SEQ_utils.hh"
40
41# include "DEG_depsgraph.hh"
42# include "DEG_depsgraph_build.hh"
43
44# include "WM_api.hh"
45
46namespace blender {
47
48static StripElem *rna_Strip_elem_from_frame(ID *id, Strip *self, int timeline_frame)
49{
50 Scene *scene = id_cast<Scene *>(id);
51 return seq::render_give_stripelem(scene, self, timeline_frame);
52}
53
54static void rna_Strip_swap_internal(ID *id,
55 Strip *strip_self,
56 ReportList *reports,
57 Strip *strip_other)
58{
59 const char *error_msg;
60 Scene *scene = id_cast<Scene *>(id);
61
62 if (seq::edit_strip_swap(scene, strip_self, strip_other, &error_msg) == false) {
63 BKE_report(reports, RPT_ERROR, error_msg);
64 }
65}
66
67static void rna_Strips_move_strip_to_meta(
68 ID *id, Strip *strip_self, Main *bmain, ReportList *reports, Strip *meta_dst)
69{
70 Scene *scene = id_cast<Scene *>(id);
71 const char *error_msg;
72
73 /* Move strip to meta. */
74 if (!seq::edit_move_strip_to_meta(scene, strip_self, meta_dst, &error_msg)) {
75 BKE_report(reports, RPT_ERROR, error_msg);
76 }
77
78 /* Update depsgraph. */
81
83
85}
86
87static Strip *rna_Strip_split(ID *id,
88 Strip *strip,
89 Main *bmain,
90 ReportList *reports,
91 int frame,
92 int split_method,
93 bool ignore_connections)
94{
95 Scene *scene = id_cast<Scene *>(id);
96 ListBaseT<Strip> *seqbase = seq::get_seqbase_by_strip(scene, strip);
97
98 const char *error_msg = nullptr;
99 Strip *strip_split = seq::edit_strip_split(bmain,
100 scene,
101 seqbase,
102 strip,
103 frame,
104 seq::eSplitMethod(split_method),
105 ignore_connections,
106 &error_msg);
107 if (error_msg != nullptr) {
108 BKE_report(reports, RPT_ERROR, error_msg);
109 }
110
111 /* Update depsgraph. */
114
116
117 return strip_split;
118}
119
120static Strip *rna_Strip_parent_meta(ID *id, Strip *strip_self)
121{
122 Scene *scene = id_cast<Scene *>(id);
123 return seq::lookup_meta_by_strip(seq::editing_get(scene), strip_self);
124}
125
126static Strip *rna_Strips_new_clip(ID *id,
127 ListBaseT<Strip> *seqbase,
128 Main *bmain,
129 const char *name,
130 MovieClip *clip,
131 int channel,
132 int frame_start)
133{
134 Scene *scene = id_cast<Scene *>(id);
136 seq::add_load_data_init(&load_data, name, nullptr, frame_start, channel);
137 load_data.clip = clip;
138 Strip *strip = seq::add_movieclip_strip(scene, seqbase, &load_data);
139
143
144 return strip;
145}
146
147static Strip *rna_Strips_editing_new_clip(ID *id,
148 Editing *ed,
149 Main *bmain,
150 const char *name,
151 MovieClip *clip,
152 int channel,
153 int frame_start)
154{
155 return rna_Strips_new_clip(id, &ed->seqbase, bmain, name, clip, channel, frame_start);
156}
157
158static Strip *rna_Strips_meta_new_clip(ID *id,
159 Strip *strip,
160 Main *bmain,
161 const char *name,
162 MovieClip *clip,
163 int channel,
164 int frame_start)
165{
166 return rna_Strips_new_clip(id, &strip->seqbase, bmain, name, clip, channel, frame_start);
167}
168
169static Strip *rna_Strips_new_mask(ID *id,
170 ListBaseT<Strip> *seqbase,
171 Main *bmain,
172 const char *name,
173 Mask *mask,
174 int channel,
175 int frame_start)
176{
177 Scene *scene = id_cast<Scene *>(id);
179 seq::add_load_data_init(&load_data, name, nullptr, frame_start, channel);
180 load_data.mask = mask;
181 Strip *strip = seq::add_mask_strip(scene, seqbase, &load_data);
182
186
187 return strip;
188}
189static Strip *rna_Strips_editing_new_mask(
190 ID *id, Editing *ed, Main *bmain, const char *name, Mask *mask, int channel, int frame_start)
191{
192 return rna_Strips_new_mask(id, &ed->seqbase, bmain, name, mask, channel, frame_start);
193}
194
195static Strip *rna_Strips_meta_new_mask(
196 ID *id, Strip *strip, Main *bmain, const char *name, Mask *mask, int channel, int frame_start)
197{
198 return rna_Strips_new_mask(id, &strip->seqbase, bmain, name, mask, channel, frame_start);
199}
200
201static Strip *rna_Strips_new_scene(ID *id,
202 ListBaseT<Strip> *seqbase,
203 Main *bmain,
204 const char *name,
205 Scene *sce_strip,
206 int channel,
207 int frame_start)
208{
209 Scene *scene = id_cast<Scene *>(id);
211 seq::add_load_data_init(&load_data, name, nullptr, frame_start, channel);
212 load_data.scene = sce_strip;
213 Strip *strip = seq::add_scene_strip(scene, seqbase, &load_data);
214
218
219 return strip;
220}
221
222static Strip *rna_Strips_editing_new_scene(ID *id,
223 Editing *ed,
224 Main *bmain,
225 const char *name,
226 Scene *sce_strip,
227 int channel,
228 int frame_start)
229{
230 return rna_Strips_new_scene(id, &ed->seqbase, bmain, name, sce_strip, channel, frame_start);
231}
232
233static Strip *rna_Strips_meta_new_scene(ID *id,
234 Strip *strip,
235 Main *bmain,
236 const char *name,
237 Scene *sce_strip,
238 int channel,
239 int frame_start)
240{
241 return rna_Strips_new_scene(id, &strip->seqbase, bmain, name, sce_strip, channel, frame_start);
242}
243
244static Strip *rna_Strips_new_image(ID *id,
245 ListBaseT<Strip> *seqbase,
246 Main *bmain,
247 ReportList *reports,
248 const char *name,
249 const char *file,
250 int channel,
251 int frame_start,
252 int fit_method)
253{
254 Scene *scene = id_cast<Scene *>(id);
255
257 seq::add_load_data_init(&load_data, name, file, frame_start, channel);
258 load_data.image.count = 1;
259 load_data.fit_method = eSeqImageFitMethod(fit_method);
260
261 char vt_old[64];
262 STRNCPY_UTF8(vt_old, scene->view_settings.view_transform);
263
264 Strip *strip = seq::add_image_strip(bmain, scene, seqbase, &load_data);
265
266 if (!STREQ(vt_old, scene->view_settings.view_transform)) {
267 BKE_reportf(reports,
269 "View transform set to %s (converted from %s)",
270 scene->view_settings.view_transform,
271 vt_old);
272 }
273
274 char dirpath[FILE_MAX], filename[FILE_MAXFILE];
275 BLI_path_split_dir_file(file, dirpath, sizeof(dirpath), filename, sizeof(filename));
276 seq::add_image_set_directory(strip, dirpath);
277 seq::add_image_load_file(scene, strip, 0, filename);
278 seq::add_image_init_alpha_mode(bmain, scene, strip);
279
283
284 return strip;
285}
286
287static Strip *rna_Strips_editing_new_image(ID *id,
288 Editing *ed,
289 Main *bmain,
290 ReportList *reports,
291 const char *name,
292 const char *file,
293 int channel,
294 int frame_start,
295 int fit_method)
296{
297 return rna_Strips_new_image(
298 id, &ed->seqbase, bmain, reports, name, file, channel, frame_start, fit_method);
299}
300
301static Strip *rna_Strips_meta_new_image(ID *id,
302 Strip *strip,
303 Main *bmain,
304 ReportList *reports,
305 const char *name,
306 const char *file,
307 int channel,
308 int frame_start,
309 int fit_method)
310{
311 return rna_Strips_new_image(
312 id, &strip->seqbase, bmain, reports, name, file, channel, frame_start, fit_method);
313}
314
315static Strip *rna_Strips_new_movie(ID *id,
316 ListBaseT<Strip> *seqbase,
317 Main *bmain,
318 ReportList *reports,
319 const char *name,
320 const char *file,
321 int channel,
322 int frame_start,
323 int fit_method,
324 int stream)
325{
326 Scene *scene = id_cast<Scene *>(id);
328 seq::add_load_data_init(&load_data, name, file, frame_start, channel);
329 load_data.fit_method = eSeqImageFitMethod(fit_method);
330 load_data.stream_index = stream;
331 load_data.allow_invalid_file = true;
332
333 char vt_old[64];
334 STRNCPY_UTF8(vt_old, scene->view_settings.view_transform);
335 float fps_old = scene->r.frs_sec / scene->r.frs_sec_base;
336
337 Strip *strip = seq::add_movie_strip(bmain, scene, seqbase, &load_data);
338
339 if (!STREQ(vt_old, scene->view_settings.view_transform)) {
340 BKE_reportf(reports,
342 "View transform set to %s (converted from %s)",
343 scene->view_settings.view_transform,
344 vt_old);
345 }
346
347 if (fps_old != scene->r.frs_sec / scene->r.frs_sec_base) {
348 BKE_reportf(reports,
350 "Scene frame rate set to %.4g (converted from %.4g)",
351 scene->r.frs_sec / scene->r.frs_sec_base,
352 fps_old);
353 }
354
358
359 return strip;
360}
361
362static Strip *rna_Strips_editing_new_movie(ID *id,
363 Editing *ed,
364 Main *bmain,
365 ReportList *reports,
366 const char *name,
367 const char *file,
368 int channel,
369 int frame_start,
370 int fit_method,
371 int stream)
372{
373 return rna_Strips_new_movie(
374 id, &ed->seqbase, bmain, reports, name, file, channel, frame_start, fit_method, stream);
375}
376
377static Strip *rna_Strips_meta_new_movie(ID *id,
378 Strip *strip,
379 Main *bmain,
380 ReportList *reports,
381 const char *name,
382 const char *file,
383 int channel,
384 int frame_start,
385 int fit_method,
386 int stream)
387{
388 return rna_Strips_new_movie(
389 id, &strip->seqbase, bmain, reports, name, file, channel, frame_start, fit_method, stream);
390}
391
392# ifdef WITH_AUDASPACE
393static Strip *rna_Strips_new_sound(ID *id,
394 ListBaseT<Strip> *seqbase,
395 Main *bmain,
396 ReportList *reports,
397 const char *name,
398 const char *file,
399 int channel,
400 int frame_start,
401 int stream)
402{
403 Scene *scene = (Scene *)id;
405 seq::add_load_data_init(&load_data, name, file, frame_start, channel);
406 load_data.allow_invalid_file = true;
407 load_data.stream_index = stream;
408 Strip *strip = seq::add_sound_strip(bmain, scene, seqbase, &load_data);
409
410 if (strip == nullptr) {
411 BKE_report(reports, RPT_ERROR, "Unable to open sound file");
412 return nullptr;
413 }
414
418
419 return strip;
420}
421# else /* WITH_AUDASPACE */
422static Strip *rna_Strips_new_sound(ID * /*id*/,
423 ListBaseT<Strip> * /*seqbase*/,
424 Main * /*bmain*/,
425 ReportList *reports,
426 const char * /*name*/,
427 const char * /*file*/,
428 int /*channel*/,
429 int /*frame_start*/,
430 int /*stream*/)
431{
432 BKE_report(reports, RPT_ERROR, "Blender compiled without Audaspace support");
433 return nullptr;
434}
435# endif /* WITH_AUDASPACE */
436
437static Strip *rna_Strips_editing_new_sound(ID *id,
438 Editing *ed,
439 Main *bmain,
440 ReportList *reports,
441 const char *name,
442 const char *file,
443 int channel,
444 int frame_start,
445 int stream)
446{
447 return rna_Strips_new_sound(
448 id, &ed->seqbase, bmain, reports, name, file, channel, frame_start, stream);
449}
450
451static Strip *rna_Strips_meta_new_sound(ID *id,
452 Strip *strip,
453 Main *bmain,
454 ReportList *reports,
455 const char *name,
456 const char *file,
457 int channel,
458 int frame_start,
459 int stream)
460{
461 return rna_Strips_new_sound(
462 id, &strip->seqbase, bmain, reports, name, file, channel, frame_start, stream);
463}
464
465/* Meta strip
466 * Possibility to create an empty meta to avoid plenty of meta toggling
467 * Created meta have a length equal to 1, must be set through the API. */
468static Strip *rna_Strips_new_meta(
469 ID *id, ListBaseT<Strip> *seqbase, const char *name, int channel, int frame_start)
470{
471 Scene *scene = id_cast<Scene *>(id);
473 seq::add_load_data_init(&load_data, name, nullptr, frame_start, channel);
474 Strip *seqm = seq::add_meta_strip(scene, seqbase, &load_data);
475
476 return seqm;
477}
478
479static Strip *rna_Strips_editing_new_meta(
480 ID *id, Editing *ed, const char *name, int channel, int frame_start)
481{
482 return rna_Strips_new_meta(id, &ed->seqbase, name, channel, frame_start);
483}
484
485static Strip *rna_Strips_meta_new_meta(
486 ID *id, Strip *strip, const char *name, int channel, int frame_start)
487{
488 return rna_Strips_new_meta(id, &strip->seqbase, name, channel, frame_start);
489}
490
491static Strip *rna_Strips_new_effect(ID *id,
492 ListBaseT<Strip> *seqbase,
493 ReportList *reports,
494 const char *name,
495 int type,
496 int channel,
497 int frame_start,
498 int length,
499 Strip *input1,
500 Strip *input2)
501{
502 const int min_inputs = blender::seq::effect_type_get_min_num_inputs(StripType(type));
503 const bool compositor_with_inputs = type == STRIP_TYPE_COMPOSITOR && input1 != nullptr;
504 switch (min_inputs) {
505 case 0:
506 if (length <= 0 && !compositor_with_inputs) {
507 BKE_report(reports, RPT_ERROR, "Invalid length");
508 return nullptr;
509 }
510 break;
511 case 1:
512 if (input1 == nullptr) {
513 BKE_report(reports, RPT_ERROR, "Effect takes 1 input strip");
514 return nullptr;
515 }
516 break;
517 case 2:
518 if (input1 == nullptr || input2 == nullptr) {
519 BKE_report(reports, RPT_ERROR, "Effect takes 2 input strips");
520 return nullptr;
521 }
522 break;
523 default:
524 BKE_reportf(reports,
525 RPT_ERROR,
526 "Effect expects more than 2 inputs (%d, should never happen!)",
527 min_inputs);
528 return nullptr;
529 }
531 seq::add_load_data_init(&load_data, name, nullptr, frame_start, channel);
532 load_data.effect.length = length;
533 load_data.effect.type = StripType(type);
534 load_data.effect.input1 = input1;
535 load_data.effect.input2 = input2;
536 Scene *scene = id_cast<Scene *>(id);
537 Strip *strip = seq::add_effect_strip(scene, seqbase, &load_data);
538
539 if (load_data.effect.type == STRIP_TYPE_COLOR) {
540 SolidColorVars *colvars = static_cast<SolidColorVars *>(strip->effectdata);
541 colvars->width = scene->r.xsch;
542 colvars->height = scene->r.ysch;
543 }
544
547
548 return strip;
549}
550
551static Strip *rna_Strips_editing_new_effect(ID *id,
552 Editing *ed,
553 ReportList *reports,
554 const char *name,
555 int type,
556 int channel,
557 int frame_start,
558 int length,
559 Strip *input1,
560 Strip *input2)
561{
562 return rna_Strips_new_effect(
563 id, &ed->seqbase, reports, name, type, channel, frame_start, length, input1, input2);
564}
565
566static Strip *rna_Strips_meta_new_effect(ID *id,
567 Strip *strip,
568 ReportList *reports,
569 const char *name,
570 int type,
571 int channel,
572 int frame_start,
573 int length,
574 Strip *input1,
575 Strip *input2)
576{
577 return rna_Strips_new_effect(
578 id, &strip->seqbase, reports, name, type, channel, frame_start, length, input1, input2);
579}
580
581static void rna_Strips_remove(
582 ID *id, ListBaseT<Strip> *seqbase, Main *bmain, ReportList *reports, PointerRNA *strip_ptr)
583{
584 Strip *strip = static_cast<Strip *>(strip_ptr->data);
585 Scene *scene = id_cast<Scene *>(id);
586
587 if (BLI_findindex(seqbase, strip) == -1) {
589 reports, RPT_ERROR, "Strip '%s' not in scene '%s'", strip->name + 2, scene->id.name + 2);
590 return;
591 }
592
593 seq::edit_flag_for_removal(scene, strip);
594 seq::edit_remove_flagged_strips(scene, seqbase);
595 strip_ptr->invalidate();
596
600}
601
602static void rna_Strips_editing_remove(
603 ID *id, Editing *ed, Main *bmain, ReportList *reports, PointerRNA *strip_ptr)
604{
605 rna_Strips_remove(id, &ed->seqbase, bmain, reports, strip_ptr);
606}
607
608static void rna_Strips_meta_remove(
609 ID *id, Strip *strip, Main *bmain, ReportList *reports, PointerRNA *strip_ptr)
610{
611 rna_Strips_remove(id, &strip->seqbase, bmain, reports, strip_ptr);
612}
613
614static StripElem *rna_StripElements_append(ID *id, Strip *strip, const char *filename)
615{
616 Scene *scene = id_cast<Scene *>(id);
617 StripElem *se;
618
619 const int old_len = strip->data->stripdata_num;
620 strip->data->stripdata = se = static_cast<StripElem *>(
621 MEM_realloc_uninitialized(strip->data->stripdata, sizeof(StripElem) * (old_len + 1)));
622 se += old_len;
623 STRNCPY(se->filename, filename);
624 strip->data->stripdata_num = old_len + 1;
625 strip->content_length_set(strip->content_length() + 1);
626
627 strip->flag &= ~SEQ_SINGLE_FRAME_CONTENT;
628
630
631 return se;
632}
633
634static void rna_StripElements_pop(ID *id, Strip *strip, ReportList *reports, int index)
635{
636 Scene *scene = id_cast<Scene *>(id);
637 StripElem *new_se, *se;
638
639 /* `index` addresses the same full `stripdata` array as #StripElements (see
640 * #rna_Strip_elements_begin), which may include elements hidden by content trim
641 * (#Strip::anim_startofs / #Strip::anim_endofs), not just the visible ones. */
642 const int old_len = strip->data->stripdata_num;
643 if (old_len == 1) {
644 BKE_report(reports, RPT_ERROR, "Cannot pop the last element");
645 return;
646 }
647
648 /* python style negative indexing */
649 if (index < 0) {
650 index += old_len;
651 }
652
653 if (old_len <= index || index < 0) {
654 BKE_report(reports, RPT_ERROR, "Index out of range");
655 return;
656 }
657
658 const bool is_visible = index >= strip->anim_startofs &&
659 index < strip->anim_startofs + strip->content_length();
660 if (is_visible && strip->content_length() == 1) {
661 BKE_report(reports, RPT_ERROR, "StripElements.pop: cannot pop the last element");
662 return;
663 }
664
665 /* Remove the popped slot from whichever count currently accounts for it, so the physical
666 * array (`data->stripdata_num`) shrinks by exactly one element. */
667 if (index < strip->anim_startofs) {
668 strip->anim_startofs--;
669 }
670 else if (!is_visible) {
671 strip->anim_endofs--;
672 }
673 else {
674 strip->content_length_set(strip->content_length() - 1);
675 if (strip->content_length() == 1) {
676 strip->flag |= SEQ_SINGLE_FRAME_CONTENT;
677 }
678 }
679
680 new_se = MEM_new_array<StripElem>(old_len - 1, "StripElements_pop");
681
682 se = strip->data->stripdata;
683 if (index > 0) {
684 memcpy(new_se, se, sizeof(StripElem) * index);
685 }
686
687 if (index < old_len - 1) {
688 memcpy(&new_se[index], &se[index + 1], sizeof(StripElem) * (old_len - 1 - index));
689 }
690
691 MEM_delete(strip->data->stripdata);
692 strip->data->stripdata = new_se;
693 strip->data->stripdata_num = old_len - 1;
694
696}
697
698static void rna_Strip_invalidate_cache_rnafunc(ID *id, Strip *self, int type)
699{
700 switch (type) {
702 seq::relations_invalidate_cache_raw(id_cast<Scene *>(id), self);
703 break;
705 seq::relations_invalidate_cache(id_cast<Scene *>(id), self);
706 break;
707 }
708}
709
710static SeqRetimingKey *rna_Strip_retiming_keys_add(ID *id,
711 Strip *strip,
712 ReportList *reports,
713 int timeline_frame)
714{
715 Scene *scene = id_cast<Scene *>(id);
716
718 scene, reports, strip, timeline_frame);
719
722 return key;
723}
724
725static void rna_Strip_retiming_keys_reset(ID *id, Strip *strip)
726{
727 Scene *scene = id_cast<Scene *>(id);
728
730
733}
734
735} // namespace blender
736
737#else
738
739namespace blender {
740
742{
743 FunctionRNA *func;
744 PropertyRNA *parm;
745
746 static const EnumPropertyItem strip_cache_type_items[] = {
747 {SEQ_CACHE_STORE_RAW, "RAW", 0, "Raw", ""},
748 {SEQ_CACHE_STORE_FINAL_OUT, "COMPOSITE", 0, "Composite", ""},
749 {0, nullptr, 0, nullptr, nullptr},
750 };
751
752 static const EnumPropertyItem strip_split_method_items[] = {
753 {seq::SPLIT_SOFT, "SOFT", 0, "Soft", ""},
754 {seq::SPLIT_HARD, "HARD", 0, "Hard", ""},
755 {0, nullptr, 0, nullptr, nullptr},
756 };
757
758 func = RNA_def_function(srna, "strip_elem_from_frame", "rna_Strip_elem_from_frame");
760 RNA_def_function_ui_description(func, "Return the strip element from a given frame or None");
761 parm = RNA_def_int(func,
762 "frame",
763 0,
764 -MAXFRAME,
765 MAXFRAME,
766 "Frame",
767 "The frame to get the strip element from",
768 -MAXFRAME,
769 MAXFRAME);
772 func,
773 RNA_def_pointer(func, "elem", "StripElement", "", "strip element of the current frame"));
774
775 func = RNA_def_function(srna, "swap", "rna_Strip_swap_internal");
778 RNA_def_function_ui_description(func, "Swap the position of this strip with another");
779 parm = RNA_def_pointer(func, "other", "Strip", "Other", "Other strip to swap with");
781
782 func = RNA_def_function(srna, "move_to_meta", "rna_Strips_move_strip_to_meta");
784 RNA_def_function_ui_description(func, "Move this strip into a meta Strip");
785 parm = RNA_def_pointer(
786 func, "meta_sequence", "Strip", "Destination Meta Strip", "Meta to move the strip into");
788
789 func = RNA_def_function(srna, "parent_meta", "rna_Strip_parent_meta");
791 RNA_def_function_ui_description(func, "Returns parent meta Strip");
792 /* return type */
793 parm = RNA_def_pointer(func, "sequence", "Strip", "", "Parent meta strip");
794 RNA_def_function_return(func, parm);
795
796 func = RNA_def_function(srna, "invalidate_cache", "rna_Strip_invalidate_cache_rnafunc");
799 "Invalidate cached images for strip and all dependent strips");
800 parm = RNA_def_enum(func, "type", strip_cache_type_items, 0, "Type", "Cache Type");
802
803 func = RNA_def_function(srna, "split", "rna_Strip_split");
805 RNA_def_function_ui_description(func, "Split Strip");
806 parm = RNA_def_int(
807 func, "frame", 0, INT_MIN, INT_MAX, "", "Frame where to split the strip", INT_MIN, INT_MAX);
809 parm = RNA_def_enum(func,
810 "split_method",
811 strip_split_method_items,
812 0,
813 "Split Method",
814 "The type of split operation to perform on strips");
816 parm = RNA_def_boolean(
817 func, "ignore_connections", false, "", "Don't propagate split to connected strips");
818
819 /* Return type. */
820 parm = RNA_def_pointer(func, "sequence", "Strip", "", "Right side Strip");
821 RNA_def_function_return(func, parm);
822}
823
825{
826 StructRNA *srna;
827 PropertyRNA *parm;
828 FunctionRNA *func;
829
830 RNA_def_property_srna(cprop, "StripElements");
831 srna = RNA_def_struct(brna, "StripElements", nullptr);
832 RNA_def_struct_sdna(srna, "Strip");
833 RNA_def_struct_ui_text(srna, "StripElements", "Collection of StripElement");
834
835 func = RNA_def_function(srna, "append", "rna_StripElements_append");
837 RNA_def_function_ui_description(func, "Push an image from ImageStrip.directory");
838 parm = RNA_def_string(func, "filename", "File", 0, "", "Filepath to image");
840 /* return type */
841 parm = RNA_def_pointer(func, "elem", "StripElement", "", "New StripElement");
843 RNA_def_function_return(func, parm);
844
845 func = RNA_def_function(srna, "pop", "rna_StripElements_pop");
847 RNA_def_function_ui_description(func, "Pop an image off the collection");
848 parm = RNA_def_int(
849 func, "index", -1, INT_MIN, INT_MAX, "", "Index of image to remove", INT_MIN, INT_MAX);
851}
852
854{
855 StructRNA *srna = RNA_def_struct(brna, "RetimingKeys", nullptr);
856 RNA_def_struct_sdna(srna, "Strip");
857 RNA_def_struct_ui_text(srna, "RetimingKeys", "Collection of RetimingKey");
858
859 FunctionRNA *func = RNA_def_function(srna, "add", "rna_Strip_retiming_keys_add");
861 RNA_def_int(func,
862 "timeline_frame",
863 0,
864 -MAXFRAME,
865 MAXFRAME,
866 "Timeline Frame",
867 "Where to add the retiming key in the timeline",
868 -MAXFRAME,
869 MAXFRAME);
870 RNA_def_function_ui_description(func, "Add retiming key");
871 /* return type */
872 PropertyRNA *parm = RNA_def_pointer(func, "retiming_key", "RetimingKey", "", "New RetimingKey");
873 RNA_def_function_return(func, parm);
874
875 func = RNA_def_function(srna, "reset", "rna_Strip_retiming_keys_reset");
877 RNA_def_function_ui_description(func, "Remove all retiming keys");
878}
879
880void RNA_api_strips(StructRNA *srna, const bool metastrip)
881{
882 PropertyRNA *parm;
883 FunctionRNA *func;
884
885 static const EnumPropertyItem strip_effect_items[] = {
886 {STRIP_TYPE_CROSS, "CROSS", 0, "Crossfade", "Fade out of one video, fading into another"},
887 {STRIP_TYPE_ADD, "ADD", 0, "Add", "Add together color channels from two videos"},
888 {STRIP_TYPE_SUB, "SUBTRACT", 0, "Subtract", "Subtract one strip's color from another"},
889 {STRIP_TYPE_ALPHAOVER, "ALPHA_OVER", 0, "Alpha Over", "Blend alpha on top of another video"},
890 {STRIP_TYPE_ALPHAUNDER, "ALPHA_UNDER", 0, "Alpha Under", "Blend alpha below another video"},
892 "GAMMA_CROSS",
893 0,
894 "Gamma Crossfade",
895 "Crossfade with color correction"},
896 {STRIP_TYPE_COMPOSITOR, "COMPOSITOR", 0, "Compositor", "Compositor based effect"},
897 {STRIP_TYPE_MUL, "MULTIPLY", 0, "Multiply", "Multiply color channels from two videos"},
898 {STRIP_TYPE_WIPE, "WIPE", 0, "Wipe", "Sweep a transition line across the frame"},
899 {STRIP_TYPE_GLOW, "GLOW", 0, "Glow", "Add blur and brightness to light areas"},
900 {STRIP_TYPE_COLOR, "COLOR", 0, "Color", "Add a simple color strip"},
901 {STRIP_TYPE_SPEED, "SPEED", 0, "Speed", "Timewarp video strips, modifying playback speed"},
902 {STRIP_TYPE_MULTICAM, "MULTICAM", 0, "Multicam Selector", "Control active camera angles"},
903 {STRIP_TYPE_ADJUSTMENT, "ADJUSTMENT", 0, "Adjustment Layer", "Apply nondestructive effects"},
904 {STRIP_TYPE_GAUSSIAN_BLUR, "GAUSSIAN_BLUR", 0, "Gaussian Blur", "Soften details along axes"},
905 {STRIP_TYPE_TEXT, "TEXT", 0, "Text", "Add a simple text strip"},
906 {STRIP_TYPE_COLORMIX, "COLORMIX", 0, "Color Mix", "Combine two strips using blend modes"},
907 {0, nullptr, 0, nullptr, nullptr},
908 };
909
910 const char *new_clip_func_name = "rna_Strips_editing_new_clip";
911 const char *new_mask_func_name = "rna_Strips_editing_new_mask";
912 const char *new_scene_func_name = "rna_Strips_editing_new_scene";
913 const char *new_image_func_name = "rna_Strips_editing_new_image";
914 const char *new_movie_func_name = "rna_Strips_editing_new_movie";
915 const char *new_sound_func_name = "rna_Strips_editing_new_sound";
916 const char *new_meta_func_name = "rna_Strips_editing_new_meta";
917 const char *new_effect_func_name = "rna_Strips_editing_new_effect";
918 const char *remove_func_name = "rna_Strips_editing_remove";
919
920 if (metastrip) {
921 new_clip_func_name = "rna_Strips_meta_new_clip";
922 new_mask_func_name = "rna_Strips_meta_new_mask";
923 new_scene_func_name = "rna_Strips_meta_new_scene";
924 new_image_func_name = "rna_Strips_meta_new_image";
925 new_movie_func_name = "rna_Strips_meta_new_movie";
926 new_sound_func_name = "rna_Strips_meta_new_sound";
927 new_meta_func_name = "rna_Strips_meta_new_meta";
928 new_effect_func_name = "rna_Strips_meta_new_effect";
929 remove_func_name = "rna_Strips_meta_remove";
930 }
931
932 func = RNA_def_function(srna, "new_clip", new_clip_func_name);
934 RNA_def_function_ui_description(func, "Add a new movie clip strip");
935 parm = RNA_def_string(func, "name", "Name", 0, "", "Name for the new strip");
937 parm = RNA_def_pointer(func, "clip", "MovieClip", "", "Movie clip to add");
939 parm = RNA_def_int(func,
940 "channel",
941 0,
942 1,
944 "Channel",
945 "The channel for the new strip",
946 1,
949 parm = RNA_def_int(func,
950 "frame_start",
951 0,
952 -MAXFRAME,
953 MAXFRAME,
954 "",
955 "The start frame for the new strip",
956 -MAXFRAME,
957 MAXFRAME);
959 /* return type */
960 parm = RNA_def_pointer(func, "sequence", "Strip", "", "New Strip");
962 RNA_def_function_return(func, parm);
963
964 func = RNA_def_function(srna, "new_mask", new_mask_func_name);
966 RNA_def_function_ui_description(func, "Add a new mask strip");
967 parm = RNA_def_string(func, "name", "Name", 0, "", "Name for the new strip");
969 parm = RNA_def_pointer(func, "mask", "Mask", "", "Mask to add");
971 parm = RNA_def_int(func,
972 "channel",
973 0,
974 1,
976 "Channel",
977 "The channel for the new strip",
978 1,
981 parm = RNA_def_int(func,
982 "frame_start",
983 0,
984 -MAXFRAME,
985 MAXFRAME,
986 "",
987 "The start frame for the new strip",
988 -MAXFRAME,
989 MAXFRAME);
991 /* return type */
992 parm = RNA_def_pointer(func, "sequence", "Strip", "", "New Strip");
994 RNA_def_function_return(func, parm);
995
996 func = RNA_def_function(srna, "new_scene", new_scene_func_name);
998 RNA_def_function_ui_description(func, "Add a new scene strip");
999 parm = RNA_def_string(func, "name", "Name", 0, "", "Name for the new strip");
1001 parm = RNA_def_pointer(func, "scene", "Scene", "", "Scene to add");
1003 parm = RNA_def_int(func,
1004 "channel",
1005 0,
1006 1,
1008 "Channel",
1009 "The channel for the new strip",
1010 1,
1013 parm = RNA_def_int(func,
1014 "frame_start",
1015 0,
1016 -MAXFRAME,
1017 MAXFRAME,
1018 "",
1019 "The start frame for the new strip",
1020 -MAXFRAME,
1021 MAXFRAME);
1023 /* return type */
1024 parm = RNA_def_pointer(func, "sequence", "Strip", "", "New Strip");
1026 RNA_def_function_return(func, parm);
1027
1028 func = RNA_def_function(srna, "new_image", new_image_func_name);
1030 RNA_def_function_ui_description(func, "Add a new image strip");
1031 parm = RNA_def_string(func, "name", "Name", 0, "", "Name for the new strip");
1033 parm = RNA_def_string(func, "filepath", "File", 0, "", "Filepath to image");
1035 parm = RNA_def_int(func,
1036 "channel",
1037 0,
1038 1,
1040 "Channel",
1041 "The channel for the new strip",
1042 1,
1045 parm = RNA_def_int(func,
1046 "frame_start",
1047 0,
1048 -MAXFRAME,
1049 MAXFRAME,
1050 "",
1051 "The start frame for the new strip",
1052 -MAXFRAME,
1053 MAXFRAME);
1055 parm = RNA_def_enum(func,
1056 "fit_method",
1059 "Image Fit Method",
1060 "Mode for fitting the image to the canvas");
1061 /* return type */
1062 parm = RNA_def_pointer(func, "sequence", "Strip", "", "New Strip");
1064 RNA_def_function_return(func, parm);
1065
1066 func = RNA_def_function(srna, "new_movie", new_movie_func_name);
1068 RNA_def_function_ui_description(func, "Add a new movie strip");
1069 parm = RNA_def_string(func, "name", "Name", 0, "", "Name for the new strip");
1071 parm = RNA_def_string(func, "filepath", "File", 0, "", "Filepath to movie");
1073 parm = RNA_def_int(func,
1074 "channel",
1075 0,
1076 1,
1078 "Channel",
1079 "The channel for the new strip",
1080 1,
1083 parm = RNA_def_int(func,
1084 "frame_start",
1085 0,
1086 -MAXFRAME,
1087 MAXFRAME,
1088 "",
1089 "The start frame for the new strip",
1090 -MAXFRAME,
1091 MAXFRAME);
1093 parm = RNA_def_enum(func,
1094 "fit_method",
1097 "Image Fit Method",
1098 "Mode for fitting the image to the canvas");
1100 func, "stream", 0, 0, SHRT_MAX, "Stream", "Stream index for multi-stream files", 0, 20);
1101 /* return type */
1102 parm = RNA_def_pointer(func, "sequence", "Strip", "", "New Strip");
1104 RNA_def_function_return(func, parm);
1105
1106 func = RNA_def_function(srna, "new_sound", new_sound_func_name);
1108 RNA_def_function_ui_description(func, "Add a new sound strip");
1109 parm = RNA_def_string(func, "name", "Name", 0, "", "Name for the new strip");
1111 parm = RNA_def_string(func, "filepath", "File", 0, "", "Filepath to movie");
1113 parm = RNA_def_int(func,
1114 "channel",
1115 0,
1116 1,
1118 "Channel",
1119 "The channel for the new strip",
1120 1,
1123 parm = RNA_def_int(func,
1124 "frame_start",
1125 0,
1126 -MAXFRAME,
1127 MAXFRAME,
1128 "",
1129 "The start frame for the new strip",
1130 -MAXFRAME,
1131 MAXFRAME);
1134 func, "stream", 0, 0, SHRT_MAX, "Stream", "Stream index for multi-stream files", 0, 20);
1135 /* return type */
1136 parm = RNA_def_pointer(func, "sequence", "Strip", "", "New Strip");
1138 RNA_def_function_return(func, parm);
1139
1140 func = RNA_def_function(srna, "new_meta", new_meta_func_name);
1142 RNA_def_function_ui_description(func, "Add a new meta strip");
1143 parm = RNA_def_string(func, "name", "Name", 0, "", "Name for the new strip");
1145 parm = RNA_def_int(func,
1146 "channel",
1147 0,
1148 1,
1150 "Channel",
1151 "The channel for the new strip",
1152 1,
1155 parm = RNA_def_int(func,
1156 "frame_start",
1157 0,
1158 -MAXFRAME,
1159 MAXFRAME,
1160 "",
1161 "The start frame for the new strip",
1162 -MAXFRAME,
1163 MAXFRAME);
1165 /* return type */
1166 parm = RNA_def_pointer(func, "sequence", "Strip", "", "New Strip");
1168 RNA_def_function_return(func, parm);
1169
1170 func = RNA_def_function(srna, "new_effect", new_effect_func_name);
1172 RNA_def_function_ui_description(func, "Add a new effect strip");
1173 parm = RNA_def_string(func, "name", "Name", 0, "", "Name for the new strip");
1175 parm = RNA_def_enum(func, "type", strip_effect_items, 0, "Type", "type for the new strip");
1177 parm = RNA_def_int(func,
1178 "channel",
1179 0,
1180 1,
1182 "Channel",
1183 "The channel for the new strip",
1184 1,
1186 /* don't use MAXFRAME since it makes importer scripts fail */
1188 parm = RNA_def_int(func,
1189 "frame_start",
1190 0,
1191 INT_MIN,
1192 INT_MAX,
1193 "",
1194 "The start frame for the new strip",
1195 INT_MIN,
1196 INT_MAX);
1198 RNA_def_int(func,
1199 "length",
1200 0,
1201 INT_MIN,
1202 INT_MAX,
1203 "",
1204 "Length of the strip in frames, or the length of each strip if multiple are added",
1205 INT_MIN,
1206 INT_MAX);
1207 RNA_def_pointer(func, "input1", "Strip", "", "First input strip for effect");
1208 RNA_def_pointer(func, "input2", "Strip", "", "Second input strip for effect");
1209 /* return type */
1210 parm = RNA_def_pointer(func, "sequence", "Strip", "", "New Strip");
1212 RNA_def_function_return(func, parm);
1213
1214 func = RNA_def_function(srna, "remove", remove_func_name);
1216 RNA_def_function_ui_description(func, "Remove a Strip");
1217 parm = RNA_def_pointer(func, "sequence", "Strip", "", "Strip to remove");
1220}
1221
1222} // namespace blender
1223
1224#endif
#define FILE_MAXFILE
#define FILE_MAX
#define STRNCPY_UTF8(dst, src)
#define MAXFRAME
#define ND_SEQUENCER
Definition WM_types.hh:456
#define NC_SCENE
Definition WM_types.hh:391
#define STREQ(a, b)
#define MEM_realloc_uninitialized(vmemh, len)
SIMD_FORCE_INLINE btScalar length() const
Return the length of the vector.
Definition btVector3.h:257
string name
Definition scene.h:136
float4 load_data(StoredFloat4 data)
#define SHRT_MAX
#define INT_MAX
std::string filename(const std::string_view &str, size_t pos)
SeqRetimingKey * retiming_key_add_new_for_strip(const Scene *scene, ReportList *reports, Strip *strip, const int frame)
Strip * lookup_meta_by_strip(Editing *ed, const Strip *key)
Strip * add_effect_strip(Scene *scene, ListBaseT< Strip > *seqbase, LoadData *load_data)
Definition strip_add.cc:174
void relations_invalidate_cache(Scene *scene, Strip *strip)
Strip * add_image_strip(Main *bmain, Scene *scene, ListBaseT< Strip > *seqbase, LoadData *load_data)
Definition strip_add.cc:245
ListBaseT< Strip > * get_seqbase_by_strip(const Scene *scene, Strip *strip)
Strip * add_meta_strip(Scene *scene, ListBaseT< Strip > *seqbase, LoadData *load_data)
Definition strip_add.cc:376
Editing * editing_get(const Scene *scene)
Definition sequencer.cc:304
void add_image_load_file(Scene *scene, Strip *strip, size_t strip_frame, const char *filename)
Definition strip_add.cc:210
void edit_remove_flagged_strips(Scene *scene, ListBaseT< Strip > *seqbase)
void add_image_set_directory(Strip *strip, const char *dirpath)
Definition strip_add.cc:205
void relations_invalidate_cache_raw(Scene *scene, Strip *strip)
void retiming_data_clear(Strip *strip)
constexpr int MAX_CHANNELS
Strip * add_sound_strip(Main *, Scene *, ListBaseT< Strip > *, LoadData *)
Definition strip_add.cc:367
bool edit_move_strip_to_meta(Scene *scene, Strip *src_strip, Strip *dst_stripm, const char **r_error_str)
void add_image_init_alpha_mode(Main *bmain, Scene *scene, Strip *strip)
Definition strip_add.cc:216
void edit_flag_for_removal(Scene *scene, Strip *strip)
Strip * add_movieclip_strip(Scene *scene, ListBaseT< Strip > *seqbase, LoadData *load_data)
Definition strip_add.cc:151
Strip * add_scene_strip(Scene *scene, ListBaseT< Strip > *seqbase, LoadData *load_data)
Definition strip_add.cc:138
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)
bool edit_strip_swap(Scene *scene, Strip *strip_a, Strip *strip_b, const char **r_error_str)
Definition strip_edit.cc:45
int effect_type_get_min_num_inputs(StripType type)
Definition effects.cc:347
Strip * add_movie_strip(Main *bmain, Scene *scene, ListBaseT< Strip > *seqbase, LoadData *load_data)
Definition strip_add.cc:394
void strip_lookup_invalidate(const Editing *ed)
Strip * add_mask_strip(Scene *scene, ListBaseT< Strip > *seqbase, LoadData *load_data)
Definition strip_add.cc:163
void add_load_data_init(LoadData *load_data, const char *name, const char *path, const int start_frame, const int channel)
Definition strip_add.cc:69
StripElem * render_give_stripelem(const Scene *scene, const Strip *strip, int timeline_frame)
Definition render.cc:220
BMesh Iterators.
void WM_main_add_notifier(uint type, void *reference)
void RNA_def_property_srna(PropertyRNA *prop, const char *type)
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description)
char * STRNCPY(char(&dst)[N], const char *src)
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
@ RPT_WARNING
Definition BKE_report.hh:40
@ SEQ_USE_ORIGINAL_SIZE
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
@ FUNC_USE_REPORTS
@ FUNC_USE_SELF_ID
Definition RNA_types.hh:980
@ FUNC_USE_MAIN
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_pointer(StructOrFunctionRNA *cont_, const char *identifier, const char *type, const char *ui_name, const char *ui_description)
void RNA_api_strip_retiming_keys(BlenderRNA *brna)
int BLI_findindex(const ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:593
void RNA_def_struct_sdna(StructRNA *srna, const char *structname)
void RNA_def_parameter_clear_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
void DEG_id_tag_update(ID *id, unsigned int flags)
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:162
void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret)
void RNA_api_strips(StructRNA *srna, bool metastrip)
void RNA_api_strip(StructRNA *srna)
const EnumPropertyItem rna_enum_strip_scale_method_items[]
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier_c_str, const char *call)
void RNA_def_function_flag(FunctionRNA *func, FunctionFlag 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 BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
Definition report.cc:191
StructRNA * RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
@ ID_RECALC_SEQUENCER_STRIPS
Definition DNA_ID.h:1122
@ PROP_THICK_WRAP
Definition RNA_types.hh:493
@ PROP_NEVER_NULL
Definition RNA_types.hh:447
void BLI_path_split_dir_file(const char *filepath, char *dir, size_t dir_maxncpy, char *file, size_t file_maxncpy) ATTR_NONNULL(1
void DEG_relations_tag_update(Main *bmain)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
@ PARM_REQUIRED
Definition RNA_types.hh:631
@ PARM_RNAPTR
Definition RNA_types.hh:633
void RNA_api_strip_elements(BlenderRNA *brna, PropertyRNA *cprop)