1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
17 /** \file
18  * \ingroup RNA
19  */
20 
21 #include <limits.h>
22 #include <stdlib.h>
23 
24 #include "DNA_anim_types.h"
25 #include "DNA_movieclip_types.h"
26 #include "DNA_object_types.h"
27 #include "DNA_scene_types.h"
28 #include "DNA_sequence_types.h"
29 #include "DNA_vfont_types.h"
30 
31 #include "BLI_math.h"
32 
33 #include "BLT_translation.h"
34 
35 #include "BKE_anim_data.h"
36 #include "BKE_animsys.h"
37 #include "BKE_sequencer.h"
38 #include "BKE_sound.h"
39 
40 #include "IMB_metadata.h"
41 
42 #include "MEM_guardedalloc.h"
43 
44 #include "RNA_access.h"
45 #include "RNA_define.h"
46 #include "RNA_enum_types.h"
47 
48 #include "rna_internal.h"
49 
50 #include "WM_types.h"
51 
52 typedef struct EffectInfo {
53   const char *struct_name;
54   const char *ui_name;
55   const char *ui_desc;
56   void (*func)(StructRNA *);
57   int inputs;
58 } EffectInfo;
59 
60 const EnumPropertyItem rna_enum_sequence_modifier_type_items[] = {
61     {seqModifierType_ColorBalance, "COLOR_BALANCE", ICON_NONE, "Color Balance", ""},
62     {seqModifierType_Curves, "CURVES", ICON_NONE, "Curves", ""},
63     {seqModifierType_HueCorrect, "HUE_CORRECT", ICON_NONE, "Hue Correct", ""},
64     {seqModifierType_BrightContrast, "BRIGHT_CONTRAST", ICON_NONE, "Bright/Contrast", ""},
65     {seqModifierType_Mask, "MASK", ICON_NONE, "Mask", ""},
66     {seqModifierType_WhiteBalance, "WHITE_BALANCE", ICON_NONE, "White Balance", ""},
67     {seqModifierType_Tonemap, "TONEMAP", ICON_NONE, "Tone Map", ""},
68     {0, NULL, 0, NULL, NULL},
69 };
70 
71 #ifdef RNA_RUNTIME
72 
73 #  include "BKE_global.h"
74 #  include "BKE_idprop.h"
75 #  include "BKE_movieclip.h"
76 #  include "BKE_report.h"
77 
78 #  include "WM_api.h"
79 
80 #  include "DEG_depsgraph.h"
81 #  include "DEG_depsgraph_build.h"
82 
83 #  include "IMB_imbuf.h"
84 
85 typedef struct SequenceSearchData {
86   Sequence *seq;
87   void *data;
88   SequenceModifierData *smd;
89 } SequenceSearchData;
90 
91 /* build a temp reference to the parent */
meta_tmp_ref(Sequence * seq_par,Sequence * seq)92 static void meta_tmp_ref(Sequence *seq_par, Sequence *seq)
93 {
94   for (; seq; seq = seq->next) {
95     seq->tmp = seq_par;
96     if (seq->type == SEQ_TYPE_META) {
97       meta_tmp_ref(seq, seq->seqbase.first);
98     }
99   }
100 }
101 
rna_SequenceElement_update(Main * UNUSED (bmain),Scene * UNUSED (scene),PointerRNA * ptr)102 static void rna_SequenceElement_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
103 {
104   Scene *scene = (Scene *)ptr->owner_id;
105   Editing *ed = BKE_sequencer_editing_get(scene, false);
106 
107   if (ed) {
108     StripElem *se = (StripElem *)ptr->data;
109     Sequence *seq;
110 
111     /* slow but we can't avoid! */
112     seq = BKE_sequencer_from_elem(&ed->seqbase, se);
113     if (seq) {
114       BKE_sequence_invalidate_cache_raw(scene, seq);
115     }
116   }
117 }
118 
rna_Sequence_invalidate_raw_update(Main * UNUSED (bmain),Scene * UNUSED (scene),PointerRNA * ptr)119 static void rna_Sequence_invalidate_raw_update(Main *UNUSED(bmain),
120                                                Scene *UNUSED(scene),
121                                                PointerRNA *ptr)
122 {
123   Scene *scene = (Scene *)ptr->owner_id;
124   Editing *ed = BKE_sequencer_editing_get(scene, false);
125 
126   if (ed) {
127     Sequence *seq = (Sequence *)ptr->data;
128 
129     BKE_sequence_invalidate_cache_raw(scene, seq);
130   }
131 }
132 
rna_Sequence_invalidate_preprocessed_update(Main * UNUSED (bmain),Scene * UNUSED (scene),PointerRNA * ptr)133 static void rna_Sequence_invalidate_preprocessed_update(Main *UNUSED(bmain),
134                                                         Scene *UNUSED(scene),
135                                                         PointerRNA *ptr)
136 {
137   Scene *scene = (Scene *)ptr->owner_id;
138   Editing *ed = BKE_sequencer_editing_get(scene, false);
139 
140   if (ed) {
141     Sequence *seq = (Sequence *)ptr->data;
142 
143     BKE_sequence_invalidate_cache_preprocessed(scene, seq);
144   }
145 }
146 
rna_Sequence_invalidate_composite_update(Main * UNUSED (bmain),Scene * UNUSED (scene),PointerRNA * ptr)147 static void rna_Sequence_invalidate_composite_update(Main *UNUSED(bmain),
148                                                      Scene *UNUSED(scene),
149                                                      PointerRNA *ptr)
150 {
151   Scene *scene = (Scene *)ptr->owner_id;
152   Editing *ed = BKE_sequencer_editing_get(scene, false);
153 
154   if (ed) {
155     Sequence *seq = (Sequence *)ptr->data;
156 
157     BKE_sequence_invalidate_cache_composite(scene, seq);
158   }
159 }
160 
rna_Sequence_scene_switch_update(Main * bmain,Scene * scene,PointerRNA * ptr)161 static void rna_Sequence_scene_switch_update(Main *bmain, Scene *scene, PointerRNA *ptr)
162 {
163   rna_Sequence_invalidate_raw_update(bmain, scene, ptr);
164   DEG_id_tag_update(&scene->id, ID_RECALC_AUDIO | ID_RECALC_SEQUENCER_STRIPS);
165   DEG_relations_tag_update(bmain);
166 }
167 
rna_Sequence_use_sequence(Main * bmain,Scene * scene,PointerRNA * ptr)168 static void rna_Sequence_use_sequence(Main *bmain, Scene *scene, PointerRNA *ptr)
169 {
170   /* General update callback. */
171   rna_Sequence_invalidate_raw_update(bmain, scene, ptr);
172   /* Changing recursion changes set of IDs which needs to be remapped by the copy-on-write.
173    * the only way for this currently is to tag the ID for ID_RECALC_COPY_ON_WRITE. */
174   Editing *ed = BKE_sequencer_editing_get(scene, false);
175   if (ed) {
176     Sequence *seq = (Sequence *)ptr->data;
177     if (seq->scene != NULL) {
178       DEG_id_tag_update(&seq->scene->id, ID_RECALC_COPY_ON_WRITE);
179     }
180   }
181   /* The sequencer scene is to be updated as well, including new relations from the nested
182    * sequencer. */
183   DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS);
184   DEG_relations_tag_update(bmain);
185 }
186 
rna_SequenceEditor_sequences_all_begin(CollectionPropertyIterator * iter,PointerRNA * ptr)187 static void rna_SequenceEditor_sequences_all_begin(CollectionPropertyIterator *iter,
188                                                    PointerRNA *ptr)
189 {
190   Scene *scene = (Scene *)ptr->owner_id;
191   Editing *ed = BKE_sequencer_editing_get(scene, false);
192 
193   meta_tmp_ref(NULL, ed->seqbase.first);
194 
195   rna_iterator_listbase_begin(iter, &ed->seqbase, NULL);
196 }
197 
rna_SequenceEditor_update_cache(Main * UNUSED (bmain),Scene * scene,PointerRNA * UNUSED (ptr))198 static void rna_SequenceEditor_update_cache(Main *UNUSED(bmain),
199                                             Scene *scene,
200                                             PointerRNA *UNUSED(ptr))
201 {
202   Editing *ed = scene->ed;
203 
204   BKE_sequencer_free_imbuf(scene, &ed->seqbase, false);
205   BKE_sequencer_cache_cleanup(scene);
206 }
207 
rna_SequenceEditor_sequences_all_next(CollectionPropertyIterator * iter)208 static void rna_SequenceEditor_sequences_all_next(CollectionPropertyIterator *iter)
209 {
210   ListBaseIterator *internal = &iter->internal.listbase;
211   Sequence *seq = (Sequence *)internal->link;
212 
213   if (seq->seqbase.first) {
214     internal->link = (Link *)seq->seqbase.first;
215   }
216   else if (seq->next) {
217     internal->link = (Link *)seq->next;
218   }
219   else {
220     internal->link = NULL;
221 
222     do {
223       seq = seq->tmp; /* XXX - seq's don't reference their parents! */
224       if (seq && seq->next) {
225         internal->link = (Link *)seq->next;
226         break;
227       }
228     } while (seq);
229   }
230 
231   iter->valid = (internal->link != NULL);
232 }
233 
234 /* internal use */
rna_SequenceEditor_elements_length(PointerRNA * ptr)235 static int rna_SequenceEditor_elements_length(PointerRNA *ptr)
236 {
237   Sequence *seq = (Sequence *)ptr->data;
238 
239   /* Hack? copied from sequencer.c::reload_sequence_new_file() */
240   size_t olen = MEM_allocN_len(seq->strip->stripdata) / sizeof(struct StripElem);
241 
242   /* The problem with seq->strip->len and seq->len is that it's discounted from the offset
243    * (hard cut trim). */
244   return (int)olen;
245 }
246 
rna_SequenceEditor_elements_begin(CollectionPropertyIterator * iter,PointerRNA * ptr)247 static void rna_SequenceEditor_elements_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
248 {
249   Sequence *seq = (Sequence *)ptr->data;
250   rna_iterator_array_begin(iter,
251                            (void *)seq->strip->stripdata,
252                            sizeof(StripElem),
253                            rna_SequenceEditor_elements_length(ptr),
254                            0,
255                            NULL);
256 }
257 
rna_Sequence_views_format_update(Main * bmain,Scene * scene,PointerRNA * ptr)258 static void rna_Sequence_views_format_update(Main *bmain, Scene *scene, PointerRNA *ptr)
259 {
260   rna_Sequence_invalidate_raw_update(bmain, scene, ptr);
261 }
262 
do_sequence_frame_change_update(Scene * scene,Sequence * seq)263 static void do_sequence_frame_change_update(Scene *scene, Sequence *seq)
264 {
265   Editing *ed = BKE_sequencer_editing_get(scene, false);
266   ListBase *seqbase = BKE_sequence_seqbase(&ed->seqbase, seq);
267   Sequence *tseq;
268   BKE_sequence_calc_disp(scene, seq);
269 
270   /* ensure effects are always fit in length to their input */
271 
272   /* TODO(sergey): probably could be optimized.
273    *               in terms skipping update of non-changing strips
274    */
275   for (tseq = seqbase->first; tseq; tseq = tseq->next) {
276     if (tseq->seq1 || tseq->seq2 || tseq->seq3) {
277       BKE_sequence_calc(scene, tseq);
278     }
279   }
280 
281   if (BKE_sequence_test_overlap(seqbase, seq)) {
282     BKE_sequence_base_shuffle(seqbase, seq, scene); /* XXX - BROKEN!, uses context seqbasep */
283   }
284   BKE_sequencer_sort(scene);
285 }
286 
287 /* A simple wrapper around above func, directly usable as prop update func.
288  * Also invalidate cache if needed.
289  */
rna_Sequence_frame_change_update(Main * UNUSED (bmain),Scene * UNUSED (scene),PointerRNA * ptr)290 static void rna_Sequence_frame_change_update(Main *UNUSED(bmain),
291                                              Scene *UNUSED(scene),
292                                              PointerRNA *ptr)
293 {
294   Scene *scene = (Scene *)ptr->owner_id;
295   do_sequence_frame_change_update(scene, (Sequence *)ptr->data);
296 }
297 
rna_Sequence_start_frame_set(PointerRNA * ptr,int value)298 static void rna_Sequence_start_frame_set(PointerRNA *ptr, int value)
299 {
300   Sequence *seq = (Sequence *)ptr->data;
301   Scene *scene = (Scene *)ptr->owner_id;
302 
303   BKE_sequence_invalidate_cache_composite(scene, seq);
304   BKE_sequence_translate(scene, seq, value - seq->start);
305   do_sequence_frame_change_update(scene, seq);
306   BKE_sequence_invalidate_cache_composite(scene, seq);
307 }
308 
rna_Sequence_start_frame_final_set(PointerRNA * ptr,int value)309 static void rna_Sequence_start_frame_final_set(PointerRNA *ptr, int value)
310 {
311   Sequence *seq = (Sequence *)ptr->data;
312   Scene *scene = (Scene *)ptr->owner_id;
313 
314   BKE_sequence_invalidate_cache_composite(scene, seq);
315   BKE_sequence_tx_set_final_left(seq, value);
316   BKE_sequence_single_fix(seq);
317   do_sequence_frame_change_update(scene, seq);
318   BKE_sequence_invalidate_cache_composite(scene, seq);
319 }
320 
rna_Sequence_end_frame_final_set(PointerRNA * ptr,int value)321 static void rna_Sequence_end_frame_final_set(PointerRNA *ptr, int value)
322 {
323   Sequence *seq = (Sequence *)ptr->data;
324   Scene *scene = (Scene *)ptr->owner_id;
325 
326   BKE_sequence_invalidate_cache_composite(scene, seq);
327   BKE_sequence_tx_set_final_right(seq, value);
328   BKE_sequence_single_fix(seq);
329   do_sequence_frame_change_update(scene, seq);
330   BKE_sequence_invalidate_cache_composite(scene, seq);
331 }
332 
rna_Sequence_frame_offset_start_set(PointerRNA * ptr,int value)333 static void rna_Sequence_frame_offset_start_set(PointerRNA *ptr, int value)
334 {
335   Sequence *seq = (Sequence *)ptr->data;
336   Scene *scene = (Scene *)ptr->owner_id;
337 
338   BKE_sequence_invalidate_cache_composite(scene, seq);
339   seq->startofs = value;
340 }
341 
rna_Sequence_frame_offset_end_set(PointerRNA * ptr,int value)342 static void rna_Sequence_frame_offset_end_set(PointerRNA *ptr, int value)
343 {
344   Sequence *seq = (Sequence *)ptr->data;
345   Scene *scene = (Scene *)ptr->owner_id;
346 
347   BKE_sequence_invalidate_cache_composite(scene, seq);
348   seq->endofs = value;
349 }
350 
rna_Sequence_frame_still_start_set(PointerRNA * ptr,int value)351 static void rna_Sequence_frame_still_start_set(PointerRNA *ptr, int value)
352 {
353   Sequence *seq = (Sequence *)ptr->data;
354   Scene *scene = (Scene *)ptr->owner_id;
355 
356   BKE_sequence_invalidate_cache_composite(scene, seq);
357   seq->startstill = value;
358 }
359 
rna_Sequence_frame_still_end_set(PointerRNA * ptr,int value)360 static void rna_Sequence_frame_still_end_set(PointerRNA *ptr, int value)
361 {
362   Sequence *seq = (Sequence *)ptr->data;
363   Scene *scene = (Scene *)ptr->owner_id;
364 
365   BKE_sequence_invalidate_cache_composite(scene, seq);
366   seq->endstill = value;
367 }
368 
rna_Sequence_anim_startofs_final_set(PointerRNA * ptr,int value)369 static void rna_Sequence_anim_startofs_final_set(PointerRNA *ptr, int value)
370 {
371   Sequence *seq = (Sequence *)ptr->data;
372   Scene *scene = (Scene *)ptr->owner_id;
373 
374   seq->anim_startofs = MIN2(value, seq->len + seq->anim_startofs);
375 
376   BKE_sequence_reload_new_file(G.main, scene, seq, false);
377   do_sequence_frame_change_update(scene, seq);
378 }
379 
rna_Sequence_anim_endofs_final_set(PointerRNA * ptr,int value)380 static void rna_Sequence_anim_endofs_final_set(PointerRNA *ptr, int value)
381 {
382   Sequence *seq = (Sequence *)ptr->data;
383   Scene *scene = (Scene *)ptr->owner_id;
384 
385   seq->anim_endofs = MIN2(value, seq->len + seq->anim_endofs);
386 
387   BKE_sequence_reload_new_file(G.main, scene, seq, false);
388   do_sequence_frame_change_update(scene, seq);
389 }
390 
rna_Sequence_anim_endofs_final_range(PointerRNA * ptr,int * min,int * max,int * UNUSED (softmin),int * UNUSED (softmax))391 static void rna_Sequence_anim_endofs_final_range(
392     PointerRNA *ptr, int *min, int *max, int *UNUSED(softmin), int *UNUSED(softmax))
393 {
394   Sequence *seq = (Sequence *)ptr->data;
395 
396   *min = 0;
397   *max = seq->len + seq->anim_endofs - seq->startofs - seq->endofs - 1;
398 }
399 
rna_Sequence_anim_startofs_final_range(PointerRNA * ptr,int * min,int * max,int * UNUSED (softmin),int * UNUSED (softmax))400 static void rna_Sequence_anim_startofs_final_range(
401     PointerRNA *ptr, int *min, int *max, int *UNUSED(softmin), int *UNUSED(softmax))
402 {
403   Sequence *seq = (Sequence *)ptr->data;
404 
405   *min = 0;
406   *max = seq->len + seq->anim_startofs - seq->startofs - seq->endofs - 1;
407 }
408 
rna_Sequence_frame_offset_start_range(PointerRNA * ptr,int * min,int * max,int * UNUSED (softmin),int * UNUSED (softmax))409 static void rna_Sequence_frame_offset_start_range(
410     PointerRNA *ptr, int *min, int *max, int *UNUSED(softmin), int *UNUSED(softmax))
411 {
412   Sequence *seq = (Sequence *)ptr->data;
413   *min = ELEM(seq->type, SEQ_TYPE_SOUND_RAM, SEQ_TYPE_SOUND_HD) ? 0 : INT_MIN;
414   *max = seq->len - seq->endofs - 1;
415 }
416 
rna_Sequence_frame_offset_end_range(PointerRNA * ptr,int * min,int * max,int * UNUSED (softmin),int * UNUSED (softmax))417 static void rna_Sequence_frame_offset_end_range(
418     PointerRNA *ptr, int *min, int *max, int *UNUSED(softmin), int *UNUSED(softmax))
419 {
420   Sequence *seq = (Sequence *)ptr->data;
421   *min = ELEM(seq->type, SEQ_TYPE_SOUND_RAM, SEQ_TYPE_SOUND_HD) ? 0 : INT_MIN;
422   *max = seq->len - seq->startofs - 1;
423 }
424 
rna_Sequence_frame_length_set(PointerRNA * ptr,int value)425 static void rna_Sequence_frame_length_set(PointerRNA *ptr, int value)
426 {
427   Sequence *seq = (Sequence *)ptr->data;
428   Scene *scene = (Scene *)ptr->owner_id;
429 
430   BKE_sequence_invalidate_cache_composite(scene, seq);
431   BKE_sequence_tx_set_final_right(seq, BKE_sequence_tx_get_final_left(seq, false) + value);
432   do_sequence_frame_change_update(scene, seq);
433   BKE_sequence_invalidate_cache_composite(scene, seq);
434 }
435 
rna_Sequence_frame_length_get(PointerRNA * ptr)436 static int rna_Sequence_frame_length_get(PointerRNA *ptr)
437 {
438   Sequence *seq = (Sequence *)ptr->data;
439   return BKE_sequence_tx_get_final_right(seq, false) - BKE_sequence_tx_get_final_left(seq, false);
440 }
441 
rna_Sequence_frame_editable(PointerRNA * ptr,const char ** UNUSED (r_info))442 static int rna_Sequence_frame_editable(PointerRNA *ptr, const char **UNUSED(r_info))
443 {
444   Sequence *seq = (Sequence *)ptr->data;
445   /* Effect sequences' start frame and length must be readonly! */
446   return (BKE_sequence_effect_get_num_inputs(seq->type)) ? 0 : PROP_EDITABLE;
447 }
448 
rna_Sequence_channel_set(PointerRNA * ptr,int value)449 static void rna_Sequence_channel_set(PointerRNA *ptr, int value)
450 {
451   Sequence *seq = (Sequence *)ptr->data;
452   Scene *scene = (Scene *)ptr->owner_id;
453   Editing *ed = BKE_sequencer_editing_get(scene, false);
454   ListBase *seqbase = BKE_sequence_seqbase(&ed->seqbase, seq);
455 
456   BKE_sequence_invalidate_cache_composite(scene, seq);
457   /* check channel increment or decrement */
458   const int channel_delta = (value >= seq->machine) ? 1 : -1;
459   seq->machine = value;
460 
461   if (BKE_sequence_test_overlap(seqbase, seq)) {
462     /* XXX - BROKEN!, uses context seqbasep */
463     BKE_sequence_base_shuffle_ex(seqbase, seq, scene, channel_delta);
464   }
465   BKE_sequencer_sort(scene);
466   BKE_sequence_invalidate_cache_composite(scene, seq);
467 }
468 
rna_Sequence_use_proxy_set(PointerRNA * ptr,bool value)469 static void rna_Sequence_use_proxy_set(PointerRNA *ptr, bool value)
470 {
471   Sequence *seq = (Sequence *)ptr->data;
472   BKE_sequencer_proxy_set(seq, value != 0);
473 }
474 
rna_Sequence_use_translation_set(PointerRNA * ptr,bool value)475 static void rna_Sequence_use_translation_set(PointerRNA *ptr, bool value)
476 {
477   Sequence *seq = (Sequence *)ptr->data;
478   if (value) {
479     seq->flag |= SEQ_USE_TRANSFORM;
480     if (seq->strip->transform == NULL) {
481       seq->strip->transform = MEM_callocN(sizeof(struct StripTransform), "StripTransform");
482     }
483   }
484   else {
485     seq->flag &= ~SEQ_USE_TRANSFORM;
486   }
487 }
488 
rna_Sequence_use_crop_set(PointerRNA * ptr,bool value)489 static void rna_Sequence_use_crop_set(PointerRNA *ptr, bool value)
490 {
491   Sequence *seq = (Sequence *)ptr->data;
492   if (value) {
493     seq->flag |= SEQ_USE_CROP;
494     if (seq->strip->crop == NULL) {
495       seq->strip->crop = MEM_callocN(sizeof(struct StripCrop), "StripCrop");
496     }
497   }
498   else {
499     seq->flag &= ~SEQ_USE_CROP;
500   }
501 }
502 
transform_seq_cmp_fn(Sequence * seq,void * arg_pt)503 static int transform_seq_cmp_fn(Sequence *seq, void *arg_pt)
504 {
505   SequenceSearchData *data = arg_pt;
506 
507   if (seq->strip && seq->strip->transform == data->data) {
508     data->seq = seq;
509     return -1; /* done so bail out */
510   }
511   return 1;
512 }
513 
sequence_get_by_transform(Editing * ed,StripTransform * transform)514 static Sequence *sequence_get_by_transform(Editing *ed, StripTransform *transform)
515 {
516   SequenceSearchData data;
517 
518   data.seq = NULL;
519   data.data = transform;
520 
521   /* irritating we need to search for our sequence! */
522   BKE_sequencer_base_recursive_apply(&ed->seqbase, transform_seq_cmp_fn, &data);
523 
524   return data.seq;
525 }
526 
rna_SequenceTransform_path(PointerRNA * ptr)527 static char *rna_SequenceTransform_path(PointerRNA *ptr)
528 {
529   Scene *scene = (Scene *)ptr->owner_id;
530   Editing *ed = BKE_sequencer_editing_get(scene, false);
531   Sequence *seq = sequence_get_by_transform(ed, ptr->data);
532 
533   if (seq && seq->name + 2) {
534     char name_esc[(sizeof(seq->name) - 2) * 2];
535 
536     BLI_strescape(name_esc, seq->name + 2, sizeof(name_esc));
537     return BLI_sprintfN("sequence_editor.sequences_all[\"%s\"].transform", name_esc);
538   }
539   else {
540     return BLI_strdup("");
541   }
542 }
543 
rna_SequenceTransform_update(Main * UNUSED (bmain),Scene * UNUSED (scene),PointerRNA * ptr)544 static void rna_SequenceTransform_update(Main *UNUSED(bmain),
545                                          Scene *UNUSED(scene),
546                                          PointerRNA *ptr)
547 {
548   Scene *scene = (Scene *)ptr->owner_id;
549   Editing *ed = BKE_sequencer_editing_get(scene, false);
550   Sequence *seq = sequence_get_by_transform(ed, ptr->data);
551 
552   BKE_sequence_invalidate_cache_preprocessed(scene, seq);
553 }
554 
crop_seq_cmp_fn(Sequence * seq,void * arg_pt)555 static int crop_seq_cmp_fn(Sequence *seq, void *arg_pt)
556 {
557   SequenceSearchData *data = arg_pt;
558 
559   if (seq->strip && seq->strip->crop == data->data) {
560     data->seq = seq;
561     return -1; /* done so bail out */
562   }
563   return 1;
564 }
565 
sequence_get_by_crop(Editing * ed,StripCrop * crop)566 static Sequence *sequence_get_by_crop(Editing *ed, StripCrop *crop)
567 {
568   SequenceSearchData data;
569 
570   data.seq = NULL;
571   data.data = crop;
572 
573   /* irritating we need to search for our sequence! */
574   BKE_sequencer_base_recursive_apply(&ed->seqbase, crop_seq_cmp_fn, &data);
575 
576   return data.seq;
577 }
578 
rna_SequenceCrop_path(PointerRNA * ptr)579 static char *rna_SequenceCrop_path(PointerRNA *ptr)
580 {
581   Scene *scene = (Scene *)ptr->owner_id;
582   Editing *ed = BKE_sequencer_editing_get(scene, false);
583   Sequence *seq = sequence_get_by_crop(ed, ptr->data);
584 
585   if (seq && seq->name + 2) {
586     char name_esc[(sizeof(seq->name) - 2) * 2];
587 
588     BLI_strescape(name_esc, seq->name + 2, sizeof(name_esc));
589     return BLI_sprintfN("sequence_editor.sequences_all[\"%s\"].crop", name_esc);
590   }
591   else {
592     return BLI_strdup("");
593   }
594 }
595 
rna_SequenceCrop_update(Main * UNUSED (bmain),Scene * UNUSED (scene),PointerRNA * ptr)596 static void rna_SequenceCrop_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
597 {
598   Scene *scene = (Scene *)ptr->owner_id;
599   Editing *ed = BKE_sequencer_editing_get(scene, false);
600   Sequence *seq = sequence_get_by_crop(ed, ptr->data);
601 
602   BKE_sequence_invalidate_cache_preprocessed(scene, seq);
603 }
604 
rna_Sequence_text_font_set(PointerRNA * ptr,PointerRNA ptr_value,struct ReportList * UNUSED (reports))605 static void rna_Sequence_text_font_set(PointerRNA *ptr,
606                                        PointerRNA ptr_value,
607                                        struct ReportList *UNUSED(reports))
608 {
609   Sequence *seq = ptr->data;
610   TextVars *data = seq->effectdata;
611   VFont *value = ptr_value.data;
612 
613   BKE_sequencer_text_font_unload(data, true);
614 
615   id_us_plus(&value->id);
616   data->text_blf_id = SEQ_FONT_NOT_LOADED;
617   data->text_font = value;
618 }
619 
620 /* name functions that ignore the first two characters */
rna_Sequence_name_get(PointerRNA * ptr,char * value)621 static void rna_Sequence_name_get(PointerRNA *ptr, char *value)
622 {
623   Sequence *seq = (Sequence *)ptr->data;
624   BLI_strncpy(value, seq->name + 2, sizeof(seq->name) - 2);
625 }
626 
rna_Sequence_name_length(PointerRNA * ptr)627 static int rna_Sequence_name_length(PointerRNA *ptr)
628 {
629   Sequence *seq = (Sequence *)ptr->data;
630   return strlen(seq->name + 2);
631 }
632 
rna_Sequence_name_set(PointerRNA * ptr,const char * value)633 static void rna_Sequence_name_set(PointerRNA *ptr, const char *value)
634 {
635   Scene *scene = (Scene *)ptr->owner_id;
636   Sequence *seq = (Sequence *)ptr->data;
637   char oldname[sizeof(seq->name)];
638   AnimData *adt;
639 
640   BKE_sequencer_prefetch_stop(scene);
641 
642   /* make a copy of the old name first */
643   BLI_strncpy(oldname, seq->name + 2, sizeof(seq->name) - 2);
644 
645   /* copy the new name into the name slot */
646   BLI_strncpy_utf8(seq->name + 2, value, sizeof(seq->name) - 2);
647 
648   /* make sure the name is unique */
649   BKE_sequence_base_unique_name_recursive(&scene->ed->seqbase, seq);
650 
651   /* fix all the animation data which may link to this */
652 
653   /* Don't rename everywhere because these are per scene. */
654 #  if 0
655   BKE_animdata_fix_paths_rename_all(NULL, "sequence_editor.sequences_all", oldname, seq->name + 2);
656 #  endif
657   adt = BKE_animdata_from_id(&scene->id);
658   if (adt) {
659     BKE_animdata_fix_paths_rename(
660         &scene->id, adt, NULL, "sequence_editor.sequences_all", oldname, seq->name + 2, 0, 0, 1);
661   }
662 }
663 
rna_Sequence_refine(struct PointerRNA * ptr)664 static StructRNA *rna_Sequence_refine(struct PointerRNA *ptr)
665 {
666   Sequence *seq = (Sequence *)ptr->data;
667 
668   switch (seq->type) {
669     case SEQ_TYPE_IMAGE:
670       return &RNA_ImageSequence;
671     case SEQ_TYPE_META:
672       return &RNA_MetaSequence;
673     case SEQ_TYPE_SCENE:
674       return &RNA_SceneSequence;
675     case SEQ_TYPE_MOVIE:
676       return &RNA_MovieSequence;
677     case SEQ_TYPE_MOVIECLIP:
678       return &RNA_MovieClipSequence;
679     case SEQ_TYPE_MASK:
680       return &RNA_MaskSequence;
681     case SEQ_TYPE_SOUND_RAM:
682       return &RNA_SoundSequence;
683     case SEQ_TYPE_CROSS:
684       return &RNA_CrossSequence;
685     case SEQ_TYPE_ADD:
686       return &RNA_AddSequence;
687     case SEQ_TYPE_SUB:
688       return &RNA_SubtractSequence;
689     case SEQ_TYPE_ALPHAOVER:
690       return &RNA_AlphaOverSequence;
691     case SEQ_TYPE_ALPHAUNDER:
692       return &RNA_AlphaUnderSequence;
693     case SEQ_TYPE_GAMCROSS:
694       return &RNA_GammaCrossSequence;
695     case SEQ_TYPE_MUL:
696       return &RNA_MultiplySequence;
697     case SEQ_TYPE_OVERDROP:
698       return &RNA_OverDropSequence;
699     case SEQ_TYPE_MULTICAM:
700       return &RNA_MulticamSequence;
701     case SEQ_TYPE_ADJUSTMENT:
702       return &RNA_AdjustmentSequence;
703     case SEQ_TYPE_WIPE:
704       return &RNA_WipeSequence;
705     case SEQ_TYPE_GLOW:
706       return &RNA_GlowSequence;
707     case SEQ_TYPE_TRANSFORM:
708       return &RNA_TransformSequence;
709     case SEQ_TYPE_COLOR:
710       return &RNA_ColorSequence;
711     case SEQ_TYPE_SPEED:
712       return &RNA_SpeedControlSequence;
713     case SEQ_TYPE_GAUSSIAN_BLUR:
714       return &RNA_GaussianBlurSequence;
715     case SEQ_TYPE_TEXT:
716       return &RNA_TextSequence;
717     case SEQ_TYPE_COLORMIX:
718       return &RNA_ColorMixSequence;
719     default:
720       return &RNA_Sequence;
721   }
722 }
723 
rna_Sequence_path(PointerRNA * ptr)724 static char *rna_Sequence_path(PointerRNA *ptr)
725 {
726   Sequence *seq = (Sequence *)ptr->data;
727 
728   /* sequencer data comes from scene...
729    * TODO: would be nice to make SequenceEditor data a data-block of its own (for shorter paths)
730    */
731   if (seq->name + 2) {
732     char name_esc[(sizeof(seq->name) - 2) * 2];
733 
734     BLI_strescape(name_esc, seq->name + 2, sizeof(name_esc));
735     return BLI_sprintfN("sequence_editor.sequences_all[\"%s\"]", name_esc);
736   }
737   else {
738     return BLI_strdup("");
739   }
740 }
741 
rna_Sequence_idprops(PointerRNA * ptr,bool create)742 static IDProperty *rna_Sequence_idprops(PointerRNA *ptr, bool create)
743 {
744   Sequence *seq = ptr->data;
745 
746   if (create && !seq->prop) {
747     IDPropertyTemplate val = {0};
748     seq->prop = IDP_New(IDP_GROUP, &val, "Sequence ID properties");
749   }
750 
751   return seq->prop;
752 }
753 
rna_MovieSequence_reload_if_needed(ID * scene_id,Sequence * seq,Main * bmain)754 static bool rna_MovieSequence_reload_if_needed(ID *scene_id, Sequence *seq, Main *bmain)
755 {
756   Scene *scene = (Scene *)scene_id;
757   bool has_reloaded;
758   bool can_produce_frames;
759 
760   BKE_sequence_movie_reload_if_needed(bmain, scene, seq, &has_reloaded, &can_produce_frames);
761 
762   if (has_reloaded && can_produce_frames) {
763     BKE_sequence_calc(scene, seq);
764     BKE_sequence_invalidate_cache_raw(scene, seq);
765 
766     DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS);
767     WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, scene);
768   }
769 
770   return can_produce_frames;
771 }
772 
rna_MovieSequence_metadata_get(Sequence * seq)773 static PointerRNA rna_MovieSequence_metadata_get(Sequence *seq)
774 {
775   if (seq == NULL || seq->anims.first == NULL) {
776     return PointerRNA_NULL;
777   }
778 
779   StripAnim *sanim = seq->anims.first;
780   if (sanim->anim == NULL) {
781     return PointerRNA_NULL;
782   }
783 
784   IDProperty *metadata = IMB_anim_load_metadata(sanim->anim);
785   if (metadata == NULL) {
786     return PointerRNA_NULL;
787   }
788 
789   PointerRNA ptr;
790   RNA_pointer_create(NULL, &RNA_IDPropertyWrapPtr, metadata, &ptr);
791   return ptr;
792 }
793 
rna_SequenceEditor_meta_stack_get(CollectionPropertyIterator * iter)794 static PointerRNA rna_SequenceEditor_meta_stack_get(CollectionPropertyIterator *iter)
795 {
796   ListBaseIterator *internal = &iter->internal.listbase;
797   MetaStack *ms = (MetaStack *)internal->link;
798 
799   return rna_pointer_inherit_refine(&iter->parent, &RNA_Sequence, ms->parseq);
800 }
801 
802 /* TODO, expose seq path setting as a higher level sequencer BKE function */
rna_Sequence_filepath_set(PointerRNA * ptr,const char * value)803 static void rna_Sequence_filepath_set(PointerRNA *ptr, const char *value)
804 {
805   Sequence *seq = (Sequence *)(ptr->data);
806   BLI_split_dirfile(value,
807                     seq->strip->dir,
808                     seq->strip->stripdata->name,
809                     sizeof(seq->strip->dir),
810                     sizeof(seq->strip->stripdata->name));
811 }
812 
rna_Sequence_filepath_get(PointerRNA * ptr,char * value)813 static void rna_Sequence_filepath_get(PointerRNA *ptr, char *value)
814 {
815   Sequence *seq = (Sequence *)(ptr->data);
816 
817   BLI_join_dirfile(value, FILE_MAX, seq->strip->dir, seq->strip->stripdata->name);
818 }
819 
rna_Sequence_filepath_length(PointerRNA * ptr)820 static int rna_Sequence_filepath_length(PointerRNA *ptr)
821 {
822   Sequence *seq = (Sequence *)(ptr->data);
823   char path[FILE_MAX];
824 
825   BLI_join_dirfile(path, sizeof(path), seq->strip->dir, seq->strip->stripdata->name);
826   return strlen(path);
827 }
828 
rna_Sequence_proxy_filepath_set(PointerRNA * ptr,const char * value)829 static void rna_Sequence_proxy_filepath_set(PointerRNA *ptr, const char *value)
830 {
831   StripProxy *proxy = (StripProxy *)(ptr->data);
832   BLI_split_dirfile(value, proxy->dir, proxy->file, sizeof(proxy->dir), sizeof(proxy->file));
833   if (proxy->anim) {
834     IMB_free_anim(proxy->anim);
835     proxy->anim = NULL;
836   }
837 }
838 
rna_Sequence_proxy_filepath_get(PointerRNA * ptr,char * value)839 static void rna_Sequence_proxy_filepath_get(PointerRNA *ptr, char *value)
840 {
841   StripProxy *proxy = (StripProxy *)(ptr->data);
842 
843   BLI_join_dirfile(value, FILE_MAX, proxy->dir, proxy->file);
844 }
845 
rna_Sequence_proxy_filepath_length(PointerRNA * ptr)846 static int rna_Sequence_proxy_filepath_length(PointerRNA *ptr)
847 {
848   StripProxy *proxy = (StripProxy *)(ptr->data);
849   char path[FILE_MAX];
850 
851   BLI_join_dirfile(path, sizeof(path), proxy->dir, proxy->file);
852   return strlen(path);
853 }
854 
rna_Sequence_audio_update(Main * UNUSED (bmain),Scene * scene,PointerRNA * UNUSED (ptr))855 static void rna_Sequence_audio_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr))
856 {
857   DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS);
858 }
859 
rna_Sequence_input_count_get(PointerRNA * ptr)860 static int rna_Sequence_input_count_get(PointerRNA *ptr)
861 {
862   Sequence *seq = (Sequence *)(ptr->data);
863 
864   return BKE_sequence_effect_get_num_inputs(seq->type);
865 }
866 
rna_Sequence_input_set(PointerRNA * ptr,PointerRNA ptr_value,struct ReportList * reports,int input_num)867 static void rna_Sequence_input_set(PointerRNA *ptr,
868                                    PointerRNA ptr_value,
869                                    struct ReportList *reports,
870                                    int input_num)
871 {
872 
873   Sequence *seq = ptr->data;
874   Sequence *input = ptr_value.data;
875 
876   if (BKE_sequencer_render_loop_check(input, seq)) {
877     BKE_report(reports, RPT_ERROR, "Cannot reassign inputs: recursion detected");
878     return;
879   }
880 
881   switch (input_num) {
882     case 1:
883       seq->seq1 = input;
884       break;
885     case 2:
886       seq->seq2 = input;
887       break;
888   }
889 }
890 
rna_Sequence_input_1_set(PointerRNA * ptr,PointerRNA ptr_value,struct ReportList * reports)891 static void rna_Sequence_input_1_set(PointerRNA *ptr,
892                                      PointerRNA ptr_value,
893                                      struct ReportList *reports)
894 {
895   rna_Sequence_input_set(ptr, ptr_value, reports, 1);
896 }
897 
rna_Sequence_input_2_set(PointerRNA * ptr,PointerRNA ptr_value,struct ReportList * reports)898 static void rna_Sequence_input_2_set(PointerRNA *ptr,
899                                      PointerRNA ptr_value,
900                                      struct ReportList *reports)
901 {
902   rna_Sequence_input_set(ptr, ptr_value, reports, 2);
903 }
904 #  if 0
905 static void rna_SoundSequence_filename_set(PointerRNA *ptr, const char *value)
906 {
907   Sequence *seq = (Sequence *)(ptr->data);
908   BLI_split_dirfile(value,
909                     seq->strip->dir,
910                     seq->strip->stripdata->name,
911                     sizeof(seq->strip->dir),
912                     sizeof(seq->strip->stripdata->name));
913 }
914 
915 static void rna_SequenceElement_filename_set(PointerRNA *ptr, const char *value)
916 {
917   StripElem *elem = (StripElem *)(ptr->data);
918   BLI_split_file_part(value, elem->name, sizeof(elem->name));
919 }
920 #  endif
921 
rna_Sequence_reopen_files_update(Main * bmain,Scene * UNUSED (scene),PointerRNA * ptr)922 static void rna_Sequence_reopen_files_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
923 {
924   Scene *scene = (Scene *)ptr->owner_id;
925   Editing *ed = BKE_sequencer_editing_get(scene, false);
926 
927   BKE_sequencer_free_imbuf(scene, &ed->seqbase, false);
928   rna_Sequence_invalidate_raw_update(bmain, scene, ptr);
929 
930   if (RNA_struct_is_a(ptr->type, &RNA_SoundSequence)) {
931     BKE_sequencer_update_sound_bounds(scene, ptr->data);
932   }
933 }
934 
rna_Sequence_filepath_update(Main * bmain,Scene * UNUSED (scene),PointerRNA * ptr)935 static void rna_Sequence_filepath_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
936 {
937   Scene *scene = (Scene *)ptr->owner_id;
938   Sequence *seq = (Sequence *)(ptr->data);
939   BKE_sequence_reload_new_file(bmain, scene, seq, true);
940   BKE_sequence_calc(scene, seq);
941   rna_Sequence_invalidate_raw_update(bmain, scene, ptr);
942 }
943 
rna_Sequence_sound_update(Main * UNUSED (bmain),Scene * scene,PointerRNA * UNUSED (ptr))944 static void rna_Sequence_sound_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr))
945 {
946   DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS | ID_RECALC_AUDIO);
947 }
948 
seqproxy_seq_cmp_fn(Sequence * seq,void * arg_pt)949 static int seqproxy_seq_cmp_fn(Sequence *seq, void *arg_pt)
950 {
951   SequenceSearchData *data = arg_pt;
952 
953   if (seq->strip && seq->strip->proxy == data->data) {
954     data->seq = seq;
955     return -1; /* done so bail out */
956   }
957   return 1;
958 }
959 
sequence_get_by_proxy(Editing * ed,StripProxy * proxy)960 static Sequence *sequence_get_by_proxy(Editing *ed, StripProxy *proxy)
961 {
962   SequenceSearchData data;
963 
964   data.seq = NULL;
965   data.data = proxy;
966 
967   BKE_sequencer_base_recursive_apply(&ed->seqbase, seqproxy_seq_cmp_fn, &data);
968   return data.seq;
969 }
970 
rna_Sequence_tcindex_update(Main * bmain,Scene * UNUSED (scene),PointerRNA * ptr)971 static void rna_Sequence_tcindex_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
972 {
973   Scene *scene = (Scene *)ptr->owner_id;
974   Editing *ed = BKE_sequencer_editing_get(scene, false);
975   Sequence *seq = sequence_get_by_proxy(ed, ptr->data);
976 
977   BKE_sequence_reload_new_file(bmain, scene, seq, false);
978   do_sequence_frame_change_update(scene, seq);
979 }
980 
rna_SequenceProxy_update(Main * UNUSED (bmain),Scene * UNUSED (scene),PointerRNA * ptr)981 static void rna_SequenceProxy_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
982 {
983   Scene *scene = (Scene *)ptr->owner_id;
984   Editing *ed = BKE_sequencer_editing_get(scene, false);
985   Sequence *seq = sequence_get_by_proxy(ed, ptr->data);
986 
987   BKE_sequence_invalidate_cache_raw(scene, seq);
988 }
989 
990 /* do_versions? */
rna_Sequence_opacity_get(PointerRNA * ptr)991 static float rna_Sequence_opacity_get(PointerRNA *ptr)
992 {
993   Sequence *seq = (Sequence *)(ptr->data);
994   return seq->blend_opacity / 100.0f;
995 }
rna_Sequence_opacity_set(PointerRNA * ptr,float value)996 static void rna_Sequence_opacity_set(PointerRNA *ptr, float value)
997 {
998   Sequence *seq = (Sequence *)(ptr->data);
999   CLAMP(value, 0.0f, 1.0f);
1000   seq->blend_opacity = value * 100.0f;
1001 }
1002 
colbalance_seq_cmp_fn(Sequence * seq,void * arg_pt)1003 static int colbalance_seq_cmp_fn(Sequence *seq, void *arg_pt)
1004 {
1005   SequenceSearchData *data = arg_pt;
1006 
1007   if (seq->modifiers.first) {
1008     SequenceModifierData *smd = seq->modifiers.first;
1009 
1010     for (smd = seq->modifiers.first; smd; smd = smd->next) {
1011       if (smd->type == seqModifierType_ColorBalance) {
1012         ColorBalanceModifierData *cbmd = (ColorBalanceModifierData *)smd;
1013 
1014         if (&cbmd->color_balance == data->data) {
1015           data->seq = seq;
1016           data->smd = smd;
1017           return -1; /* done so bail out */
1018         }
1019       }
1020     }
1021   }
1022 
1023   return 1;
1024 }
1025 
sequence_get_by_colorbalance(Editing * ed,StripColorBalance * cb,SequenceModifierData ** r_smd)1026 static Sequence *sequence_get_by_colorbalance(Editing *ed,
1027                                               StripColorBalance *cb,
1028                                               SequenceModifierData **r_smd)
1029 {
1030   SequenceSearchData data;
1031 
1032   data.seq = NULL;
1033   data.smd = NULL;
1034   data.data = cb;
1035 
1036   /* irritating we need to search for our sequence! */
1037   BKE_sequencer_base_recursive_apply(&ed->seqbase, colbalance_seq_cmp_fn, &data);
1038 
1039   *r_smd = data.smd;
1040 
1041   return data.seq;
1042 }
1043 
rna_SequenceColorBalance_path(PointerRNA * ptr)1044 static char *rna_SequenceColorBalance_path(PointerRNA *ptr)
1045 {
1046   Scene *scene = (Scene *)ptr->owner_id;
1047   SequenceModifierData *smd;
1048   Editing *ed = BKE_sequencer_editing_get(scene, false);
1049   Sequence *seq = sequence_get_by_colorbalance(ed, ptr->data, &smd);
1050 
1051   if (seq && seq->name + 2) {
1052     char name_esc[(sizeof(seq->name) - 2) * 2];
1053 
1054     BLI_strescape(name_esc, seq->name + 2, sizeof(name_esc));
1055 
1056     if (!smd) {
1057       /* path to old filter color balance */
1058       return BLI_sprintfN("sequence_editor.sequences_all[\"%s\"].color_balance", name_esc);
1059     }
1060     else {
1061       /* path to modifier */
1062       char name_esc_smd[sizeof(smd->name) * 2];
1063 
1064       BLI_strescape(name_esc_smd, smd->name, sizeof(name_esc_smd));
1065       return BLI_sprintfN("sequence_editor.sequences_all[\"%s\"].modifiers[\"%s\"].color_balance",
1066                           name_esc,
1067                           name_esc_smd);
1068     }
1069   }
1070   else {
1071     return BLI_strdup("");
1072   }
1073 }
1074 
rna_SequenceColorBalance_update(Main * UNUSED (bmain),Scene * UNUSED (scene),PointerRNA * ptr)1075 static void rna_SequenceColorBalance_update(Main *UNUSED(bmain),
1076                                             Scene *UNUSED(scene),
1077                                             PointerRNA *ptr)
1078 {
1079   Scene *scene = (Scene *)ptr->owner_id;
1080   Editing *ed = BKE_sequencer_editing_get(scene, false);
1081   SequenceModifierData *smd;
1082   Sequence *seq = sequence_get_by_colorbalance(ed, ptr->data, &smd);
1083 
1084   BKE_sequence_invalidate_cache_preprocessed(scene, seq);
1085 }
1086 
rna_SequenceEditor_overlay_lock_set(PointerRNA * ptr,bool value)1087 static void rna_SequenceEditor_overlay_lock_set(PointerRNA *ptr, bool value)
1088 {
1089   Scene *scene = (Scene *)ptr->owner_id;
1090   Editing *ed = BKE_sequencer_editing_get(scene, false);
1091 
1092   if (ed == NULL) {
1093     return;
1094   }
1095 
1096   /* convert from abs to relative and back */
1097   if ((ed->over_flag & SEQ_EDIT_OVERLAY_ABS) == 0 && value) {
1098     ed->over_cfra = scene->r.cfra + ed->over_ofs;
1099     ed->over_flag |= SEQ_EDIT_OVERLAY_ABS;
1100   }
1101   else if ((ed->over_flag & SEQ_EDIT_OVERLAY_ABS) && !value) {
1102     ed->over_ofs = ed->over_cfra - scene->r.cfra;
1103     ed->over_flag &= ~SEQ_EDIT_OVERLAY_ABS;
1104   }
1105 }
1106 
rna_SequenceEditor_overlay_frame_get(PointerRNA * ptr)1107 static int rna_SequenceEditor_overlay_frame_get(PointerRNA *ptr)
1108 {
1109   Scene *scene = (Scene *)ptr->owner_id;
1110   Editing *ed = BKE_sequencer_editing_get(scene, false);
1111 
1112   if (ed == NULL) {
1113     return scene->r.cfra;
1114   }
1115 
1116   if (ed->over_flag & SEQ_EDIT_OVERLAY_ABS) {
1117     return ed->over_cfra - scene->r.cfra;
1118   }
1119   else {
1120     return ed->over_ofs;
1121   }
1122 }
1123 
rna_SequenceEditor_overlay_frame_set(PointerRNA * ptr,int value)1124 static void rna_SequenceEditor_overlay_frame_set(PointerRNA *ptr, int value)
1125 {
1126   Scene *scene = (Scene *)ptr->owner_id;
1127   Editing *ed = BKE_sequencer_editing_get(scene, false);
1128 
1129   if (ed == NULL) {
1130     return;
1131   }
1132 
1133   if (ed->over_flag & SEQ_EDIT_OVERLAY_ABS) {
1134     ed->over_cfra = (scene->r.cfra + value);
1135   }
1136   else {
1137     ed->over_ofs = value;
1138   }
1139 }
1140 
modifier_seq_cmp_fn(Sequence * seq,void * arg_pt)1141 static int modifier_seq_cmp_fn(Sequence *seq, void *arg_pt)
1142 {
1143   SequenceSearchData *data = arg_pt;
1144 
1145   if (BLI_findindex(&seq->modifiers, data->data) != -1) {
1146     data->seq = seq;
1147     return -1; /* done so bail out */
1148   }
1149 
1150   return 1;
1151 }
1152 
sequence_get_by_modifier(Editing * ed,SequenceModifierData * smd)1153 static Sequence *sequence_get_by_modifier(Editing *ed, SequenceModifierData *smd)
1154 {
1155   SequenceSearchData data;
1156 
1157   data.seq = NULL;
1158   data.data = smd;
1159 
1160   /* irritating we need to search for our sequence! */
1161   BKE_sequencer_base_recursive_apply(&ed->seqbase, modifier_seq_cmp_fn, &data);
1162 
1163   return data.seq;
1164 }
1165 
rna_SequenceModifier_refine(struct PointerRNA * ptr)1166 static StructRNA *rna_SequenceModifier_refine(struct PointerRNA *ptr)
1167 {
1168   SequenceModifierData *smd = (SequenceModifierData *)ptr->data;
1169 
1170   switch (smd->type) {
1171     case seqModifierType_ColorBalance:
1172       return &RNA_ColorBalanceModifier;
1173     case seqModifierType_Curves:
1174       return &RNA_CurvesModifier;
1175     case seqModifierType_HueCorrect:
1176       return &RNA_HueCorrectModifier;
1177     case seqModifierType_BrightContrast:
1178       return &RNA_BrightContrastModifier;
1179     case seqModifierType_WhiteBalance:
1180       return &RNA_WhiteBalanceModifier;
1181     case seqModifierType_Tonemap:
1182       return &RNA_SequencerTonemapModifierData;
1183     default:
1184       return &RNA_SequenceModifier;
1185   }
1186 }
1187 
rna_SequenceModifier_path(PointerRNA * ptr)1188 static char *rna_SequenceModifier_path(PointerRNA *ptr)
1189 {
1190   Scene *scene = (Scene *)ptr->owner_id;
1191   Editing *ed = BKE_sequencer_editing_get(scene, false);
1192   SequenceModifierData *smd = ptr->data;
1193   Sequence *seq = sequence_get_by_modifier(ed, smd);
1194 
1195   if (seq && seq->name + 2) {
1196     char name_esc[(sizeof(seq->name) - 2) * 2];
1197     char name_esc_smd[sizeof(smd->name) * 2];
1198 
1199     BLI_strescape(name_esc, seq->name + 2, sizeof(name_esc));
1200     BLI_strescape(name_esc_smd, smd->name, sizeof(name_esc_smd));
1201     return BLI_sprintfN(
1202         "sequence_editor.sequences_all[\"%s\"].modifiers[\"%s\"]", name_esc, name_esc_smd);
1203   }
1204   else {
1205     return BLI_strdup("");
1206   }
1207 }
1208 
rna_SequenceModifier_name_set(PointerRNA * ptr,const char * value)1209 static void rna_SequenceModifier_name_set(PointerRNA *ptr, const char *value)
1210 {
1211   SequenceModifierData *smd = ptr->data;
1212   Scene *scene = (Scene *)ptr->owner_id;
1213   Editing *ed = BKE_sequencer_editing_get(scene, false);
1214   Sequence *seq = sequence_get_by_modifier(ed, smd);
1215   AnimData *adt;
1216   char oldname[sizeof(smd->name)];
1217 
1218   /* make a copy of the old name first */
1219   BLI_strncpy(oldname, smd->name, sizeof(smd->name));
1220 
1221   /* copy the new name into the name slot */
1222   BLI_strncpy_utf8(smd->name, value, sizeof(smd->name));
1223 
1224   /* make sure the name is truly unique */
1225   BKE_sequence_modifier_unique_name(seq, smd);
1226 
1227   /* fix all the animation data which may link to this */
1228   adt = BKE_animdata_from_id(&scene->id);
1229   if (adt) {
1230     char path[1024];
1231 
1232     BLI_snprintf(
1233         path, sizeof(path), "sequence_editor.sequences_all[\"%s\"].modifiers", seq->name + 2);
1234     BKE_animdata_fix_paths_rename(&scene->id, adt, NULL, path, oldname, smd->name, 0, 0, 1);
1235   }
1236 }
1237 
rna_SequenceModifier_update(Main * UNUSED (bmain),Scene * UNUSED (scene),PointerRNA * ptr)1238 static void rna_SequenceModifier_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
1239 {
1240   /* strip from other scenes could be modified, so using active scene is not reliable */
1241   Scene *scene = (Scene *)ptr->owner_id;
1242   Editing *ed = BKE_sequencer_editing_get(scene, false);
1243   Sequence *seq = sequence_get_by_modifier(ed, ptr->data);
1244 
1245   BKE_sequence_invalidate_cache_preprocessed(scene, seq);
1246 }
1247 
rna_SequenceModifier_otherSequence_poll(PointerRNA * ptr,PointerRNA value)1248 static bool rna_SequenceModifier_otherSequence_poll(PointerRNA *ptr, PointerRNA value)
1249 {
1250   Scene *scene = (Scene *)ptr->owner_id;
1251   Editing *ed = BKE_sequencer_editing_get(scene, false);
1252   Sequence *seq = sequence_get_by_modifier(ed, ptr->data);
1253   Sequence *cur = (Sequence *)value.data;
1254 
1255   if ((seq == cur) || (cur->type == SEQ_TYPE_SOUND_RAM)) {
1256     return false;
1257   }
1258 
1259   return true;
1260 }
1261 
rna_Sequence_modifier_new(Sequence * seq,bContext * C,ReportList * reports,const char * name,int type)1262 static SequenceModifierData *rna_Sequence_modifier_new(
1263     Sequence *seq, bContext *C, ReportList *reports, const char *name, int type)
1264 {
1265   if (!BKE_sequence_supports_modifiers(seq)) {
1266     BKE_report(reports, RPT_ERROR, "Sequence type does not support modifiers");
1267 
1268     return NULL;
1269   }
1270   else {
1271     Scene *scene = CTX_data_scene(C);
1272     SequenceModifierData *smd;
1273 
1274     smd = BKE_sequence_modifier_new(seq, name, type);
1275 
1276     BKE_sequence_invalidate_cache_preprocessed(scene, seq);
1277 
1278     WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, NULL);
1279 
1280     return smd;
1281   }
1282 }
1283 
rna_Sequence_modifier_remove(Sequence * seq,bContext * C,ReportList * reports,PointerRNA * smd_ptr)1284 static void rna_Sequence_modifier_remove(Sequence *seq,
1285                                          bContext *C,
1286                                          ReportList *reports,
1287                                          PointerRNA *smd_ptr)
1288 {
1289   SequenceModifierData *smd = smd_ptr->data;
1290   Scene *scene = CTX_data_scene(C);
1291 
1292   if (BKE_sequence_modifier_remove(seq, smd) == false) {
1293     BKE_report(reports, RPT_ERROR, "Modifier was not found in the stack");
1294     return;
1295   }
1296 
1297   RNA_POINTER_INVALIDATE(smd_ptr);
1298   BKE_sequence_invalidate_cache_preprocessed(scene, seq);
1299 
1300   WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, NULL);
1301 }
1302 
rna_Sequence_modifier_clear(Sequence * seq,bContext * C)1303 static void rna_Sequence_modifier_clear(Sequence *seq, bContext *C)
1304 {
1305   Scene *scene = CTX_data_scene(C);
1306 
1307   BKE_sequence_modifier_clear(seq);
1308 
1309   BKE_sequence_invalidate_cache_preprocessed(scene, seq);
1310 
1311   WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, NULL);
1312 }
1313 
rna_SequenceModifier_strip_set(PointerRNA * ptr,PointerRNA value,struct ReportList * reports)1314 static void rna_SequenceModifier_strip_set(PointerRNA *ptr,
1315                                            PointerRNA value,
1316                                            struct ReportList *reports)
1317 {
1318   SequenceModifierData *smd = ptr->data;
1319   Scene *scene = (Scene *)ptr->owner_id;
1320   Editing *ed = BKE_sequencer_editing_get(scene, false);
1321   Sequence *seq = sequence_get_by_modifier(ed, smd);
1322   Sequence *target = (Sequence *)value.data;
1323 
1324   if (target != NULL && BKE_sequencer_render_loop_check(target, seq)) {
1325     BKE_report(reports, RPT_ERROR, "Recursion detected, can not use this strip");
1326     return;
1327   }
1328 
1329   smd->mask_sequence = target;
1330 }
1331 
rna_Sequence_fps_get(PointerRNA * ptr)1332 static float rna_Sequence_fps_get(PointerRNA *ptr)
1333 {
1334   Scene *scene = (Scene *)ptr->owner_id;
1335   Sequence *seq = (Sequence *)(ptr->data);
1336   return BKE_sequence_get_fps(scene, seq);
1337 }
1338 
1339 #else
1340 
rna_def_strip_element(BlenderRNA * brna)1341 static void rna_def_strip_element(BlenderRNA *brna)
1342 {
1343   StructRNA *srna;
1344   PropertyRNA *prop;
1345 
1346   srna = RNA_def_struct(brna, "SequenceElement", NULL);
1347   RNA_def_struct_ui_text(srna, "Sequence Element", "Sequence strip data for a single frame");
1348   RNA_def_struct_sdna(srna, "StripElem");
1349 
1350   prop = RNA_def_property(srna, "filename", PROP_STRING, PROP_FILENAME);
1351   RNA_def_property_string_sdna(prop, NULL, "name");
1352   RNA_def_property_ui_text(prop, "Filename", "Name of the source file");
1353   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceElement_update");
1354 
1355   prop = RNA_def_property(srna, "orig_width", PROP_INT, PROP_NONE);
1356   RNA_def_property_int_sdna(prop, NULL, "orig_width");
1357   RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1358   RNA_def_property_ui_text(prop, "Orig Width", "Original image width");
1359 
1360   prop = RNA_def_property(srna, "orig_height", PROP_INT, PROP_NONE);
1361   RNA_def_property_int_sdna(prop, NULL, "orig_height");
1362   RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1363   RNA_def_property_ui_text(prop, "Orig Height", "Original image height");
1364 }
1365 
rna_def_strip_crop(BlenderRNA * brna)1366 static void rna_def_strip_crop(BlenderRNA *brna)
1367 {
1368   StructRNA *srna;
1369   PropertyRNA *prop;
1370 
1371   srna = RNA_def_struct(brna, "SequenceCrop", NULL);
1372   RNA_def_struct_ui_text(srna, "Sequence Crop", "Cropping parameters for a sequence strip");
1373   RNA_def_struct_sdna(srna, "StripCrop");
1374 
1375   prop = RNA_def_property(srna, "max_y", PROP_INT, PROP_PIXEL);
1376   RNA_def_property_int_sdna(prop, NULL, "top");
1377   RNA_def_property_ui_text(prop, "Top", "Number of pixels to crop from the top");
1378   RNA_def_property_ui_range(prop, 0, 4096, 1, -1);
1379   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceCrop_update");
1380 
1381   prop = RNA_def_property(srna, "min_y", PROP_INT, PROP_PIXEL);
1382   RNA_def_property_int_sdna(prop, NULL, "bottom");
1383   RNA_def_property_ui_text(prop, "Bottom", "Number of pixels to crop from the bottom");
1384   RNA_def_property_ui_range(prop, 0, 4096, 1, -1);
1385   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceCrop_update");
1386 
1387   prop = RNA_def_property(srna, "min_x", PROP_INT, PROP_PIXEL);
1388   RNA_def_property_int_sdna(prop, NULL, "left");
1389   RNA_def_property_ui_text(prop, "Left", "Number of pixels to crop from the left side");
1390   RNA_def_property_ui_range(prop, 0, 4096, 1, -1);
1391   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceCrop_update");
1392 
1393   prop = RNA_def_property(srna, "max_x", PROP_INT, PROP_PIXEL);
1394   RNA_def_property_int_sdna(prop, NULL, "right");
1395   RNA_def_property_ui_text(prop, "Right", "Number of pixels to crop from the right side");
1396   RNA_def_property_ui_range(prop, 0, 4096, 1, -1);
1397   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceCrop_update");
1398 
1399   RNA_def_struct_path_func(srna, "rna_SequenceCrop_path");
1400 }
1401 
rna_def_strip_transform(BlenderRNA * brna)1402 static void rna_def_strip_transform(BlenderRNA *brna)
1403 {
1404   StructRNA *srna;
1405   PropertyRNA *prop;
1406 
1407   srna = RNA_def_struct(brna, "SequenceTransform", NULL);
1408   RNA_def_struct_ui_text(srna, "Sequence Transform", "Transform parameters for a sequence strip");
1409   RNA_def_struct_sdna(srna, "StripTransform");
1410 
1411   prop = RNA_def_property(srna, "offset_x", PROP_INT, PROP_PIXEL);
1412   RNA_def_property_int_sdna(prop, NULL, "xofs");
1413   RNA_def_property_ui_text(
1414       prop, "Offset X", "Amount to move the input on the X axis within its boundaries");
1415   RNA_def_property_ui_range(prop, -4096, 4096, 1, -1);
1416   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceTransform_update");
1417 
1418   prop = RNA_def_property(srna, "offset_y", PROP_INT, PROP_PIXEL);
1419   RNA_def_property_int_sdna(prop, NULL, "yofs");
1420   RNA_def_property_ui_text(
1421       prop, "Offset Y", "Amount to move the input on the Y axis within its boundaries");
1422   RNA_def_property_ui_range(prop, -4096, 4096, 1, -1);
1423   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceTransform_update");
1424 
1425   RNA_def_struct_path_func(srna, "rna_SequenceTransform_path");
1426 }
1427 
rna_def_strip_proxy(BlenderRNA * brna)1428 static void rna_def_strip_proxy(BlenderRNA *brna)
1429 {
1430   StructRNA *srna;
1431   PropertyRNA *prop;
1432 
1433   static const EnumPropertyItem seq_tc_items[] = {
1434       {SEQ_PROXY_TC_NONE, "NONE", 0, "No TC in use", ""},
1435       {SEQ_PROXY_TC_RECORD_RUN,
1436        "RECORD_RUN",
1437        0,
1438        "Record Run",
1439        "Use images in the order as they are recorded"},
1440       {SEQ_PROXY_TC_FREE_RUN,
1441        "FREE_RUN",
1442        0,
1443        "Free Run",
1444        "Use global timestamp written by recording device"},
1445       {SEQ_PROXY_TC_INTERP_REC_DATE_FREE_RUN,
1446        "FREE_RUN_REC_DATE",
1447        0,
1448        "Free Run (rec date)",
1449        "Interpolate a global timestamp using the "
1450        "record date and time written by recording device"},
1451       {SEQ_PROXY_TC_RECORD_RUN_NO_GAPS,
1452        "RECORD_RUN_NO_GAPS",
1453        0,
1454        "Record Run No Gaps",
1455        "Like record run, but ignore timecode, "
1456        "changes in framerate or dropouts"},
1457       {0, NULL, 0, NULL, NULL},
1458   };
1459 
1460   srna = RNA_def_struct(brna, "SequenceProxy", NULL);
1461   RNA_def_struct_ui_text(srna, "Sequence Proxy", "Proxy parameters for a sequence strip");
1462   RNA_def_struct_sdna(srna, "StripProxy");
1463 
1464   prop = RNA_def_property(srna, "directory", PROP_STRING, PROP_DIRPATH);
1465   RNA_def_property_string_sdna(prop, NULL, "dir");
1466   RNA_def_property_ui_text(prop, "Directory", "Location to store the proxy files");
1467   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceProxy_update");
1468 
1469   prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH);
1470   RNA_def_property_ui_text(prop, "Path", "Location of custom proxy file");
1471   RNA_def_property_string_funcs(prop,
1472                                 "rna_Sequence_proxy_filepath_get",
1473                                 "rna_Sequence_proxy_filepath_length",
1474                                 "rna_Sequence_proxy_filepath_set");
1475 
1476   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceProxy_update");
1477 
1478   prop = RNA_def_property(srna, "use_overwrite", PROP_BOOLEAN, PROP_NONE);
1479   RNA_def_property_boolean_negative_sdna(prop, NULL, "build_flags", SEQ_PROXY_SKIP_EXISTING);
1480   RNA_def_property_ui_text(prop, "Overwrite", "Overwrite existing proxy files when building");
1481 
1482   prop = RNA_def_property(srna, "build_25", PROP_BOOLEAN, PROP_NONE);
1483   RNA_def_property_boolean_sdna(prop, NULL, "build_size_flags", SEQ_PROXY_IMAGE_SIZE_25);
1484   RNA_def_property_ui_text(prop, "25%", "Build 25% proxy resolution");
1485 
1486   prop = RNA_def_property(srna, "build_50", PROP_BOOLEAN, PROP_NONE);
1487   RNA_def_property_boolean_sdna(prop, NULL, "build_size_flags", SEQ_PROXY_IMAGE_SIZE_50);
1488   RNA_def_property_ui_text(prop, "50%", "Build 50% proxy resolution");
1489 
1490   prop = RNA_def_property(srna, "build_75", PROP_BOOLEAN, PROP_NONE);
1491   RNA_def_property_boolean_sdna(prop, NULL, "build_size_flags", SEQ_PROXY_IMAGE_SIZE_75);
1492   RNA_def_property_ui_text(prop, "75%", "Build 75% proxy resolution");
1493 
1494   prop = RNA_def_property(srna, "build_100", PROP_BOOLEAN, PROP_NONE);
1495   RNA_def_property_boolean_sdna(prop, NULL, "build_size_flags", SEQ_PROXY_IMAGE_SIZE_100);
1496   RNA_def_property_ui_text(prop, "100%", "Build 100% proxy resolution");
1497 
1498   prop = RNA_def_property(srna, "build_record_run", PROP_BOOLEAN, PROP_NONE);
1499   RNA_def_property_boolean_sdna(prop, NULL, "build_tc_flags", SEQ_PROXY_TC_RECORD_RUN);
1500   RNA_def_property_ui_text(prop, "Rec Run", "Build record run time code index");
1501 
1502   prop = RNA_def_property(srna, "build_free_run", PROP_BOOLEAN, PROP_NONE);
1503   RNA_def_property_boolean_sdna(prop, NULL, "build_tc_flags", SEQ_PROXY_TC_FREE_RUN);
1504   RNA_def_property_ui_text(prop, "Free Run", "Build free run time code index");
1505 
1506   prop = RNA_def_property(srna, "build_free_run_rec_date", PROP_BOOLEAN, PROP_NONE);
1507   RNA_def_property_boolean_sdna(
1508       prop, NULL, "build_tc_flags", SEQ_PROXY_TC_INTERP_REC_DATE_FREE_RUN);
1509   RNA_def_property_ui_text(
1510       prop, "Free Run (Rec Date)", "Build free run time code index using Record Date/Time");
1511 
1512   prop = RNA_def_property(srna, "quality", PROP_INT, PROP_UNSIGNED);
1513   RNA_def_property_int_sdna(prop, NULL, "quality");
1514   RNA_def_property_ui_text(prop, "Quality", "JPEG Quality of proxies to build");
1515   RNA_def_property_ui_range(prop, 1, 100, 1, -1);
1516 
1517   prop = RNA_def_property(srna, "timecode", PROP_ENUM, PROP_NONE);
1518   RNA_def_property_enum_sdna(prop, NULL, "tc");
1519   RNA_def_property_enum_items(prop, seq_tc_items);
1520   RNA_def_property_ui_text(prop, "Timecode", "Method for reading the inputs timecode");
1521   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_tcindex_update");
1522 
1523   prop = RNA_def_property(srna, "use_proxy_custom_directory", PROP_BOOLEAN, PROP_NONE);
1524   RNA_def_property_boolean_sdna(prop, NULL, "storage", SEQ_STORAGE_PROXY_CUSTOM_DIR);
1525   RNA_def_property_ui_text(prop, "Proxy Custom Directory", "Use a custom directory to store data");
1526   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
1527 
1528   prop = RNA_def_property(srna, "use_proxy_custom_file", PROP_BOOLEAN, PROP_NONE);
1529   RNA_def_property_boolean_sdna(prop, NULL, "storage", SEQ_STORAGE_PROXY_CUSTOM_FILE);
1530   RNA_def_property_ui_text(prop, "Proxy Custom File", "Use a custom file to read proxy data from");
1531   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
1532 }
1533 
rna_def_color_balance(BlenderRNA * brna)1534 static void rna_def_color_balance(BlenderRNA *brna)
1535 {
1536   StructRNA *srna;
1537   PropertyRNA *prop;
1538 
1539   srna = RNA_def_struct(brna, "SequenceColorBalanceData", NULL);
1540   RNA_def_struct_ui_text(srna,
1541                          "Sequence Color Balance Data",
1542                          "Color balance parameters for a sequence strip and its modifiers");
1543   RNA_def_struct_sdna(srna, "StripColorBalance");
1544 
1545   prop = RNA_def_property(srna, "lift", PROP_FLOAT, PROP_COLOR_GAMMA);
1546   RNA_def_property_ui_text(prop, "Lift", "Color balance lift (shadows)");
1547   RNA_def_property_ui_range(prop, 0, 2, 0.1, 3);
1548   RNA_def_property_float_default(prop, 1.0f);
1549   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceColorBalance_update");
1550 
1551   prop = RNA_def_property(srna, "gamma", PROP_FLOAT, PROP_COLOR_GAMMA);
1552   RNA_def_property_ui_text(prop, "Gamma", "Color balance gamma (midtones)");
1553   RNA_def_property_ui_range(prop, 0, 2, 0.1, 3);
1554   RNA_def_property_float_default(prop, 1.0f);
1555   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceColorBalance_update");
1556 
1557   prop = RNA_def_property(srna, "gain", PROP_FLOAT, PROP_COLOR_GAMMA);
1558   RNA_def_property_ui_text(prop, "Gain", "Color balance gain (highlights)");
1559   RNA_def_property_ui_range(prop, 0, 2, 0.1, 3);
1560   RNA_def_property_float_default(prop, 1.0f);
1561   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceColorBalance_update");
1562 
1563   prop = RNA_def_property(srna, "invert_gain", PROP_BOOLEAN, PROP_NONE);
1564   RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_COLOR_BALANCE_INVERSE_GAIN);
1565   RNA_def_property_ui_text(prop, "Inverse Gain", "Invert the gain color`");
1566   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceColorBalance_update");
1567 
1568   prop = RNA_def_property(srna, "invert_gamma", PROP_BOOLEAN, PROP_NONE);
1569   RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_COLOR_BALANCE_INVERSE_GAMMA);
1570   RNA_def_property_ui_text(prop, "Inverse Gamma", "Invert the gamma color");
1571   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceColorBalance_update");
1572 
1573   prop = RNA_def_property(srna, "invert_lift", PROP_BOOLEAN, PROP_NONE);
1574   RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_COLOR_BALANCE_INVERSE_LIFT);
1575   RNA_def_property_ui_text(prop, "Inverse Lift", "Invert the lift color");
1576   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceColorBalance_update");
1577 
1578   /* not yet used */
1579 #  if 0
1580   prop = RNA_def_property(srna, "exposure", PROP_FLOAT, PROP_NONE);
1581   RNA_def_property_range(prop, 0.0f, 1.0f);
1582   RNA_def_property_ui_text(prop, "Exposure", "");
1583   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_ColorBabalnce_update");
1584 
1585   prop = RNA_def_property(srna, "saturation", PROP_FLOAT, PROP_NONE);
1586   RNA_def_property_range(prop, 0.0f, 1.0f);
1587   RNA_def_property_ui_text(prop, "Saturation", "");
1588   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_ColorBabalnce_update");
1589 #  endif
1590 
1591   RNA_def_struct_path_func(srna, "rna_SequenceColorBalance_path");
1592 }
1593 
rna_def_strip_color_balance(BlenderRNA * brna)1594 static void rna_def_strip_color_balance(BlenderRNA *brna)
1595 {
1596   StructRNA *srna;
1597 
1598   srna = RNA_def_struct(brna, "SequenceColorBalance", "SequenceColorBalanceData");
1599   RNA_def_struct_ui_text(
1600       srna, "Sequence Color Balance", "Color balance parameters for a sequence strip");
1601   RNA_def_struct_sdna(srna, "StripColorBalance");
1602 }
1603 
1604 static const EnumPropertyItem blend_mode_items[] = {
1605     {SEQ_BLEND_REPLACE, "REPLACE", 0, "Replace", ""},
1606     {SEQ_TYPE_CROSS, "CROSS", 0, "Cross", ""},
1607     {0, "", ICON_NONE, NULL, NULL},
1608     {SEQ_TYPE_DARKEN, "DARKEN", 0, "Darken", ""},
1609     {SEQ_TYPE_MUL, "MULTIPLY", 0, "Multiply", ""},
1610     {SEQ_TYPE_COLOR_BURN, "BURN", 0, "Color Burn", ""},
1611     {SEQ_TYPE_LINEAR_BURN, "LINEAR_BURN", 0, "Linear Burn", ""},
1612     {0, "", ICON_NONE, NULL, NULL},
1613     {SEQ_TYPE_LIGHTEN, "LIGHTEN", 0, "Lighten", ""},
1614     {SEQ_TYPE_SCREEN, "SCREEN", 0, "Screen", ""},
1615     {SEQ_TYPE_DODGE, "DODGE", 0, "Color Dodge", ""},
1616     {SEQ_TYPE_ADD, "ADD", 0, "Add", ""},
1617     {0, "", ICON_NONE, NULL, NULL},
1618     {SEQ_TYPE_OVERLAY, "OVERLAY", 0, "Overlay", ""},
1619     {SEQ_TYPE_SOFT_LIGHT, "SOFT_LIGHT", 0, "Soft Light", ""},
1620     {SEQ_TYPE_HARD_LIGHT, "HARD_LIGHT", 0, "Hard Light", ""},
1621     {SEQ_TYPE_VIVID_LIGHT, "VIVID_LIGHT", 0, "Vivid Light", ""},
1622     {SEQ_TYPE_LIN_LIGHT, "LINEAR_LIGHT", 0, "Linear Light", ""},
1623     {SEQ_TYPE_PIN_LIGHT, "PIN_LIGHT", 0, "Pin Light", ""},
1624     {0, "", ICON_NONE, NULL, NULL},
1625     {SEQ_TYPE_DIFFERENCE, "DIFFERENCE", 0, "Difference", ""},
1626     {SEQ_TYPE_EXCLUSION, "EXCLUSION", 0, "Exclusion", ""},
1627     {SEQ_TYPE_SUB, "SUBTRACT", 0, "Subtract", ""},
1628     {0, "", ICON_NONE, NULL, NULL},
1629     {SEQ_TYPE_HUE, "HUE", 0, "Hue", ""},
1630     {SEQ_TYPE_SATURATION, "SATURATION", 0, "Saturation", ""},
1631     {SEQ_TYPE_BLEND_COLOR, "COLOR", 0, "Color", ""},
1632     {SEQ_TYPE_VALUE, "VALUE", 0, "Value", ""},
1633     {0, "", ICON_NONE, NULL, NULL},
1634     {SEQ_TYPE_ALPHAOVER, "ALPHA_OVER", 0, "Alpha Over", ""},
1635     {SEQ_TYPE_ALPHAUNDER, "ALPHA_UNDER", 0, "Alpha Under", ""},
1636     {SEQ_TYPE_GAMCROSS, "GAMMA_CROSS", 0, "Gamma Cross", ""},
1637     {SEQ_TYPE_OVERDROP, "OVER_DROP", 0, "Over Drop", ""},
1638     {0, NULL, 0, NULL, NULL},
1639 };
1640 
rna_def_sequence_modifiers(BlenderRNA * brna,PropertyRNA * cprop)1641 static void rna_def_sequence_modifiers(BlenderRNA *brna, PropertyRNA *cprop)
1642 {
1643   StructRNA *srna;
1644 
1645   FunctionRNA *func;
1646   PropertyRNA *parm;
1647 
1648   RNA_def_property_srna(cprop, "SequenceModifiers");
1649   srna = RNA_def_struct(brna, "SequenceModifiers", NULL);
1650   RNA_def_struct_sdna(srna, "Sequence");
1651   RNA_def_struct_ui_text(srna, "Strip Modifiers", "Collection of strip modifiers");
1652 
1653   /* add modifier */
1654   func = RNA_def_function(srna, "new", "rna_Sequence_modifier_new");
1655   RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
1656   RNA_def_function_ui_description(func, "Add a new modifier");
1657   parm = RNA_def_string(func, "name", "Name", 0, "", "New name for the modifier");
1658   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1659   /* modifier to add */
1660   parm = RNA_def_enum(func,
1661                       "type",
1662                       rna_enum_sequence_modifier_type_items,
1663                       seqModifierType_ColorBalance,
1664                       "",
1665                       "Modifier type to add");
1666   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1667   /* return type */
1668   parm = RNA_def_pointer(func, "modifier", "SequenceModifier", "", "Newly created modifier");
1669   RNA_def_function_return(func, parm);
1670 
1671   /* remove modifier */
1672   func = RNA_def_function(srna, "remove", "rna_Sequence_modifier_remove");
1673   RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
1674   RNA_def_function_ui_description(func, "Remove an existing modifier from the sequence");
1675   /* modifier to remove */
1676   parm = RNA_def_pointer(func, "modifier", "SequenceModifier", "", "Modifier to remove");
1677   RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
1678   RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
1679 
1680   /* clear all modifiers */
1681   func = RNA_def_function(srna, "clear", "rna_Sequence_modifier_clear");
1682   RNA_def_function_flag(func, FUNC_USE_CONTEXT);
1683   RNA_def_function_ui_description(func, "Remove all modifiers from the sequence");
1684 }
1685 
rna_def_sequence(BlenderRNA * brna)1686 static void rna_def_sequence(BlenderRNA *brna)
1687 {
1688   StructRNA *srna;
1689   PropertyRNA *prop;
1690 
1691   static const EnumPropertyItem seq_type_items[] = {
1692       {SEQ_TYPE_IMAGE, "IMAGE", 0, "Image", ""},
1693       {SEQ_TYPE_META, "META", 0, "Meta", ""},
1694       {SEQ_TYPE_SCENE, "SCENE", 0, "Scene", ""},
1695       {SEQ_TYPE_MOVIE, "MOVIE", 0, "Movie", ""},
1696       {SEQ_TYPE_MOVIECLIP, "MOVIECLIP", 0, "Clip", ""},
1697       {SEQ_TYPE_MASK, "MASK", 0, "Mask", ""},
1698       {SEQ_TYPE_SOUND_RAM, "SOUND", 0, "Sound", ""},
1699       {SEQ_TYPE_CROSS, "CROSS", 0, "Cross", ""},
1700       {SEQ_TYPE_ADD, "ADD", 0, "Add", ""},
1701       {SEQ_TYPE_SUB, "SUBTRACT", 0, "Subtract", ""},
1702       {SEQ_TYPE_ALPHAOVER, "ALPHA_OVER", 0, "Alpha Over", ""},
1703       {SEQ_TYPE_ALPHAUNDER, "ALPHA_UNDER", 0, "Alpha Under", ""},
1704       {SEQ_TYPE_GAMCROSS, "GAMMA_CROSS", 0, "Gamma Cross", ""},
1705       {SEQ_TYPE_MUL, "MULTIPLY", 0, "Multiply", ""},
1706       {SEQ_TYPE_OVERDROP, "OVER_DROP", 0, "Over Drop", ""},
1707       {SEQ_TYPE_WIPE, "WIPE", 0, "Wipe", ""},
1708       {SEQ_TYPE_GLOW, "GLOW", 0, "Glow", ""},
1709       {SEQ_TYPE_TRANSFORM, "TRANSFORM", 0, "Transform", ""},
1710       {SEQ_TYPE_COLOR, "COLOR", 0, "Color", ""},
1711       {SEQ_TYPE_SPEED, "SPEED", 0, "Speed", ""},
1712       {SEQ_TYPE_MULTICAM, "MULTICAM", 0, "Multicam Selector", ""},
1713       {SEQ_TYPE_ADJUSTMENT, "ADJUSTMENT", 0, "Adjustment Layer", ""},
1714       {SEQ_TYPE_GAUSSIAN_BLUR, "GAUSSIAN_BLUR", 0, "Gaussian Blur", ""},
1715       {SEQ_TYPE_TEXT, "TEXT", 0, "Text", ""},
1716       {SEQ_TYPE_COLORMIX, "COLORMIX", 0, "Color Mix", ""},
1717       {0, NULL, 0, NULL, NULL},
1718   };
1719 
1720   srna = RNA_def_struct(brna, "Sequence", NULL);
1721   RNA_def_struct_ui_text(srna, "Sequence", "Sequence strip in the sequence editor");
1722   RNA_def_struct_refine_func(srna, "rna_Sequence_refine");
1723   RNA_def_struct_path_func(srna, "rna_Sequence_path");
1724   RNA_def_struct_idprops_func(srna, "rna_Sequence_idprops");
1725 
1726   prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1727   RNA_def_property_string_funcs(
1728       prop, "rna_Sequence_name_get", "rna_Sequence_name_length", "rna_Sequence_name_set");
1729   RNA_def_property_string_maxlength(prop, sizeof(((Sequence *)NULL)->name) - 2);
1730   RNA_def_property_ui_text(prop, "Name", "");
1731   RNA_def_struct_name_property(srna, prop);
1732   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, NULL);
1733 
1734   prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
1735   RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1736   RNA_def_property_enum_items(prop, seq_type_items);
1737   RNA_def_property_ui_text(prop, "Type", "");
1738   RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_SEQUENCE);
1739   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
1740 
1741   /* flags */
1742   prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
1743   RNA_def_property_boolean_sdna(prop, NULL, "flag", SELECT);
1744   RNA_def_property_ui_text(prop, "Select", "");
1745   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER | NA_SELECTED, NULL);
1746 
1747   prop = RNA_def_property(srna, "select_left_handle", PROP_BOOLEAN, PROP_NONE);
1748   RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_LEFTSEL);
1749   RNA_def_property_ui_text(prop, "Left Handle Selected", "");
1750   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER | NA_SELECTED, NULL);
1751 
1752   prop = RNA_def_property(srna, "select_right_handle", PROP_BOOLEAN, PROP_NONE);
1753   RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_RIGHTSEL);
1754   RNA_def_property_ui_text(prop, "Right Handle Selected", "");
1755   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER | NA_SELECTED, NULL);
1756 
1757   prop = RNA_def_property(srna, "mute", PROP_BOOLEAN, PROP_NONE);
1758   RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_MUTE);
1759   RNA_def_property_ui_icon(prop, ICON_CHECKBOX_HLT, -1);
1760   RNA_def_property_ui_text(
1761       prop, "Mute", "Disable strip so that it cannot be viewed in the output");
1762   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
1763 
1764   prop = RNA_def_property(srna, "lock", PROP_BOOLEAN, PROP_NONE);
1765   RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_LOCK);
1766   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
1767   RNA_def_property_ui_icon(prop, ICON_UNLOCKED, true);
1768   RNA_def_property_ui_text(prop, "Lock", "Lock strip so that it cannot be transformed");
1769   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, NULL);
1770 
1771   /* strip positioning */
1772   /* Cache has to be invalidated before and after transformation. */
1773   prop = RNA_def_property(srna, "frame_final_duration", PROP_INT, PROP_TIME);
1774   RNA_def_property_range(prop, 1, MAXFRAME);
1775   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
1776   RNA_def_property_ui_text(
1777       prop, "Length", "The length of the contents of this strip after the handles are applied");
1778   RNA_def_property_int_funcs(
1779       prop, "rna_Sequence_frame_length_get", "rna_Sequence_frame_length_set", NULL);
1780   RNA_def_property_editable_func(prop, "rna_Sequence_frame_editable");
1781   RNA_def_property_update(
1782       prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_preprocessed_update");
1783 
1784   prop = RNA_def_property(srna, "frame_duration", PROP_INT, PROP_TIME);
1785   RNA_def_property_int_sdna(prop, NULL, "len");
1786   RNA_def_property_clear_flag(prop, PROP_EDITABLE | PROP_ANIMATABLE);
1787   RNA_def_property_range(prop, 1, MAXFRAME);
1788   RNA_def_property_ui_text(
1789       prop, "Length", "The length of the contents of this strip before the handles are applied");
1790 
1791   prop = RNA_def_property(srna, "frame_start", PROP_INT, PROP_TIME);
1792   RNA_def_property_int_sdna(prop, NULL, "start");
1793   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
1794   RNA_def_property_ui_text(prop, "Start Frame", "X position where the strip begins");
1795   RNA_def_property_int_funcs(
1796       prop, NULL, "rna_Sequence_start_frame_set", NULL); /* overlap tests and calc_seq_disp */
1797   RNA_def_property_editable_func(prop, "rna_Sequence_frame_editable");
1798   RNA_def_property_update(
1799       prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_preprocessed_update");
1800 
1801   prop = RNA_def_property(srna, "frame_final_start", PROP_INT, PROP_TIME);
1802   RNA_def_property_int_sdna(prop, NULL, "startdisp");
1803   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
1804   RNA_def_property_ui_text(
1805       prop,
1806       "Start Frame",
1807       "Start frame displayed in the sequence editor after offsets are applied, setting this is "
1808       "equivalent to moving the handle, not the actual start frame");
1809   /* overlap tests and calc_seq_disp */
1810   RNA_def_property_int_funcs(prop, NULL, "rna_Sequence_start_frame_final_set", NULL);
1811   RNA_def_property_editable_func(prop, "rna_Sequence_frame_editable");
1812   RNA_def_property_update(
1813       prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_preprocessed_update");
1814 
1815   prop = RNA_def_property(srna, "frame_final_end", PROP_INT, PROP_TIME);
1816   RNA_def_property_int_sdna(prop, NULL, "enddisp");
1817   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
1818   RNA_def_property_ui_text(
1819       prop, "End Frame", "End frame displayed in the sequence editor after offsets are applied");
1820   /* overlap tests and calc_seq_disp */
1821   RNA_def_property_int_funcs(prop, NULL, "rna_Sequence_end_frame_final_set", NULL);
1822   RNA_def_property_editable_func(prop, "rna_Sequence_frame_editable");
1823   RNA_def_property_update(
1824       prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_preprocessed_update");
1825 
1826   prop = RNA_def_property(srna, "frame_offset_start", PROP_INT, PROP_TIME);
1827   RNA_def_property_int_sdna(prop, NULL, "startofs");
1828   //  RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* overlap tests */
1829   RNA_def_property_ui_text(prop, "Start Offset", "");
1830   RNA_def_property_int_funcs(
1831       prop, NULL, "rna_Sequence_frame_offset_start_set", "rna_Sequence_frame_offset_start_range");
1832   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_frame_change_update");
1833 
1834   prop = RNA_def_property(srna, "frame_offset_end", PROP_INT, PROP_TIME);
1835   RNA_def_property_int_sdna(prop, NULL, "endofs");
1836   //  RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* overlap tests */
1837   RNA_def_property_ui_text(prop, "End Offset", "");
1838   RNA_def_property_int_funcs(
1839       prop, NULL, "rna_Sequence_frame_offset_end_set", "rna_Sequence_frame_offset_end_range");
1840   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_frame_change_update");
1841 
1842   prop = RNA_def_property(srna, "frame_still_start", PROP_INT, PROP_TIME);
1843   RNA_def_property_int_sdna(prop, NULL, "startstill");
1844   //  RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* overlap tests */
1845   RNA_def_property_range(prop, 0, MAXFRAME);
1846   RNA_def_property_ui_text(prop, "Start Still", "");
1847   RNA_def_property_int_funcs(prop, NULL, "rna_Sequence_frame_still_start_set", NULL);
1848   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_frame_change_update");
1849 
1850   prop = RNA_def_property(srna, "frame_still_end", PROP_INT, PROP_TIME);
1851   RNA_def_property_int_sdna(prop, NULL, "endstill");
1852   //  RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* overlap tests */
1853   RNA_def_property_range(prop, 0, MAXFRAME);
1854   RNA_def_property_ui_text(prop, "End Still", "");
1855   RNA_def_property_int_funcs(prop, NULL, "rna_Sequence_frame_still_end_set", NULL);
1856   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_frame_change_update");
1857 
1858   prop = RNA_def_property(srna, "channel", PROP_INT, PROP_UNSIGNED);
1859   RNA_def_property_int_sdna(prop, NULL, "machine");
1860   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
1861   RNA_def_property_range(prop, 1, MAXSEQ);
1862   RNA_def_property_ui_text(prop, "Channel", "Y position of the sequence strip");
1863   RNA_def_property_int_funcs(prop, NULL, "rna_Sequence_channel_set", NULL); /* overlap test */
1864   RNA_def_property_update(
1865       prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_preprocessed_update");
1866 
1867   prop = RNA_def_property(srna, "use_linear_modifiers", PROP_BOOLEAN, PROP_NONE);
1868   RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_USE_LINEAR_MODIFIERS);
1869   RNA_def_property_ui_text(prop,
1870                            "Use Linear Modifiers",
1871                            "Calculate modifiers in linear space instead of sequencer's space");
1872   RNA_def_property_update(
1873       prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_preprocessed_update");
1874 
1875   /* blending */
1876 
1877   prop = RNA_def_property(srna, "blend_type", PROP_ENUM, PROP_NONE);
1878   RNA_def_property_enum_sdna(prop, NULL, "blend_mode");
1879   RNA_def_property_enum_items(prop, blend_mode_items);
1880   RNA_def_property_ui_text(
1881       prop, "Blending Mode", "Method for controlling how the strip combines with other strips");
1882   RNA_def_property_update(
1883       prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_preprocessed_update");
1884 
1885   prop = RNA_def_property(srna, "blend_alpha", PROP_FLOAT, PROP_FACTOR);
1886   RNA_def_property_range(prop, 0.0f, 1.0f);
1887   RNA_def_property_ui_text(
1888       prop, "Blend Opacity", "Percentage of how much the strip's colors affect other strips");
1889   /* stupid 0-100 -> 0-1 */
1890   RNA_def_property_float_funcs(prop, "rna_Sequence_opacity_get", "rna_Sequence_opacity_set", NULL);
1891   RNA_def_property_update(
1892       prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_composite_update");
1893 
1894   prop = RNA_def_property(srna, "effect_fader", PROP_FLOAT, PROP_FACTOR);
1895   RNA_def_property_range(prop, 0.0f, 1.0f);
1896   RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.1, 3);
1897   RNA_def_property_float_sdna(prop, NULL, "effect_fader");
1898   RNA_def_property_ui_text(prop, "Effect Fader Position", "Custom fade value");
1899   RNA_def_property_update(
1900       prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_preprocessed_update");
1901 
1902   prop = RNA_def_property(srna, "use_default_fade", PROP_BOOLEAN, PROP_NONE);
1903   RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_USE_EFFECT_DEFAULT_FADE);
1904   RNA_def_property_ui_text(
1905       prop,
1906       "Use Default Fade",
1907       "Fade effect using the built-in default (usually make transition as long as "
1908       "effect strip)");
1909   RNA_def_property_update(
1910       prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_preprocessed_update");
1911 
1912   prop = RNA_def_property(srna, "speed_factor", PROP_FLOAT, PROP_NONE);
1913   RNA_def_property_float_sdna(prop, NULL, "speed_fader");
1914   RNA_def_property_ui_text(
1915       prop,
1916       "Speed Factor",
1917       "Multiply the current speed of the sequence with this number or remap current frame "
1918       "to this frame");
1919   RNA_def_property_update(
1920       prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_preprocessed_update");
1921 
1922   /* modifiers */
1923   prop = RNA_def_property(srna, "modifiers", PROP_COLLECTION, PROP_NONE);
1924   RNA_def_property_struct_type(prop, "SequenceModifier");
1925   RNA_def_property_ui_text(prop, "Modifiers", "Modifiers affecting this strip");
1926   rna_def_sequence_modifiers(brna, prop);
1927 
1928   prop = RNA_def_property(srna, "use_cache_raw", PROP_BOOLEAN, PROP_NONE);
1929   RNA_def_property_boolean_sdna(prop, NULL, "cache_flag", SEQ_CACHE_STORE_RAW);
1930   RNA_def_property_ui_text(prop,
1931                            "Cache Raw",
1932                            "Cache raw images read from disk, for faster tweaking of strip "
1933                            "parameters at the cost of memory usage");
1934 
1935   prop = RNA_def_property(srna, "use_cache_preprocessed", PROP_BOOLEAN, PROP_NONE);
1936   RNA_def_property_boolean_sdna(prop, NULL, "cache_flag", SEQ_CACHE_STORE_PREPROCESSED);
1937   RNA_def_property_ui_text(
1938       prop,
1939       "Cache Pre-processed",
1940       "Cache pre-processed images, for faster tweaking of effects at the cost of memory usage");
1941 
1942   prop = RNA_def_property(srna, "use_cache_composite", PROP_BOOLEAN, PROP_NONE);
1943   RNA_def_property_boolean_sdna(prop, NULL, "cache_flag", SEQ_CACHE_STORE_COMPOSITE);
1944   RNA_def_property_ui_text(prop,
1945                            "Cache Composite",
1946                            "Cache intermediate composited images, for faster tweaking of stacked "
1947                            "strips at the cost of memory usage");
1948 
1949   prop = RNA_def_property(srna, "override_cache_settings", PROP_BOOLEAN, PROP_NONE);
1950   RNA_def_property_boolean_sdna(prop, NULL, "cache_flag", SEQ_CACHE_OVERRIDE);
1951   RNA_def_property_ui_text(prop, "Override Cache Settings", "Override global cache settings");
1952 
1953   RNA_api_sequence_strip(srna);
1954 }
1955 
rna_def_editor(BlenderRNA * brna)1956 static void rna_def_editor(BlenderRNA *brna)
1957 {
1958   StructRNA *srna;
1959   PropertyRNA *prop;
1960 
1961   static const EnumPropertyItem editing_storage_items[] = {
1962       {0, "PER_STRIP", 0, "Per Strip", "Store proxies using per strip settings"},
1963       {SEQ_EDIT_PROXY_DIR_STORAGE,
1964        "PROJECT",
1965        0,
1966        "Project",
1967        "Store proxies using project directory"},
1968       {0, NULL, 0, NULL, NULL},
1969   };
1970   srna = RNA_def_struct(brna, "SequenceEditor", NULL);
1971   RNA_def_struct_ui_text(srna, "Sequence Editor", "Sequence editing data for a Scene data-block");
1972   RNA_def_struct_ui_icon(srna, ICON_SEQUENCE);
1973   RNA_def_struct_sdna(srna, "Editing");
1974 
1975   prop = RNA_def_property(srna, "sequences", PROP_COLLECTION, PROP_NONE);
1976   RNA_def_property_collection_sdna(prop, NULL, "seqbase", NULL);
1977   RNA_def_property_struct_type(prop, "Sequence");
1978   RNA_def_property_ui_text(prop, "Sequences", "Top-level strips only");
1979   RNA_api_sequences(brna, prop);
1980 
1981   prop = RNA_def_property(srna, "sequences_all", PROP_COLLECTION, PROP_NONE);
1982   RNA_def_property_collection_sdna(prop, NULL, "seqbase", NULL);
1983   RNA_def_property_struct_type(prop, "Sequence");
1984   RNA_def_property_ui_text(
1985       prop, "All Sequences", "All strips, recursively including those inside metastrips");
1986   RNA_def_property_collection_funcs(prop,
1987                                     "rna_SequenceEditor_sequences_all_begin",
1988                                     "rna_SequenceEditor_sequences_all_next",
1989                                     NULL,
1990                                     NULL,
1991                                     NULL,
1992                                     NULL,
1993                                     NULL,
1994                                     NULL);
1995 
1996   prop = RNA_def_property(srna, "meta_stack", PROP_COLLECTION, PROP_NONE);
1997   RNA_def_property_collection_sdna(prop, NULL, "metastack", NULL);
1998   RNA_def_property_struct_type(prop, "Sequence");
1999   RNA_def_property_ui_text(
2000       prop, "Meta Stack", "Meta strip stack, last is currently edited meta strip");
2001   RNA_def_property_collection_funcs(
2002       prop, NULL, NULL, NULL, "rna_SequenceEditor_meta_stack_get", NULL, NULL, NULL, NULL);
2003 
2004   prop = RNA_def_property(srna, "active_strip", PROP_POINTER, PROP_NONE);
2005   RNA_def_property_pointer_sdna(prop, NULL, "act_seq");
2006   RNA_def_property_flag(prop, PROP_EDITABLE);
2007   RNA_def_property_ui_text(prop, "Active Strip", "Sequencer's active strip");
2008 
2009   prop = RNA_def_property(srna, "show_overlay", PROP_BOOLEAN, PROP_NONE);
2010   RNA_def_property_boolean_sdna(prop, NULL, "over_flag", SEQ_EDIT_OVERLAY_SHOW);
2011   RNA_def_property_ui_text(
2012       prop, "Show Overlay", "Partial overlay on top of the sequencer with a frame offset");
2013   RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL);
2014 
2015   prop = RNA_def_property(srna, "use_overlay_lock", PROP_BOOLEAN, PROP_NONE);
2016   RNA_def_property_boolean_sdna(prop, NULL, "over_flag", SEQ_EDIT_OVERLAY_ABS);
2017   RNA_def_property_ui_text(prop, "Overlay Lock", "");
2018   RNA_def_property_boolean_funcs(prop, NULL, "rna_SequenceEditor_overlay_lock_set");
2019   RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL);
2020 
2021   /* access to fixed and relative frame */
2022   prop = RNA_def_property(srna, "overlay_frame", PROP_INT, PROP_NONE);
2023   RNA_def_property_ui_text(prop, "Overlay Offset", "Number of frames to offset");
2024   RNA_def_property_int_funcs(
2025       prop, "rna_SequenceEditor_overlay_frame_get", "rna_SequenceEditor_overlay_frame_set", NULL);
2026   RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL);
2027 
2028   prop = RNA_def_property(srna, "proxy_storage", PROP_ENUM, PROP_NONE);
2029   RNA_def_property_enum_items(prop, editing_storage_items);
2030   RNA_def_property_ui_text(prop, "Proxy Storage", "How to store proxies for this project");
2031   RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, "rna_SequenceEditor_update_cache");
2032 
2033   prop = RNA_def_property(srna, "proxy_dir", PROP_STRING, PROP_DIRPATH);
2034   RNA_def_property_string_sdna(prop, NULL, "proxy_dir");
2035   RNA_def_property_ui_text(prop, "Proxy Directory", "");
2036   RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, "rna_SequenceEditor_update_cache");
2037 
2038   /* cache flags */
2039 
2040   prop = RNA_def_property(srna, "show_cache", PROP_BOOLEAN, PROP_NONE);
2041   RNA_def_property_boolean_sdna(prop, NULL, "cache_flag", SEQ_CACHE_VIEW_ENABLE);
2042   RNA_def_property_ui_text(prop, "Show Cache", "Visualize cached images on the timeline");
2043   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, NULL);
2044 
2045   prop = RNA_def_property(srna, "show_cache_final_out", PROP_BOOLEAN, PROP_NONE);
2046   RNA_def_property_boolean_sdna(prop, NULL, "cache_flag", SEQ_CACHE_VIEW_FINAL_OUT);
2047   RNA_def_property_ui_text(prop, "Final Images", "Visualize cached complete frames");
2048   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, NULL);
2049 
2050   prop = RNA_def_property(srna, "show_cache_raw", PROP_BOOLEAN, PROP_NONE);
2051   RNA_def_property_boolean_sdna(prop, NULL, "cache_flag", SEQ_CACHE_VIEW_RAW);
2052   RNA_def_property_ui_text(prop, "Raw Images", "Visualize cached raw images");
2053   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, NULL);
2054 
2055   prop = RNA_def_property(srna, "show_cache_preprocessed", PROP_BOOLEAN, PROP_NONE);
2056   RNA_def_property_boolean_sdna(prop, NULL, "cache_flag", SEQ_CACHE_VIEW_PREPROCESSED);
2057   RNA_def_property_ui_text(prop, "Pre-processed Images", "Visualize cached pre-processed images");
2058   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, NULL);
2059 
2060   prop = RNA_def_property(srna, "show_cache_composite", PROP_BOOLEAN, PROP_NONE);
2061   RNA_def_property_boolean_sdna(prop, NULL, "cache_flag", SEQ_CACHE_VIEW_COMPOSITE);
2062   RNA_def_property_ui_text(prop, "Composite Images", "Visualize cached composite images");
2063   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, NULL);
2064 
2065   prop = RNA_def_property(srna, "use_cache_raw", PROP_BOOLEAN, PROP_NONE);
2066   RNA_def_property_boolean_sdna(prop, NULL, "cache_flag", SEQ_CACHE_STORE_RAW);
2067   RNA_def_property_ui_text(prop,
2068                            "Cache Raw",
2069                            "Cache raw images read from disk, for faster tweaking of strip "
2070                            "parameters at the cost of memory usage");
2071 
2072   prop = RNA_def_property(srna, "use_cache_preprocessed", PROP_BOOLEAN, PROP_NONE);
2073   RNA_def_property_boolean_sdna(prop, NULL, "cache_flag", SEQ_CACHE_STORE_PREPROCESSED);
2074   RNA_def_property_ui_text(
2075       prop,
2076       "Cache Pre-processed",
2077       "Cache pre-processed images, for faster tweaking of effects at the cost of memory usage");
2078 
2079   prop = RNA_def_property(srna, "use_cache_composite", PROP_BOOLEAN, PROP_NONE);
2080   RNA_def_property_boolean_sdna(prop, NULL, "cache_flag", SEQ_CACHE_STORE_COMPOSITE);
2081   RNA_def_property_ui_text(prop,
2082                            "Cache Composite",
2083                            "Cache intermediate composited images, for faster tweaking of stacked "
2084                            "strips at the cost of memory usage");
2085 
2086   prop = RNA_def_property(srna, "use_cache_final", PROP_BOOLEAN, PROP_NONE);
2087   RNA_def_property_boolean_sdna(prop, NULL, "cache_flag", SEQ_CACHE_STORE_FINAL_OUT);
2088   RNA_def_property_ui_text(prop, "Cache Final", "Cache final image for each frame");
2089 
2090   prop = RNA_def_property(srna, "use_prefetch", PROP_BOOLEAN, PROP_NONE);
2091   RNA_def_property_boolean_sdna(prop, NULL, "cache_flag", SEQ_CACHE_PREFETCH_ENABLE);
2092   RNA_def_property_ui_text(
2093       prop,
2094       "Prefetch Frames",
2095       "Render frames ahead of current frame in the background for faster playback");
2096   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, NULL);
2097 
2098   prop = RNA_def_property(srna, "recycle_max_cost", PROP_FLOAT, PROP_NONE);
2099   RNA_def_property_range(prop, 0.0f, SEQ_CACHE_COST_MAX);
2100   RNA_def_property_ui_range(prop, 0.0f, SEQ_CACHE_COST_MAX, 0.1f, 1);
2101   RNA_def_property_float_sdna(prop, NULL, "recycle_max_cost");
2102   RNA_def_property_ui_text(
2103       prop, "Recycle Up To Cost", "Only frames with cost lower than this value will be recycled");
2104 }
2105 
rna_def_filter_video(StructRNA * srna)2106 static void rna_def_filter_video(StructRNA *srna)
2107 {
2108   PropertyRNA *prop;
2109 
2110   static const EnumPropertyItem alpha_mode_items[] = {
2111       {SEQ_ALPHA_STRAIGHT,
2112        "STRAIGHT",
2113        0,
2114        "Straight",
2115        "RGB channels in transparent pixels are unaffected by the alpha channel"},
2116       {SEQ_ALPHA_PREMUL,
2117        "PREMUL",
2118        0,
2119        "Premultiplied",
2120        "RGB channels in transparent pixels are multiplied by the alpha channel"},
2121       {0, NULL, 0, NULL, NULL},
2122   };
2123 
2124   prop = RNA_def_property(srna, "use_deinterlace", PROP_BOOLEAN, PROP_NONE);
2125   RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_FILTERY);
2126   RNA_def_property_ui_text(prop, "Deinterlace", "Remove fields from video movies");
2127   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_reopen_files_update");
2128 
2129   prop = RNA_def_property(srna, "alpha_mode", PROP_ENUM, PROP_NONE);
2130   RNA_def_property_enum_items(prop, alpha_mode_items);
2131   RNA_def_property_ui_text(
2132       prop, "Alpha Mode", "Representation of alpha information in the RGBA pixels");
2133   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
2134 
2135   prop = RNA_def_property(srna, "use_flip_x", PROP_BOOLEAN, PROP_NONE);
2136   RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_FLIPX);
2137   RNA_def_property_ui_text(prop, "Flip X", "Flip on the X axis");
2138   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
2139 
2140   prop = RNA_def_property(srna, "use_flip_y", PROP_BOOLEAN, PROP_NONE);
2141   RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_FLIPY);
2142   RNA_def_property_ui_text(prop, "Flip Y", "Flip on the Y axis");
2143   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
2144 
2145   prop = RNA_def_property(srna, "use_float", PROP_BOOLEAN, PROP_NONE);
2146   RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_MAKE_FLOAT);
2147   RNA_def_property_ui_text(prop, "Convert Float", "Convert input to float data");
2148   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
2149 
2150   prop = RNA_def_property(srna, "use_reverse_frames", PROP_BOOLEAN, PROP_NONE);
2151   RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_REVERSE_FRAMES);
2152   RNA_def_property_ui_text(prop, "Reverse Frames", "Reverse frame order");
2153   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
2154 
2155   prop = RNA_def_property(srna, "color_multiply", PROP_FLOAT, PROP_UNSIGNED);
2156   RNA_def_property_float_sdna(prop, NULL, "mul");
2157   RNA_def_property_range(prop, 0.0f, 20.0f);
2158   RNA_def_property_float_default(prop, 1.0f);
2159   RNA_def_property_ui_text(prop, "Multiply Colors", "");
2160   RNA_def_property_update(
2161       prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_preprocessed_update");
2162 
2163   prop = RNA_def_property(srna, "color_saturation", PROP_FLOAT, PROP_UNSIGNED);
2164   RNA_def_property_float_sdna(prop, NULL, "sat");
2165   RNA_def_property_range(prop, 0.0f, 20.0f);
2166   RNA_def_property_ui_range(prop, 0.0f, 2.0f, 3, 3);
2167   RNA_def_property_float_default(prop, 1.0f);
2168   RNA_def_property_ui_text(prop, "Saturation", "Adjust the intensity of the input's color");
2169   RNA_def_property_update(
2170       prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_preprocessed_update");
2171 
2172   prop = RNA_def_property(srna, "strobe", PROP_FLOAT, PROP_NONE);
2173   RNA_def_property_range(prop, 1.0f, 30.0f);
2174   RNA_def_property_ui_text(prop, "Strobe", "Only display every nth frame");
2175   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
2176 
2177   prop = RNA_def_property(srna, "use_translation", PROP_BOOLEAN, PROP_NONE);
2178   RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_USE_TRANSFORM);
2179   RNA_def_property_ui_text(prop, "Use Translation", "Translate image before processing");
2180   RNA_def_property_boolean_funcs(prop, NULL, "rna_Sequence_use_translation_set");
2181   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
2182 
2183   prop = RNA_def_property(srna, "transform", PROP_POINTER, PROP_NONE);
2184   RNA_def_property_pointer_sdna(prop, NULL, "strip->transform");
2185   RNA_def_property_ui_text(prop, "Transform", "");
2186 
2187   prop = RNA_def_property(srna, "use_crop", PROP_BOOLEAN, PROP_NONE);
2188   RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_USE_CROP);
2189   RNA_def_property_ui_text(prop, "Use Crop", "Crop image before processing");
2190   RNA_def_property_boolean_funcs(prop, NULL, "rna_Sequence_use_crop_set");
2191   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
2192 
2193   prop = RNA_def_property(srna, "crop", PROP_POINTER, PROP_NONE);
2194   RNA_def_property_pointer_sdna(prop, NULL, "strip->crop");
2195   RNA_def_property_ui_text(prop, "Crop", "");
2196 }
2197 
rna_def_proxy(StructRNA * srna)2198 static void rna_def_proxy(StructRNA *srna)
2199 {
2200   PropertyRNA *prop;
2201 
2202   prop = RNA_def_property(srna, "use_proxy", PROP_BOOLEAN, PROP_NONE);
2203   RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_USE_PROXY);
2204   RNA_def_property_ui_text(
2205       prop, "Use Proxy / Timecode", "Use a preview proxy and/or time-code index for this strip");
2206   RNA_def_property_boolean_funcs(prop, NULL, "rna_Sequence_use_proxy_set");
2207   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
2208 
2209   prop = RNA_def_property(srna, "proxy", PROP_POINTER, PROP_NONE);
2210   RNA_def_property_pointer_sdna(prop, NULL, "strip->proxy");
2211   RNA_def_property_ui_text(prop, "Proxy", "");
2212 }
2213 
rna_def_input(StructRNA * srna)2214 static void rna_def_input(StructRNA *srna)
2215 {
2216   PropertyRNA *prop;
2217 
2218   prop = RNA_def_property(srna, "animation_offset_start", PROP_INT, PROP_UNSIGNED);
2219   RNA_def_property_int_sdna(prop, NULL, "anim_startofs");
2220   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2221   RNA_def_property_int_funcs(prop,
2222                              NULL,
2223                              "rna_Sequence_anim_startofs_final_set",
2224                              "rna_Sequence_anim_startofs_final_range"); /* overlap tests */
2225   RNA_def_property_ui_text(prop, "Animation Start Offset", "Animation start offset (trim start)");
2226   RNA_def_property_update(
2227       prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_preprocessed_update");
2228 
2229   prop = RNA_def_property(srna, "animation_offset_end", PROP_INT, PROP_UNSIGNED);
2230   RNA_def_property_int_sdna(prop, NULL, "anim_endofs");
2231   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2232   RNA_def_property_int_funcs(prop,
2233                              NULL,
2234                              "rna_Sequence_anim_endofs_final_set",
2235                              "rna_Sequence_anim_endofs_final_range"); /* overlap tests */
2236   RNA_def_property_ui_text(prop, "Animation End Offset", "Animation end offset (trim end)");
2237   RNA_def_property_update(
2238       prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_preprocessed_update");
2239 }
2240 
rna_def_effect_inputs(StructRNA * srna,int count)2241 static void rna_def_effect_inputs(StructRNA *srna, int count)
2242 {
2243   PropertyRNA *prop;
2244 
2245   prop = RNA_def_property(srna, "input_count", PROP_INT, PROP_UNSIGNED);
2246   RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2247   RNA_def_property_int_funcs(prop, "rna_Sequence_input_count_get", NULL, NULL);
2248 
2249   if (count >= 1) {
2250     prop = RNA_def_property(srna, "input_1", PROP_POINTER, PROP_NONE);
2251     RNA_def_property_pointer_sdna(prop, NULL, "seq1");
2252     RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_NULL);
2253     RNA_def_property_pointer_funcs(prop, NULL, "rna_Sequence_input_1_set", NULL, NULL);
2254     RNA_def_property_ui_text(prop, "Input 1", "First input for the effect strip");
2255   }
2256 
2257   if (count >= 2) {
2258     prop = RNA_def_property(srna, "input_2", PROP_POINTER, PROP_NONE);
2259     RNA_def_property_pointer_sdna(prop, NULL, "seq2");
2260     RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_NULL);
2261     RNA_def_property_pointer_funcs(prop, NULL, "rna_Sequence_input_2_set", NULL, NULL);
2262     RNA_def_property_ui_text(prop, "Input 2", "Second input for the effect strip");
2263   }
2264 
2265 #  if 0
2266   if (count == 3) {
2267     /* Not used by any effects (perhaps one day plugins?). */
2268     prop = RNA_def_property(srna, "input_3", PROP_POINTER, PROP_NONE);
2269     RNA_def_property_pointer_sdna(prop, NULL, "seq3");
2270     RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_NULL);
2271     RNA_def_property_ui_text(prop, "Input 3", "Third input for the effect strip");
2272   }
2273 #  endif
2274 }
2275 
rna_def_color_management(StructRNA * srna)2276 static void rna_def_color_management(StructRNA *srna)
2277 {
2278   PropertyRNA *prop;
2279 
2280   prop = RNA_def_property(srna, "colorspace_settings", PROP_POINTER, PROP_NONE);
2281   RNA_def_property_pointer_sdna(prop, NULL, "strip->colorspace_settings");
2282   RNA_def_property_struct_type(prop, "ColorManagedInputColorspaceSettings");
2283   RNA_def_property_ui_text(prop, "Color Space Settings", "Input color space settings");
2284 }
2285 
rna_def_movie_types(StructRNA * srna)2286 static void rna_def_movie_types(StructRNA *srna)
2287 {
2288   PropertyRNA *prop;
2289 
2290   prop = RNA_def_property(srna, "fps", PROP_FLOAT, PROP_NONE);
2291   RNA_def_property_ui_text(prop, "FPS", "Frames per second");
2292   RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2293   RNA_def_property_float_funcs(prop, "rna_Sequence_fps_get", NULL, NULL);
2294 }
2295 
rna_def_image(BlenderRNA * brna)2296 static void rna_def_image(BlenderRNA *brna)
2297 {
2298   StructRNA *srna;
2299   PropertyRNA *prop;
2300 
2301   srna = RNA_def_struct(brna, "ImageSequence", "Sequence");
2302   RNA_def_struct_ui_text(srna, "Image Sequence", "Sequence strip to load one or more images");
2303   RNA_def_struct_sdna(srna, "Sequence");
2304 
2305   prop = RNA_def_property(srna, "directory", PROP_STRING, PROP_DIRPATH);
2306   RNA_def_property_string_sdna(prop, NULL, "strip->dir");
2307   RNA_def_property_ui_text(prop, "Directory", "");
2308   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
2309 
2310   prop = RNA_def_property(srna, "elements", PROP_COLLECTION, PROP_NONE);
2311   RNA_def_property_collection_sdna(prop, NULL, "strip->stripdata", NULL);
2312   RNA_def_property_struct_type(prop, "SequenceElement");
2313   RNA_def_property_ui_text(prop, "Elements", "");
2314   RNA_def_property_collection_funcs(prop,
2315                                     "rna_SequenceEditor_elements_begin",
2316                                     "rna_iterator_array_next",
2317                                     "rna_iterator_array_end",
2318                                     "rna_iterator_array_get",
2319                                     "rna_SequenceEditor_elements_length",
2320                                     NULL,
2321                                     NULL,
2322                                     NULL);
2323   RNA_api_sequence_elements(brna, prop);
2324 
2325   /* multiview */
2326   prop = RNA_def_property(srna, "use_multiview", PROP_BOOLEAN, PROP_NONE);
2327   RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_USE_VIEWS);
2328   RNA_def_property_ui_text(prop, "Use Multi-View", "Use Multiple Views (when available)");
2329   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_views_format_update");
2330 
2331   prop = RNA_def_property(srna, "views_format", PROP_ENUM, PROP_NONE);
2332   RNA_def_property_enum_sdna(prop, NULL, "views_format");
2333   RNA_def_property_enum_items(prop, rna_enum_views_format_items);
2334   RNA_def_property_ui_text(prop, "Views Format", "Mode to load image views");
2335   RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Sequence_views_format_update");
2336 
2337   prop = RNA_def_property(srna, "stereo_3d_format", PROP_POINTER, PROP_NONE);
2338   RNA_def_property_pointer_sdna(prop, NULL, "stereo3d_format");
2339   RNA_def_property_flag(prop, PROP_NEVER_NULL);
2340   RNA_def_property_struct_type(prop, "Stereo3dFormat");
2341   RNA_def_property_ui_text(prop, "Stereo 3D Format", "Settings for stereo 3d");
2342 
2343   rna_def_filter_video(srna);
2344   rna_def_proxy(srna);
2345   rna_def_input(srna);
2346   rna_def_color_management(srna);
2347 }
2348 
rna_def_meta(BlenderRNA * brna)2349 static void rna_def_meta(BlenderRNA *brna)
2350 {
2351   StructRNA *srna;
2352   PropertyRNA *prop;
2353 
2354   srna = RNA_def_struct(brna, "MetaSequence", "Sequence");
2355   RNA_def_struct_ui_text(
2356       srna, "Meta Sequence", "Sequence strip to group other strips as a single sequence strip");
2357   RNA_def_struct_sdna(srna, "Sequence");
2358 
2359   prop = RNA_def_property(srna, "sequences", PROP_COLLECTION, PROP_NONE);
2360   RNA_def_property_collection_sdna(prop, NULL, "seqbase", NULL);
2361   RNA_def_property_struct_type(prop, "Sequence");
2362   RNA_def_property_ui_text(prop, "Sequences", "");
2363 
2364   rna_def_filter_video(srna);
2365   rna_def_proxy(srna);
2366   rna_def_input(srna);
2367 }
2368 
rna_def_scene(BlenderRNA * brna)2369 static void rna_def_scene(BlenderRNA *brna)
2370 {
2371   StructRNA *srna;
2372   PropertyRNA *prop;
2373 
2374   static const EnumPropertyItem scene_input_items[] = {
2375       {0, "CAMERA", ICON_VIEW3D, "Camera", "Use the Scene's 3D camera as input"},
2376       {SEQ_SCENE_STRIPS,
2377        "SEQUENCER",
2378        ICON_SEQUENCE,
2379        "Sequencer",
2380        "Use the Scene's Sequencer timeline as input"},
2381       {0, NULL, 0, NULL, NULL},
2382   };
2383 
2384   srna = RNA_def_struct(brna, "SceneSequence", "Sequence");
2385   RNA_def_struct_ui_text(
2386       srna, "Scene Sequence", "Sequence strip to used the rendered image of a scene");
2387   RNA_def_struct_sdna(srna, "Sequence");
2388 
2389   prop = RNA_def_property(srna, "scene", PROP_POINTER, PROP_NONE);
2390   RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
2391   RNA_def_property_ui_text(prop, "Scene", "Scene that this sequence uses");
2392   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_scene_switch_update");
2393 
2394   prop = RNA_def_property(srna, "scene_camera", PROP_POINTER, PROP_NONE);
2395   RNA_def_property_flag(prop, PROP_EDITABLE);
2396   RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_Camera_object_poll");
2397   RNA_def_property_ui_text(prop, "Camera Override", "Override the scenes active camera");
2398   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
2399 
2400   prop = RNA_def_property(srna, "scene_input", PROP_ENUM, PROP_NONE);
2401   RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
2402   RNA_def_property_enum_items(prop, scene_input_items);
2403   RNA_def_property_ui_text(prop, "Input", "Input type to use for the Scene strip");
2404   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_use_sequence");
2405 
2406   prop = RNA_def_property(srna, "use_grease_pencil", PROP_BOOLEAN, PROP_NONE);
2407   RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SEQ_SCENE_NO_GPENCIL);
2408   RNA_def_property_ui_text(
2409       prop, "Use Grease Pencil", "Show Grease Pencil strokes in OpenGL previews");
2410   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, NULL);
2411 
2412   rna_def_filter_video(srna);
2413   rna_def_proxy(srna);
2414   rna_def_input(srna);
2415   rna_def_movie_types(srna);
2416 }
2417 
rna_def_movie(BlenderRNA * brna)2418 static void rna_def_movie(BlenderRNA *brna)
2419 {
2420   StructRNA *srna;
2421   PropertyRNA *prop;
2422   FunctionRNA *func;
2423   PropertyRNA *parm;
2424 
2425   srna = RNA_def_struct(brna, "MovieSequence", "Sequence");
2426   RNA_def_struct_ui_text(srna, "Movie Sequence", "Sequence strip to load a video");
2427   RNA_def_struct_sdna(srna, "Sequence");
2428 
2429   prop = RNA_def_property(srna, "mpeg_preseek", PROP_INT, PROP_NONE);
2430   RNA_def_property_int_sdna(prop, NULL, "anim_preseek");
2431   RNA_def_property_range(prop, 0, 50);
2432   RNA_def_property_ui_text(prop, "MPEG Preseek", "For MPEG movies, preseek this many frames");
2433   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, NULL);
2434 
2435   prop = RNA_def_property(srna, "stream_index", PROP_INT, PROP_NONE);
2436   RNA_def_property_int_sdna(prop, NULL, "streamindex");
2437   RNA_def_property_range(prop, 0, 20);
2438   RNA_def_property_ui_text(
2439       prop,
2440       "Stream Index",
2441       "For files with several movie streams, use the stream with the given index");
2442   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_reopen_files_update");
2443 
2444   prop = RNA_def_property(srna, "elements", PROP_COLLECTION, PROP_NONE);
2445   RNA_def_property_collection_sdna(prop, NULL, "strip->stripdata", NULL);
2446   RNA_def_property_struct_type(prop, "SequenceElement");
2447   RNA_def_property_ui_text(prop, "Elements", "");
2448   RNA_def_property_collection_funcs(prop,
2449                                     "rna_SequenceEditor_elements_begin",
2450                                     "rna_iterator_array_next",
2451                                     "rna_iterator_array_end",
2452                                     "rna_iterator_array_get",
2453                                     "rna_SequenceEditor_elements_length",
2454                                     NULL,
2455                                     NULL,
2456                                     NULL);
2457 
2458   prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH);
2459   RNA_def_property_ui_text(prop, "File", "");
2460   RNA_def_property_string_funcs(prop,
2461                                 "rna_Sequence_filepath_get",
2462                                 "rna_Sequence_filepath_length",
2463                                 "rna_Sequence_filepath_set");
2464   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_filepath_update");
2465 
2466   func = RNA_def_function(srna, "reload_if_needed", "rna_MovieSequence_reload_if_needed");
2467   RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN);
2468   /* return type */
2469   parm = RNA_def_boolean(
2470       func, "can_produce_frames", 0, "True if the strip can produce frames, False otherwise", "");
2471   RNA_def_function_return(func, parm);
2472 
2473   /* metadata */
2474   func = RNA_def_function(srna, "metadata", "rna_MovieSequence_metadata_get");
2475   RNA_def_function_ui_description(func, "Retrieve metadata of the movie file");
2476   /* return type */
2477   parm = RNA_def_pointer(
2478       func, "metadata", "IDPropertyWrapPtr", "", "Dict-like object containing the metadata");
2479   RNA_def_parameter_flags(parm, 0, PARM_RNAPTR);
2480   RNA_def_function_return(func, parm);
2481 
2482   /* multiview */
2483   prop = RNA_def_property(srna, "use_multiview", PROP_BOOLEAN, PROP_NONE);
2484   RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_USE_VIEWS);
2485   RNA_def_property_ui_text(prop, "Use Multi-View", "Use Multiple Views (when available)");
2486   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_views_format_update");
2487 
2488   prop = RNA_def_property(srna, "views_format", PROP_ENUM, PROP_NONE);
2489   RNA_def_property_enum_sdna(prop, NULL, "views_format");
2490   RNA_def_property_enum_items(prop, rna_enum_views_format_items);
2491   RNA_def_property_ui_text(prop, "Views Format", "Mode to load movie views");
2492   RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Sequence_views_format_update");
2493 
2494   prop = RNA_def_property(srna, "stereo_3d_format", PROP_POINTER, PROP_NONE);
2495   RNA_def_property_pointer_sdna(prop, NULL, "stereo3d_format");
2496   RNA_def_property_flag(prop, PROP_NEVER_NULL);
2497   RNA_def_property_struct_type(prop, "Stereo3dFormat");
2498   RNA_def_property_ui_text(prop, "Stereo 3D Format", "Settings for stereo 3d");
2499 
2500   rna_def_filter_video(srna);
2501   rna_def_proxy(srna);
2502   rna_def_input(srna);
2503   rna_def_color_management(srna);
2504   rna_def_movie_types(srna);
2505 }
2506 
rna_def_movieclip(BlenderRNA * brna)2507 static void rna_def_movieclip(BlenderRNA *brna)
2508 {
2509   StructRNA *srna;
2510   PropertyRNA *prop;
2511 
2512   srna = RNA_def_struct(brna, "MovieClipSequence", "Sequence");
2513   RNA_def_struct_ui_text(
2514       srna, "MovieClip Sequence", "Sequence strip to load a video from the clip editor");
2515   RNA_def_struct_sdna(srna, "Sequence");
2516 
2517   /* TODO - add clip property? */
2518 
2519   prop = RNA_def_property(srna, "undistort", PROP_BOOLEAN, PROP_NONE);
2520   RNA_def_property_boolean_sdna(prop, NULL, "clip_flag", SEQ_MOVIECLIP_RENDER_UNDISTORTED);
2521   RNA_def_property_ui_text(prop, "Undistort Clip", "Use the undistorted version of the clip");
2522   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
2523 
2524   prop = RNA_def_property(srna, "stabilize2d", PROP_BOOLEAN, PROP_NONE);
2525   RNA_def_property_boolean_sdna(prop, NULL, "clip_flag", SEQ_MOVIECLIP_RENDER_STABILIZED);
2526   RNA_def_property_ui_text(prop, "Stabilize 2D Clip", "Use the 2D stabilized version of the clip");
2527   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
2528 
2529   rna_def_filter_video(srna);
2530   rna_def_input(srna);
2531   rna_def_movie_types(srna);
2532 }
2533 
rna_def_mask(BlenderRNA * brna)2534 static void rna_def_mask(BlenderRNA *brna)
2535 {
2536   StructRNA *srna;
2537   PropertyRNA *prop;
2538 
2539   srna = RNA_def_struct(brna, "MaskSequence", "Sequence");
2540   RNA_def_struct_ui_text(srna, "Mask Sequence", "Sequence strip to load a video from a mask");
2541   RNA_def_struct_sdna(srna, "Sequence");
2542 
2543   prop = RNA_def_property(srna, "mask", PROP_POINTER, PROP_NONE);
2544   RNA_def_property_flag(prop, PROP_EDITABLE);
2545   RNA_def_property_ui_text(prop, "Mask", "Mask that this sequence uses");
2546   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
2547 
2548   rna_def_filter_video(srna);
2549   rna_def_input(srna);
2550 }
2551 
rna_def_sound(BlenderRNA * brna)2552 static void rna_def_sound(BlenderRNA *brna)
2553 {
2554   StructRNA *srna;
2555   PropertyRNA *prop;
2556 
2557   srna = RNA_def_struct(brna, "SoundSequence", "Sequence");
2558   RNA_def_struct_ui_text(srna,
2559                          "Sound Sequence",
2560                          "Sequence strip defining a sound to be played over a period of time");
2561   RNA_def_struct_sdna(srna, "Sequence");
2562 
2563   prop = RNA_def_property(srna, "sound", PROP_POINTER, PROP_NONE);
2564   RNA_def_property_flag(prop, PROP_EDITABLE);
2565   RNA_def_property_struct_type(prop, "Sound");
2566   RNA_def_property_ui_text(prop, "Sound", "Sound data-block used by this sequence");
2567   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_sound_update");
2568 
2569   prop = RNA_def_property(srna, "volume", PROP_FLOAT, PROP_NONE);
2570   RNA_def_property_float_sdna(prop, NULL, "volume");
2571   RNA_def_property_range(prop, 0.0f, 100.0f);
2572   RNA_def_property_ui_text(prop, "Volume", "Playback volume of the sound");
2573   RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_SOUND);
2574   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_audio_update");
2575 
2576   prop = RNA_def_property(srna, "pitch", PROP_FLOAT, PROP_NONE);
2577   RNA_def_property_float_sdna(prop, NULL, "pitch");
2578   RNA_def_property_range(prop, 0.1f, 10.0f);
2579   RNA_def_property_ui_text(prop, "Pitch", "Playback pitch of the sound");
2580   RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_SOUND);
2581   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_audio_update");
2582 
2583   prop = RNA_def_property(srna, "pan", PROP_FLOAT, PROP_NONE);
2584   RNA_def_property_float_sdna(prop, NULL, "pan");
2585   RNA_def_property_range(prop, -2.0f, 2.0f);
2586   RNA_def_property_ui_text(prop, "Pan", "Playback panning of the sound (only for Mono sources)");
2587   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_audio_update");
2588 
2589   prop = RNA_def_property(srna, "show_waveform", PROP_BOOLEAN, PROP_NONE);
2590   RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_AUDIO_DRAW_WAVEFORM);
2591   RNA_def_property_ui_text(
2592       prop, "Display Waveform", "Display the audio waveform inside the strip");
2593   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, NULL);
2594 
2595   rna_def_input(srna);
2596 }
2597 
rna_def_effect(BlenderRNA * brna)2598 static void rna_def_effect(BlenderRNA *brna)
2599 {
2600   StructRNA *srna;
2601 
2602   srna = RNA_def_struct(brna, "EffectSequence", "Sequence");
2603   RNA_def_struct_ui_text(
2604       srna,
2605       "Effect Sequence",
2606       "Sequence strip applying an effect on the images created by other strips");
2607   RNA_def_struct_sdna(srna, "Sequence");
2608 
2609   rna_def_filter_video(srna);
2610   rna_def_proxy(srna);
2611 }
2612 
rna_def_multicam(StructRNA * srna)2613 static void rna_def_multicam(StructRNA *srna)
2614 {
2615   PropertyRNA *prop;
2616 
2617   prop = RNA_def_property(srna, "multicam_source", PROP_INT, PROP_UNSIGNED);
2618   RNA_def_property_int_sdna(prop, NULL, "multicam_source");
2619   RNA_def_property_range(prop, 0, MAXSEQ - 1);
2620   RNA_def_property_ui_text(prop, "Multicam Source Channel", "");
2621   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
2622 
2623   rna_def_input(srna);
2624 }
2625 
rna_def_wipe(StructRNA * srna)2626 static void rna_def_wipe(StructRNA *srna)
2627 {
2628   PropertyRNA *prop;
2629 
2630   static const EnumPropertyItem wipe_type_items[] = {
2631       {DO_SINGLE_WIPE, "SINGLE", 0, "Single", ""},
2632       {DO_DOUBLE_WIPE, "DOUBLE", 0, "Double", ""},
2633       /* not used yet {DO_BOX_WIPE, "BOX", 0, "Box", ""}, */
2634       /* not used yet {DO_CROSS_WIPE, "CROSS", 0, "Cross", ""}, */
2635       {DO_IRIS_WIPE, "IRIS", 0, "Iris", ""},
2636       {DO_CLOCK_WIPE, "CLOCK", 0, "Clock", ""},
2637       {0, NULL, 0, NULL, NULL},
2638   };
2639 
2640   static const EnumPropertyItem wipe_direction_items[] = {
2641       {0, "OUT", 0, "Out", ""},
2642       {1, "IN", 0, "In", ""},
2643       {0, NULL, 0, NULL, NULL},
2644   };
2645 
2646   RNA_def_struct_sdna_from(srna, "WipeVars", "effectdata");
2647 
2648   prop = RNA_def_property(srna, "blur_width", PROP_FLOAT, PROP_FACTOR);
2649   RNA_def_property_float_sdna(prop, NULL, "edgeWidth");
2650   RNA_def_property_range(prop, 0.0f, 1.0f);
2651   RNA_def_property_ui_text(
2652       prop, "Blur Width", "Width of the blur edge, in percentage relative to the image size");
2653   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
2654 
2655   prop = RNA_def_property(srna, "angle", PROP_FLOAT, PROP_ANGLE);
2656   RNA_def_property_range(prop, DEG2RADF(-90.0f), DEG2RADF(90.0f));
2657   RNA_def_property_ui_text(prop, "Angle", "Edge angle");
2658   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
2659 
2660   prop = RNA_def_property(srna, "direction", PROP_ENUM, PROP_NONE);
2661   RNA_def_property_enum_sdna(prop, NULL, "forward");
2662   RNA_def_property_enum_items(prop, wipe_direction_items);
2663   RNA_def_property_ui_text(prop, "Direction", "Wipe direction");
2664   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
2665 
2666   prop = RNA_def_property(srna, "transition_type", PROP_ENUM, PROP_NONE);
2667   RNA_def_property_enum_sdna(prop, NULL, "wipetype");
2668   RNA_def_property_enum_items(prop, wipe_type_items);
2669   RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_SEQUENCE);
2670   RNA_def_property_ui_text(prop, "Transition Type", "");
2671   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
2672 }
2673 
rna_def_glow(StructRNA * srna)2674 static void rna_def_glow(StructRNA *srna)
2675 {
2676   PropertyRNA *prop;
2677 
2678   RNA_def_struct_sdna_from(srna, "GlowVars", "effectdata");
2679 
2680   prop = RNA_def_property(srna, "threshold", PROP_FLOAT, PROP_FACTOR);
2681   RNA_def_property_float_sdna(prop, NULL, "fMini");
2682   RNA_def_property_range(prop, 0.0f, 1.0f);
2683   RNA_def_property_ui_text(prop, "Threshold", "Minimum intensity to trigger a glow");
2684   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
2685 
2686   prop = RNA_def_property(srna, "clamp", PROP_FLOAT, PROP_FACTOR);
2687   RNA_def_property_float_sdna(prop, NULL, "fClamp");
2688   RNA_def_property_range(prop, 0.0f, 1.0f);
2689   RNA_def_property_ui_text(prop, "Clamp", "Brightness limit of intensity");
2690   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
2691 
2692   prop = RNA_def_property(srna, "boost_factor", PROP_FLOAT, PROP_NONE);
2693   RNA_def_property_float_sdna(prop, NULL, "fBoost");
2694   RNA_def_property_range(prop, 0.0f, 10.0f);
2695   RNA_def_property_ui_text(prop, "Boost Factor", "Brightness multiplier");
2696   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
2697 
2698   prop = RNA_def_property(srna, "blur_radius", PROP_FLOAT, PROP_NONE);
2699   RNA_def_property_float_sdna(prop, NULL, "dDist");
2700   RNA_def_property_range(prop, 0.5f, 20.0f);
2701   RNA_def_property_ui_text(prop, "Blur Distance", "Radius of glow effect");
2702   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
2703 
2704   prop = RNA_def_property(srna, "quality", PROP_INT, PROP_NONE);
2705   RNA_def_property_int_sdna(prop, NULL, "dQuality");
2706   RNA_def_property_range(prop, 1, 5);
2707   RNA_def_property_ui_text(prop, "Quality", "Accuracy of the blur effect");
2708   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
2709 
2710   prop = RNA_def_property(srna, "use_only_boost", PROP_BOOLEAN, PROP_NONE);
2711   RNA_def_property_boolean_sdna(prop, NULL, "bNoComp", 0);
2712   RNA_def_property_ui_text(prop, "Only Boost", "Show the glow buffer only");
2713   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
2714 }
2715 
rna_def_transform(StructRNA * srna)2716 static void rna_def_transform(StructRNA *srna)
2717 {
2718   PropertyRNA *prop;
2719 
2720   static const EnumPropertyItem interpolation_items[] = {
2721       {0, "NONE", 0, "None", "No interpolation"},
2722       {1, "BILINEAR", 0, "Bilinear", "Bilinear interpolation"},
2723       {2, "BICUBIC", 0, "Bicubic", "Bicubic interpolation"},
2724       {0, NULL, 0, NULL, NULL},
2725   };
2726 
2727   static const EnumPropertyItem translation_unit_items[] = {
2728       {0, "PIXELS", 0, "Pixels", ""},
2729       {1, "PERCENT", 0, "Percent", ""},
2730       {0, NULL, 0, NULL, NULL},
2731   };
2732 
2733   RNA_def_struct_sdna_from(srna, "TransformVars", "effectdata");
2734 
2735   prop = RNA_def_property(srna, "scale_start_x", PROP_FLOAT, PROP_UNSIGNED);
2736   RNA_def_property_float_sdna(prop, NULL, "ScalexIni");
2737   RNA_def_property_ui_text(prop, "Scale X", "Amount to scale the input in the X axis");
2738   RNA_def_property_ui_range(prop, 0, 10, 3, 6);
2739   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
2740 
2741   prop = RNA_def_property(srna, "scale_start_y", PROP_FLOAT, PROP_UNSIGNED);
2742   RNA_def_property_float_sdna(prop, NULL, "ScaleyIni");
2743   RNA_def_property_ui_text(prop, "Scale Y", "Amount to scale the input in the Y axis");
2744   RNA_def_property_ui_range(prop, 0, 10, 3, 6);
2745   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
2746 
2747   prop = RNA_def_property(srna, "use_uniform_scale", PROP_BOOLEAN, PROP_NONE);
2748   RNA_def_property_boolean_sdna(prop, NULL, "uniform_scale", 0);
2749   RNA_def_property_ui_text(prop, "Uniform Scale", "Scale uniformly, preserving aspect ratio");
2750   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
2751 
2752   prop = RNA_def_property(srna, "translate_start_x", PROP_FLOAT, PROP_NONE);
2753   RNA_def_property_float_sdna(prop, NULL, "xIni");
2754   RNA_def_property_ui_text(prop, "Translate X", "Amount to move the input on the X axis");
2755   RNA_def_property_ui_range(prop, -4000.0f, 4000.0f, 3, 6);
2756   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
2757 
2758   prop = RNA_def_property(srna, "translate_start_y", PROP_FLOAT, PROP_NONE);
2759   RNA_def_property_float_sdna(prop, NULL, "yIni");
2760   RNA_def_property_ui_text(prop, "Translate Y", "Amount to move the input on the Y axis");
2761   RNA_def_property_ui_range(prop, -4000.0f, 4000.0f, 3, 6);
2762   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
2763 
2764   prop = RNA_def_property(srna, "rotation_start", PROP_FLOAT, PROP_NONE);
2765   RNA_def_property_float_sdna(prop, NULL, "rotIni");
2766   RNA_def_property_ui_text(prop, "Rotation", "Degrees to rotate the input");
2767   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
2768 
2769   prop = RNA_def_property(srna, "translation_unit", PROP_ENUM, PROP_NONE);
2770   RNA_def_property_enum_sdna(prop, NULL, "percent");
2771   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); /* not meant to be animated */
2772   RNA_def_property_enum_items(prop, translation_unit_items);
2773   RNA_def_property_ui_text(prop, "Translation Unit", "Unit of measure to translate the input");
2774   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
2775 
2776   prop = RNA_def_property(srna, "interpolation", PROP_ENUM, PROP_NONE);
2777   RNA_def_property_enum_items(prop, interpolation_items);
2778   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); /* not meant to be animated */
2779   RNA_def_property_ui_text(
2780       prop, "Interpolation", "Method to determine how missing pixels are created");
2781   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
2782 }
2783 
rna_def_solid_color(StructRNA * srna)2784 static void rna_def_solid_color(StructRNA *srna)
2785 {
2786   PropertyRNA *prop;
2787 
2788   RNA_def_struct_sdna_from(srna, "SolidColorVars", "effectdata");
2789 
2790   prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR_GAMMA);
2791   RNA_def_property_float_sdna(prop, NULL, "col");
2792   RNA_def_property_ui_text(prop, "Color", "Effect Strip color");
2793   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
2794 }
2795 
rna_def_speed_control(StructRNA * srna)2796 static void rna_def_speed_control(StructRNA *srna)
2797 {
2798   PropertyRNA *prop;
2799 
2800   RNA_def_struct_sdna_from(srna, "SpeedControlVars", "effectdata");
2801 
2802   prop = RNA_def_property(srna, "multiply_speed", PROP_FLOAT, PROP_UNSIGNED);
2803   RNA_def_property_float_sdna(prop, NULL, "globalSpeed");
2804   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); /* seq->facf0 is used to animate this */
2805   RNA_def_property_ui_text(
2806       prop, "Multiply Speed", "Multiply the resulting speed after the speed factor");
2807   RNA_def_property_ui_range(prop, 0.0f, 100.0f, 1, -1);
2808   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
2809 
2810   prop = RNA_def_property(srna, "use_as_speed", PROP_BOOLEAN, PROP_NONE);
2811   RNA_def_property_boolean_sdna(prop, NULL, "flags", SEQ_SPEED_INTEGRATE);
2812   RNA_def_property_ui_text(
2813       prop, "Use as Speed", "Interpret the value as speed instead of a frame number");
2814   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
2815 
2816   prop = RNA_def_property(srna, "use_scale_to_length", PROP_BOOLEAN, PROP_NONE);
2817   RNA_def_property_boolean_sdna(prop, NULL, "flags", SEQ_SPEED_COMPRESS_IPO_Y);
2818   RNA_def_property_ui_text(
2819       prop, "Scale to Length", "Scale values from 0.0 to 1.0 to target sequence length");
2820   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
2821 
2822   prop = RNA_def_property(srna, "use_frame_interpolate", PROP_BOOLEAN, PROP_NONE);
2823   RNA_def_property_boolean_sdna(prop, NULL, "flags", SEQ_SPEED_USE_INTERPOLATION);
2824   RNA_def_property_ui_text(
2825       prop, "Frame interpolation", "Do crossfade blending between current and next frame");
2826   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
2827 }
2828 
rna_def_gaussian_blur(StructRNA * srna)2829 static void rna_def_gaussian_blur(StructRNA *srna)
2830 {
2831   PropertyRNA *prop;
2832 
2833   RNA_def_struct_sdna_from(srna, "GaussianBlurVars", "effectdata");
2834   prop = RNA_def_property(srna, "size_x", PROP_FLOAT, PROP_UNSIGNED);
2835   RNA_def_property_ui_text(prop, "Size X", "Size of the blur along X axis");
2836   RNA_def_property_ui_range(prop, 0.0f, FLT_MAX, 1, -1);
2837   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
2838 
2839   prop = RNA_def_property(srna, "size_y", PROP_FLOAT, PROP_UNSIGNED);
2840   RNA_def_property_ui_text(prop, "Size Y", "Size of the blur along Y axis");
2841   RNA_def_property_ui_range(prop, 0.0f, FLT_MAX, 1, -1);
2842   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
2843 }
2844 
rna_def_text(StructRNA * srna)2845 static void rna_def_text(StructRNA *srna)
2846 {
2847   /* Avoid text icons because they imply this aligns within a frame, see: T71082 */
2848   static const EnumPropertyItem text_align_x_items[] = {
2849       {SEQ_TEXT_ALIGN_X_LEFT, "LEFT", ICON_ANCHOR_LEFT, "Left", ""},
2850       {SEQ_TEXT_ALIGN_X_CENTER, "CENTER", ICON_ANCHOR_CENTER, "Center", ""},
2851       {SEQ_TEXT_ALIGN_X_RIGHT, "RIGHT", ICON_ANCHOR_RIGHT, "Right", ""},
2852       {0, NULL, 0, NULL, NULL},
2853   };
2854   static const EnumPropertyItem text_align_y_items[] = {
2855       {SEQ_TEXT_ALIGN_Y_TOP, "TOP", ICON_ANCHOR_TOP, "Top", ""},
2856       {SEQ_TEXT_ALIGN_Y_CENTER, "CENTER", ICON_ANCHOR_CENTER, "Center", ""},
2857       {SEQ_TEXT_ALIGN_Y_BOTTOM, "BOTTOM", ICON_ANCHOR_BOTTOM, "Bottom", ""},
2858       {0, NULL, 0, NULL, NULL},
2859   };
2860 
2861   PropertyRNA *prop;
2862 
2863   RNA_def_struct_sdna_from(srna, "TextVars", "effectdata");
2864 
2865   prop = RNA_def_property(srna, "font", PROP_POINTER, PROP_NONE);
2866   RNA_def_property_pointer_sdna(prop, NULL, "text_font");
2867   RNA_def_property_ui_icon(prop, ICON_FILE_FONT, false);
2868   RNA_def_property_ui_text(prop, "Font", "Font of the text. Falls back to the UI font by default");
2869   RNA_def_property_flag(prop, PROP_EDITABLE);
2870   RNA_def_property_pointer_funcs(prop, NULL, "rna_Sequence_text_font_set", NULL, NULL);
2871   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
2872 
2873   prop = RNA_def_property(srna, "font_size", PROP_INT, PROP_UNSIGNED);
2874   RNA_def_property_int_sdna(prop, NULL, "text_size");
2875   RNA_def_property_ui_text(prop, "Size", "Size of the text");
2876   RNA_def_property_range(prop, 0.0, 2000);
2877   RNA_def_property_ui_range(prop, 0.0f, 1000, 1, -1);
2878   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
2879 
2880   prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR_GAMMA);
2881   RNA_def_property_float_sdna(prop, NULL, "color");
2882   RNA_def_property_ui_text(prop, "Color", "Text color");
2883   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
2884 
2885   prop = RNA_def_property(srna, "shadow_color", PROP_FLOAT, PROP_COLOR_GAMMA);
2886   RNA_def_property_float_sdna(prop, NULL, "shadow_color");
2887   RNA_def_property_ui_text(prop, "Shadow Color", "");
2888   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
2889 
2890   prop = RNA_def_property(srna, "location", PROP_FLOAT, PROP_XYZ);
2891   RNA_def_property_float_sdna(prop, NULL, "loc");
2892   RNA_def_property_ui_text(prop, "Location", "Location of the text");
2893   RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
2894   RNA_def_property_ui_range(prop, 0.0, 1.0, 1, -1);
2895   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
2896 
2897   prop = RNA_def_property(srna, "wrap_width", PROP_FLOAT, PROP_NONE);
2898   RNA_def_property_float_sdna(prop, NULL, "wrap_width");
2899   RNA_def_property_ui_text(prop, "Wrap Width", "Word wrap width as factor, zero disables");
2900   RNA_def_property_range(prop, 0, FLT_MAX);
2901   RNA_def_property_ui_range(prop, 0.0, 1.0, 1, -1);
2902   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
2903 
2904   prop = RNA_def_property(srna, "align_x", PROP_ENUM, PROP_NONE);
2905   RNA_def_property_enum_sdna(prop, NULL, "align");
2906   RNA_def_property_enum_items(prop, text_align_x_items);
2907   RNA_def_property_ui_text(
2908       prop, "Align X", "Align the text along the X axis, relative to the text bounds");
2909   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
2910 
2911   prop = RNA_def_property(srna, "align_y", PROP_ENUM, PROP_NONE);
2912   RNA_def_property_enum_sdna(prop, NULL, "align_y");
2913   RNA_def_property_enum_items(prop, text_align_y_items);
2914   RNA_def_property_ui_text(
2915       prop, "Align Y", "Align the text along the Y axis, relative to the text bounds");
2916   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
2917 
2918   prop = RNA_def_property(srna, "text", PROP_STRING, PROP_NONE);
2919   RNA_def_property_ui_text(prop, "Text", "Text that will be displayed");
2920   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
2921 
2922   prop = RNA_def_property(srna, "use_shadow", PROP_BOOLEAN, PROP_NONE);
2923   RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_TEXT_SHADOW);
2924   RNA_def_property_ui_text(prop, "Shadow", "Display shadow behind text");
2925   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
2926 }
2927 
rna_def_color_mix(StructRNA * srna)2928 static void rna_def_color_mix(StructRNA *srna)
2929 {
2930   static EnumPropertyItem blend_color_items[] = {
2931       {SEQ_TYPE_DARKEN, "DARKEN", 0, "Darken", ""},
2932       {SEQ_TYPE_MUL, "MULTIPLY", 0, "Multiply", ""},
2933       {SEQ_TYPE_COLOR_BURN, "BURN", 0, "Color Burn", ""},
2934       {SEQ_TYPE_LINEAR_BURN, "LINEAR_BURN", 0, "Linear Burn", ""},
2935       {0, "", ICON_NONE, NULL, NULL},
2936       {SEQ_TYPE_LIGHTEN, "LIGHTEN", 0, "Lighten", ""},
2937       {SEQ_TYPE_SCREEN, "SCREEN", 0, "Screen", ""},
2938       {SEQ_TYPE_DODGE, "DODGE", 0, "Color Dodge", ""},
2939       {SEQ_TYPE_ADD, "ADD", 0, "Add", ""},
2940       {0, "", ICON_NONE, NULL, NULL},
2941       {SEQ_TYPE_OVERLAY, "OVERLAY", 0, "Overlay", ""},
2942       {SEQ_TYPE_SOFT_LIGHT, "SOFT_LIGHT", 0, "Soft Light", ""},
2943       {SEQ_TYPE_HARD_LIGHT, "HARD_LIGHT", 0, "Hard Light", ""},
2944       {SEQ_TYPE_VIVID_LIGHT, "VIVID_LIGHT", 0, "Vivid Light", ""},
2945       {SEQ_TYPE_LIN_LIGHT, "LINEAR_LIGHT", 0, "Linear Light", ""},
2946       {SEQ_TYPE_PIN_LIGHT, "PIN_LIGHT", 0, "Pin Light", ""},
2947       {0, "", ICON_NONE, NULL, NULL},
2948       {SEQ_TYPE_DIFFERENCE, "DIFFERENCE", 0, "Difference", ""},
2949       {SEQ_TYPE_EXCLUSION, "EXCLUSION", 0, "Exclusion", ""},
2950       {SEQ_TYPE_SUB, "SUBTRACT", 0, "Subtract", ""},
2951       {0, "", ICON_NONE, NULL, NULL},
2952       {SEQ_TYPE_HUE, "HUE", 0, "Hue", ""},
2953       {SEQ_TYPE_SATURATION, "SATURATION", 0, "Saturation", ""},
2954       {SEQ_TYPE_BLEND_COLOR, "COLOR", 0, "Color", ""},
2955       {SEQ_TYPE_VALUE, "VALUE", 0, "Value", ""},
2956       {0, NULL, 0, NULL, NULL},
2957   };
2958 
2959   PropertyRNA *prop;
2960 
2961   RNA_def_struct_sdna_from(srna, "ColorMixVars", "effectdata");
2962 
2963   prop = RNA_def_property(srna, "blend_effect", PROP_ENUM, PROP_NONE);
2964   RNA_def_property_enum_sdna(prop, NULL, "blend_effect");
2965   RNA_def_property_enum_items(prop, blend_color_items);
2966   RNA_def_property_ui_text(
2967       prop, "Blending Mode", "Method for controlling how the strip combines with other strips");
2968   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
2969 
2970   prop = RNA_def_property(srna, "factor", PROP_FLOAT, PROP_FACTOR);
2971   RNA_def_property_range(prop, 0.0f, 1.0f);
2972   RNA_def_property_ui_text(
2973       prop, "Blend Factor", "Percentage of how much the strip's colors affect other strips");
2974   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
2975 }
2976 
2977 static EffectInfo def_effects[] = {
2978     {"AddSequence", "Add Sequence", "Add Sequence", NULL, 2},
2979     {"AdjustmentSequence",
2980      "Adjustment Layer Sequence",
2981      "Sequence strip to perform filter adjustments to layers below",
2982      rna_def_input,
2983      0},
2984     {"AlphaOverSequence", "Alpha Over Sequence", "Alpha Over Sequence", NULL, 2},
2985     {"AlphaUnderSequence", "Alpha Under Sequence", "Alpha Under Sequence", NULL, 2},
2986     {"ColorSequence",
2987      "Color Sequence",
2988      "Sequence strip creating an image filled with a single color",
2989      rna_def_solid_color,
2990      0},
2991     {"CrossSequence", "Cross Sequence", "Cross Sequence", NULL, 2},
2992     {"GammaCrossSequence", "Gamma Cross Sequence", "Gamma Cross Sequence", NULL, 2},
2993     {"GlowSequence", "Glow Sequence", "Sequence strip creating a glow effect", rna_def_glow, 1},
2994     {"MulticamSequence",
2995      "Multicam Select Sequence",
2996      "Sequence strip to perform multicam editing",
2997      rna_def_multicam,
2998      0},
2999     {"MultiplySequence", "Multiply Sequence", "Multiply Sequence", NULL, 2},
3000     {"OverDropSequence", "Over Drop Sequence", "Over Drop Sequence", NULL, 2},
3001     {"SpeedControlSequence",
3002      "SpeedControl Sequence",
3003      "Sequence strip to control the speed of other strips",
3004      rna_def_speed_control,
3005      1},
3006     {"SubtractSequence", "Subtract Sequence", "Subtract Sequence", NULL, 2},
3007     {"TransformSequence",
3008      "Transform Sequence",
3009      "Sequence strip applying affine transformations to other strips",
3010      rna_def_transform,
3011      1},
3012     {"WipeSequence",
3013      "Wipe Sequence",
3014      "Sequence strip creating a wipe transition",
3015      rna_def_wipe,
3016      2},
3017     {"GaussianBlurSequence",
3018      "Gaussian Blur Sequence",
3019      "Sequence strip creating a gaussian blur",
3020      rna_def_gaussian_blur,
3021      1},
3022     {"TextSequence", "Text Sequence", "Sequence strip creating text", rna_def_text, 0},
3023     {"ColorMixSequence", "Color Mix Sequence", "Color Mix Sequence", rna_def_color_mix, 2},
3024     {"", "", "", NULL, 0},
3025 };
3026 
rna_def_effects(BlenderRNA * brna)3027 static void rna_def_effects(BlenderRNA *brna)
3028 {
3029   StructRNA *srna;
3030   EffectInfo *effect;
3031 
3032   for (effect = def_effects; effect->struct_name[0] != '\0'; effect++) {
3033     srna = RNA_def_struct(brna, effect->struct_name, "EffectSequence");
3034     RNA_def_struct_ui_text(srna, effect->ui_name, effect->ui_desc);
3035     RNA_def_struct_sdna(srna, "Sequence");
3036 
3037     rna_def_effect_inputs(srna, effect->inputs);
3038 
3039     if (effect->func) {
3040       effect->func(srna);
3041     }
3042   }
3043 }
3044 
rna_def_modifier(BlenderRNA * brna)3045 static void rna_def_modifier(BlenderRNA *brna)
3046 {
3047   StructRNA *srna;
3048   PropertyRNA *prop;
3049 
3050   static const EnumPropertyItem mask_input_type_items[] = {
3051       {SEQUENCE_MASK_INPUT_STRIP, "STRIP", 0, "Strip", "Use sequencer strip as mask input"},
3052       {SEQUENCE_MASK_INPUT_ID, "ID", 0, "Mask", "Use mask ID as mask input"},
3053       {0, NULL, 0, NULL, NULL},
3054   };
3055 
3056   static const EnumPropertyItem mask_time_items[] = {
3057       {SEQUENCE_MASK_TIME_RELATIVE,
3058        "RELATIVE",
3059        0,
3060        "Relative",
3061        "Mask animation is offset to start of strip"},
3062       {SEQUENCE_MASK_TIME_ABSOLUTE,
3063        "ABSOLUTE",
3064        0,
3065        "Absolute",
3066        "Mask animation is in sync with scene frame"},
3067       {0, NULL, 0, NULL, NULL},
3068   };
3069 
3070   srna = RNA_def_struct(brna, "SequenceModifier", NULL);
3071   RNA_def_struct_sdna(srna, "SequenceModifierData");
3072   RNA_def_struct_ui_text(srna, "SequenceModifier", "Modifier for sequence strip");
3073   RNA_def_struct_refine_func(srna, "rna_SequenceModifier_refine");
3074   RNA_def_struct_path_func(srna, "rna_SequenceModifier_path");
3075 
3076   prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
3077   RNA_def_property_string_funcs(prop, NULL, NULL, "rna_SequenceModifier_name_set");
3078   RNA_def_property_ui_text(prop, "Name", "");
3079   RNA_def_struct_name_property(srna, prop);
3080   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, NULL);
3081 
3082   prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
3083   RNA_def_property_clear_flag(prop, PROP_EDITABLE);
3084   RNA_def_property_enum_items(prop, rna_enum_sequence_modifier_type_items);
3085   RNA_def_property_ui_text(prop, "Type", "");
3086   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, NULL);
3087 
3088   prop = RNA_def_property(srna, "mute", PROP_BOOLEAN, PROP_NONE);
3089   RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQUENCE_MODIFIER_MUTE);
3090   RNA_def_property_ui_text(prop, "Mute", "Mute this modifier");
3091   RNA_def_property_ui_icon(prop, ICON_HIDE_OFF, -1);
3092   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceModifier_update");
3093 
3094   prop = RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE);
3095   RNA_def_property_flag(prop, PROP_NO_DEG_UPDATE);
3096   RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQUENCE_MODIFIER_EXPANDED);
3097   RNA_def_property_ui_text(prop, "Expanded", "Mute expanded settings for the modifier");
3098   RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1);
3099   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, NULL);
3100 
3101   prop = RNA_def_property(srna, "input_mask_type", PROP_ENUM, PROP_NONE);
3102   RNA_def_property_enum_sdna(prop, NULL, "mask_input_type");
3103   RNA_def_property_enum_items(prop, mask_input_type_items);
3104   RNA_def_property_ui_text(prop, "Mask Input Type", "Type of input data used for mask");
3105   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceModifier_update");
3106 
3107   prop = RNA_def_property(srna, "mask_time", PROP_ENUM, PROP_NONE);
3108   RNA_def_property_enum_sdna(prop, NULL, "mask_time");
3109   RNA_def_property_enum_items(prop, mask_time_items);
3110   RNA_def_property_ui_text(prop, "Mask Time", "Time to use for the Mask animation");
3111   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceModifier_update");
3112 
3113   prop = RNA_def_property(srna, "input_mask_strip", PROP_POINTER, PROP_NONE);
3114   RNA_def_property_pointer_sdna(prop, NULL, "mask_sequence");
3115   RNA_def_property_pointer_funcs(prop,
3116                                  NULL,
3117                                  "rna_SequenceModifier_strip_set",
3118                                  NULL,
3119                                  "rna_SequenceModifier_otherSequence_poll");
3120   RNA_def_property_flag(prop, PROP_EDITABLE);
3121   RNA_def_property_ui_text(prop, "Mask Strip", "Strip used as mask input for the modifier");
3122   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceModifier_update");
3123 
3124   prop = RNA_def_property(srna, "input_mask_id", PROP_POINTER, PROP_NONE);
3125   RNA_def_property_pointer_sdna(prop, NULL, "mask_id");
3126   RNA_def_property_flag(prop, PROP_EDITABLE);
3127   RNA_def_property_ui_text(prop, "Mask", "Mask ID used as mask input for the modifier");
3128   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceModifier_update");
3129 }
3130 
rna_def_colorbalance_modifier(BlenderRNA * brna)3131 static void rna_def_colorbalance_modifier(BlenderRNA *brna)
3132 {
3133   StructRNA *srna;
3134   PropertyRNA *prop;
3135 
3136   srna = RNA_def_struct(brna, "ColorBalanceModifier", "SequenceModifier");
3137   RNA_def_struct_sdna(srna, "ColorBalanceModifierData");
3138   RNA_def_struct_ui_text(
3139       srna, "ColorBalanceModifier", "Color balance modifier for sequence strip");
3140 
3141   prop = RNA_def_property(srna, "color_balance", PROP_POINTER, PROP_NONE);
3142   RNA_def_property_struct_type(prop, "SequenceColorBalanceData");
3143 
3144   prop = RNA_def_property(srna, "color_multiply", PROP_FLOAT, PROP_UNSIGNED);
3145   RNA_def_property_float_sdna(prop, NULL, "color_multiply");
3146   RNA_def_property_range(prop, 0.0f, 20.0f);
3147   RNA_def_property_float_default(prop, 1.0f);
3148   RNA_def_property_ui_text(prop, "Multiply Colors", "Multiply the intensity of each pixel");
3149   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceModifier_update");
3150 }
3151 
rna_def_whitebalance_modifier(BlenderRNA * brna)3152 static void rna_def_whitebalance_modifier(BlenderRNA *brna)
3153 {
3154   StructRNA *srna;
3155   PropertyRNA *prop;
3156 
3157   srna = RNA_def_struct(brna, "WhiteBalanceModifier", "SequenceModifier");
3158   RNA_def_struct_sdna(srna, "WhiteBalanceModifierData");
3159   RNA_def_struct_ui_text(
3160       srna, "WhiteBalanceModifier", "White balance modifier for sequence strip");
3161 
3162   prop = RNA_def_property(srna, "white_value", PROP_FLOAT, PROP_COLOR_GAMMA);
3163   RNA_def_property_range(prop, 0.0, 1.0);
3164   RNA_def_property_float_sdna(prop, NULL, "white_value");
3165   RNA_def_property_ui_text(prop, "White Value", "This color defines white in the strip");
3166   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceModifier_update");
3167 }
3168 
rna_def_curves_modifier(BlenderRNA * brna)3169 static void rna_def_curves_modifier(BlenderRNA *brna)
3170 {
3171   StructRNA *srna;
3172   PropertyRNA *prop;
3173 
3174   srna = RNA_def_struct(brna, "CurvesModifier", "SequenceModifier");
3175   RNA_def_struct_sdna(srna, "CurvesModifierData");
3176   RNA_def_struct_ui_text(srna, "CurvesModifier", "RGB curves modifier for sequence strip");
3177 
3178   prop = RNA_def_property(srna, "curve_mapping", PROP_POINTER, PROP_NONE);
3179   RNA_def_property_pointer_sdna(prop, NULL, "curve_mapping");
3180   RNA_def_property_struct_type(prop, "CurveMapping");
3181   RNA_def_property_ui_text(prop, "Curve Mapping", "");
3182   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceModifier_update");
3183 }
3184 
rna_def_hue_modifier(BlenderRNA * brna)3185 static void rna_def_hue_modifier(BlenderRNA *brna)
3186 {
3187   StructRNA *srna;
3188   PropertyRNA *prop;
3189 
3190   srna = RNA_def_struct(brna, "HueCorrectModifier", "SequenceModifier");
3191   RNA_def_struct_sdna(srna, "HueCorrectModifierData");
3192   RNA_def_struct_ui_text(srna, "HueCorrectModifier", "Hue correction modifier for sequence strip");
3193 
3194   prop = RNA_def_property(srna, "curve_mapping", PROP_POINTER, PROP_NONE);
3195   RNA_def_property_pointer_sdna(prop, NULL, "curve_mapping");
3196   RNA_def_property_struct_type(prop, "CurveMapping");
3197   RNA_def_property_ui_text(prop, "Curve Mapping", "");
3198   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceModifier_update");
3199 }
3200 
rna_def_brightcontrast_modifier(BlenderRNA * brna)3201 static void rna_def_brightcontrast_modifier(BlenderRNA *brna)
3202 {
3203   StructRNA *srna;
3204   PropertyRNA *prop;
3205 
3206   srna = RNA_def_struct(brna, "BrightContrastModifier", "SequenceModifier");
3207   RNA_def_struct_sdna(srna, "BrightContrastModifierData");
3208   RNA_def_struct_ui_text(
3209       srna, "BrightContrastModifier", "Bright/contrast modifier data for sequence strip");
3210 
3211   prop = RNA_def_property(srna, "bright", PROP_FLOAT, PROP_UNSIGNED);
3212   RNA_def_property_float_sdna(prop, NULL, "bright");
3213   RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
3214   RNA_def_property_ui_text(prop, "Bright", "Adjust the luminosity of the colors");
3215   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceModifier_update");
3216 
3217   prop = RNA_def_property(srna, "contrast", PROP_FLOAT, PROP_UNSIGNED);
3218   RNA_def_property_float_sdna(prop, NULL, "contrast");
3219   RNA_def_property_range(prop, -100.0f, 100.0f);
3220   RNA_def_property_ui_text(prop, "Contrast", "Adjust the difference in luminosity between pixels");
3221   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceModifier_update");
3222 }
3223 
rna_def_tonemap_modifier(BlenderRNA * brna)3224 static void rna_def_tonemap_modifier(BlenderRNA *brna)
3225 {
3226   StructRNA *srna;
3227   PropertyRNA *prop;
3228 
3229   static const EnumPropertyItem type_items[] = {
3230       {SEQ_TONEMAP_RD_PHOTORECEPTOR, "RD_PHOTORECEPTOR", 0, "R/D Photoreceptor", ""},
3231       {SEQ_TONEMAP_RH_SIMPLE, "RH_SIMPLE", 0, "Rh Simple", ""},
3232       {0, NULL, 0, NULL, NULL},
3233   };
3234 
3235   srna = RNA_def_struct(brna, "SequencerTonemapModifierData", "SequenceModifier");
3236   RNA_def_struct_sdna(srna, "SequencerTonemapModifierData");
3237   RNA_def_struct_ui_text(srna, "SequencerTonemapModifierData", "Tone mapping modifier");
3238 
3239   prop = RNA_def_property(srna, "tonemap_type", PROP_ENUM, PROP_NONE);
3240   RNA_def_property_enum_sdna(prop, NULL, "type");
3241   RNA_def_property_enum_items(prop, type_items);
3242   RNA_def_property_ui_text(prop, "Tonemap Type", "Tone mapping algorithm");
3243   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceModifier_update");
3244 
3245   prop = RNA_def_property(srna, "key", PROP_FLOAT, PROP_FACTOR);
3246   RNA_def_property_range(prop, 0.0f, 1.0f);
3247   RNA_def_property_ui_text(prop, "Key", "The value the average luminance is mapped to");
3248   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceModifier_update");
3249 
3250   prop = RNA_def_property(srna, "offset", PROP_FLOAT, PROP_NONE);
3251   RNA_def_property_range(prop, 0.001f, 10.0f);
3252   RNA_def_property_ui_text(
3253       prop,
3254       "Offset",
3255       "Normally always 1, but can be used as an extra control to alter the brightness curve");
3256   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceModifier_update");
3257 
3258   prop = RNA_def_property(srna, "gamma", PROP_FLOAT, PROP_NONE);
3259   RNA_def_property_range(prop, 0.001f, 3.0f);
3260   RNA_def_property_ui_text(prop, "Gamma", "If not used, set to 1");
3261   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceModifier_update");
3262 
3263   prop = RNA_def_property(srna, "intensity", PROP_FLOAT, PROP_NONE);
3264   RNA_def_property_range(prop, -8.0f, 8.0f);
3265   RNA_def_property_ui_text(
3266       prop, "Intensity", "If less than zero, darkens image; otherwise, makes it brighter");
3267   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceModifier_update");
3268 
3269   prop = RNA_def_property(srna, "contrast", PROP_FLOAT, PROP_FACTOR);
3270   RNA_def_property_range(prop, 0.0f, 1.0f);
3271   RNA_def_property_ui_text(prop, "Contrast", "Set to 0 to use estimate from input image");
3272   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceModifier_update");
3273 
3274   prop = RNA_def_property(srna, "adaptation", PROP_FLOAT, PROP_FACTOR);
3275   RNA_def_property_range(prop, 0.0f, 1.0f);
3276   RNA_def_property_ui_text(prop, "Adaptation", "If 0, global; if 1, based on pixel intensity");
3277   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceModifier_update");
3278 
3279   prop = RNA_def_property(srna, "correction", PROP_FLOAT, PROP_FACTOR);
3280   RNA_def_property_range(prop, 0.0f, 1.0f);
3281   RNA_def_property_ui_text(
3282       prop, "Color Correction", "If 0, same for all channels; if 1, each independent");
3283   RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceModifier_update");
3284 }
3285 
rna_def_modifiers(BlenderRNA * brna)3286 static void rna_def_modifiers(BlenderRNA *brna)
3287 {
3288   rna_def_modifier(brna);
3289 
3290   rna_def_colorbalance_modifier(brna);
3291   rna_def_curves_modifier(brna);
3292   rna_def_hue_modifier(brna);
3293   rna_def_brightcontrast_modifier(brna);
3294   rna_def_whitebalance_modifier(brna);
3295   rna_def_tonemap_modifier(brna);
3296 }
3297 
RNA_def_sequencer(BlenderRNA * brna)3298 void RNA_def_sequencer(BlenderRNA *brna)
3299 {
3300   rna_def_color_balance(brna);
3301 
3302   rna_def_strip_element(brna);
3303   rna_def_strip_proxy(brna);
3304   rna_def_strip_color_balance(brna);
3305   rna_def_strip_crop(brna);
3306   rna_def_strip_transform(brna);
3307 
3308   rna_def_sequence(brna);
3309   rna_def_editor(brna);
3310 
3311   rna_def_image(brna);
3312   rna_def_meta(brna);
3313   rna_def_scene(brna);
3314   rna_def_movie(brna);
3315   rna_def_movieclip(brna);
3316   rna_def_mask(brna);
3317   rna_def_sound(brna);
3318   rna_def_effect(brna);
3319   rna_def_effects(brna);
3320   rna_def_modifiers(brna);
3321 }
3322 
3323 #endif
3324