~ubuntu-branches/ubuntu/trusty/blender/trusty

« back to all changes in this revision

Viewing changes to source/blender/editors/space_sequencer/sequencer_edit.c

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-03-06 12:08:47 UTC
  • mfrom: (1.5.1) (14.1.8 experimental)
  • Revision ID: package-import@ubuntu.com-20130306120847-frjfaryb2zrotwcg
Tags: 2.66a-1ubuntu1
* Resynchronize with Debian (LP: #1076930, #1089256, #1052743, #999024,
  #1122888, #1147084)
* debian/control:
  - Lower build-depends on libavcodec-dev since we're not
    doing the libav9 transition in Ubuntu yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
#include "BLI_utildefines.h"
47
47
#include "BLI_threads.h"
48
48
 
 
49
#include "BLF_translation.h"
 
50
 
49
51
#include "DNA_scene_types.h"
50
52
#include "DNA_userdef_types.h"
51
53
 
79
81
/* XXX */
80
82
/* RNA Enums, used in multiple files */
81
83
EnumPropertyItem sequencer_prop_effect_types[] = {
82
 
        {SEQ_CROSS, "CROSS", 0, "Crossfade", "Crossfade effect strip type"},
83
 
        {SEQ_ADD, "ADD", 0, "Add", "Add effect strip type"},
84
 
        {SEQ_SUB, "SUBTRACT", 0, "Subtract", "Subtract effect strip type"},
85
 
        {SEQ_ALPHAOVER, "ALPHA_OVER", 0, "Alpha Over", "Alpha Over effect strip type"},
86
 
        {SEQ_ALPHAUNDER, "ALPHA_UNDER", 0, "Alpha Under", "Alpha Under effect strip type"},
87
 
        {SEQ_GAMCROSS, "GAMMA_CROSS", 0, "Gamma Cross", "Gamma Cross effect strip type"},
88
 
        {SEQ_MUL, "MULTIPLY", 0, "Multiply", "Multiply effect strip type"},
89
 
        {SEQ_OVERDROP, "OVER_DROP", 0, "Alpha Over Drop", "Alpha Over Drop effect strip type"},
90
 
        {SEQ_PLUGIN, "PLUGIN", 0, "Plugin", "Plugin effect strip type"},
91
 
        {SEQ_WIPE, "WIPE", 0, "Wipe", "Wipe effect strip type"},
92
 
        {SEQ_GLOW, "GLOW", 0, "Glow", "Glow effect strip type"},
93
 
        {SEQ_TRANSFORM, "TRANSFORM", 0, "Transform", "Transform effect strip type"},
94
 
        {SEQ_COLOR, "COLOR", 0, "Color", "Color effect strip type"},
95
 
        {SEQ_SPEED, "SPEED", 0, "Speed", "Color effect strip type"},
96
 
        {SEQ_MULTICAM, "MULTICAM", 0, "Multicam Selector", ""},
97
 
        {SEQ_ADJUSTMENT, "ADJUSTMENT", 0, "Adjustment Layer", ""},
 
84
        {SEQ_TYPE_CROSS, "CROSS", 0, "Crossfade", "Crossfade effect strip type"},
 
85
        {SEQ_TYPE_ADD, "ADD", 0, "Add", "Add effect strip type"},
 
86
        {SEQ_TYPE_SUB, "SUBTRACT", 0, "Subtract", "Subtract effect strip type"},
 
87
        {SEQ_TYPE_ALPHAOVER, "ALPHA_OVER", 0, "Alpha Over", "Alpha Over effect strip type"},
 
88
        {SEQ_TYPE_ALPHAUNDER, "ALPHA_UNDER", 0, "Alpha Under", "Alpha Under effect strip type"},
 
89
        {SEQ_TYPE_GAMCROSS, "GAMMA_CROSS", 0, "Gamma Cross", "Gamma Cross effect strip type"},
 
90
        {SEQ_TYPE_MUL, "MULTIPLY", 0, "Multiply", "Multiply effect strip type"},
 
91
        {SEQ_TYPE_OVERDROP, "OVER_DROP", 0, "Alpha Over Drop", "Alpha Over Drop effect strip type"},
 
92
        {SEQ_TYPE_WIPE, "WIPE", 0, "Wipe", "Wipe effect strip type"},
 
93
        {SEQ_TYPE_GLOW, "GLOW", 0, "Glow", "Glow effect strip type"},
 
94
        {SEQ_TYPE_TRANSFORM, "TRANSFORM", 0, "Transform", "Transform effect strip type"},
 
95
        {SEQ_TYPE_COLOR, "COLOR", 0, "Color", "Color effect strip type"},
 
96
        {SEQ_TYPE_SPEED, "SPEED", 0, "Speed", "Color effect strip type"},
 
97
        {SEQ_TYPE_MULTICAM, "MULTICAM", 0, "Multicam Selector", ""},
 
98
        {SEQ_TYPE_ADJUSTMENT, "ADJUSTMENT", 0, "Adjustment Layer", ""},
98
99
        {0, NULL, 0, NULL, NULL}
99
100
};
100
101
 
152
153
        for (link = pj->queue.first; link; link = link->next) {
153
154
                struct SeqIndexBuildContext *context = link->data;
154
155
 
155
 
                seq_proxy_rebuild(context, stop, do_update, progress);
 
156
                BKE_sequencer_proxy_rebuild(context, stop, do_update, progress);
156
157
        }
157
158
 
158
159
        if (*stop) {
164
165
static void proxy_endjob(void *pjv)
165
166
{
166
167
        ProxyJob *pj = pjv;
167
 
        Editing *ed = seq_give_editing(pj->scene, FALSE);
 
168
        Editing *ed = BKE_sequencer_editing_get(pj->scene, FALSE);
168
169
        LinkData *link;
169
170
 
170
171
        for (link = pj->queue.first; link; link = link->next) {
171
 
                seq_proxy_rebuild_finish(link->data, pj->stop);
 
172
                BKE_sequencer_proxy_rebuild_finish(link->data, pj->stop);
172
173
        }
173
174
 
174
 
        free_imbuf_seq(pj->scene, &ed->seqbase, FALSE, FALSE);
 
175
        BKE_sequencer_free_imbuf(pj->scene, &ed->seqbase, FALSE);
175
176
 
176
177
        WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, pj->scene);
177
178
}
178
179
 
179
180
static void seq_proxy_build_job(const bContext *C)
180
181
{
181
 
        wmJob *steve;
 
182
        wmJob *wm_job;
182
183
        ProxyJob *pj;
183
184
        Scene *scene = CTX_data_scene(C);
184
 
        Editing *ed = seq_give_editing(scene, FALSE);
 
185
        Editing *ed = BKE_sequencer_editing_get(scene, FALSE);
185
186
        ScrArea *sa = CTX_wm_area(C);
186
187
        struct SeqIndexBuildContext *context;
187
188
        LinkData *link;
188
189
        Sequence *seq;
189
190
 
190
 
        steve = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), sa, "Building Proxies", WM_JOB_PROGRESS);
 
191
        wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), sa, "Building Proxies",
 
192
                             WM_JOB_PROGRESS, WM_JOB_TYPE_SEQ_BUILD_PROXY);
191
193
 
192
 
        pj = WM_jobs_get_customdata(steve);
 
194
        pj = WM_jobs_customdata_get(wm_job);
193
195
 
194
196
        if (!pj) {
195
197
                pj = MEM_callocN(sizeof(ProxyJob), "proxy rebuild job");
197
199
                pj->scene = scene;
198
200
                pj->main = CTX_data_main(C);
199
201
 
200
 
                WM_jobs_customdata(steve, pj, proxy_freejob);
201
 
                WM_jobs_timer(steve, 0.1, NC_SCENE | ND_SEQUENCER, NC_SCENE | ND_SEQUENCER);
202
 
                WM_jobs_callbacks(steve, proxy_startjob, NULL, NULL, proxy_endjob);
 
202
                WM_jobs_customdata_set(wm_job, pj, proxy_freejob);
 
203
                WM_jobs_timer(wm_job, 0.1, NC_SCENE | ND_SEQUENCER, NC_SCENE | ND_SEQUENCER);
 
204
                WM_jobs_callbacks(wm_job, proxy_startjob, NULL, NULL, proxy_endjob);
203
205
        }
204
206
 
205
 
        SEQP_BEGIN(ed, seq) {
 
207
        SEQP_BEGIN (ed, seq)
 
208
        {
206
209
                if ((seq->flag & SELECT)) {
207
 
                        context = seq_proxy_rebuild_context(pj->main, pj->scene, seq);
 
210
                        context = BKE_sequencer_proxy_rebuild_context(pj->main, pj->scene, seq);
208
211
                        link = BLI_genericNodeN(context);
209
212
                        BLI_addtail(&pj->queue, link);
210
213
                }
211
214
        }
212
215
        SEQ_END
213
216
 
214
 
        if (!WM_jobs_is_running(steve)) {
215
 
                G.afbreek = 0;
216
 
                WM_jobs_start(CTX_wm_manager(C), steve);
 
217
        if (!WM_jobs_is_running(wm_job)) {
 
218
                G.is_break = FALSE;
 
219
                WM_jobs_start(CTX_wm_manager(C), wm_job);
217
220
        }
218
221
 
219
222
        ED_area_tag_redraw(CTX_wm_area(C));
231
234
        rectf->ymax = seq->machine + SEQ_STRIP_OFSTOP;
232
235
}
233
236
 
234
 
static void UNUSED_FUNCTION(change_plugin_seq) (Scene * scene, char *str) /* called from fileselect */
235
 
{
236
 
        Editing *ed = seq_give_editing(scene, FALSE);
237
 
        struct SeqEffectHandle sh;
238
 
        Sequence *last_seq = seq_active_get(scene);
239
 
 
240
 
        if (last_seq == NULL || last_seq->type != SEQ_PLUGIN) return;
241
 
 
242
 
        sh = get_sequence_effect(last_seq);
243
 
        sh.free(last_seq);
244
 
        sh.init_plugin(last_seq, str);
245
 
 
246
 
        last_seq->machine = MAX3(last_seq->seq1->machine,
247
 
                                 last_seq->seq2->machine,
248
 
                                 last_seq->seq3->machine);
249
 
 
250
 
        if (seq_test_overlap(ed->seqbasep, last_seq) ) shuffle_seq(ed->seqbasep, last_seq, scene);
251
 
        
252
 
}
253
 
 
254
 
 
255
237
void boundbox_seq(Scene *scene, rctf *rect)
256
238
{
257
239
        Sequence *seq;
258
 
        Editing *ed = seq_give_editing(scene, FALSE);
 
240
        Editing *ed = BKE_sequencer_editing_get(scene, FALSE);
259
241
        float min[2], max[2];
260
242
 
261
243
        
302
284
{
303
285
        /* sel - 0==unselected, 1==selected, -1==done care*/
304
286
        Sequence *seq;
305
 
        Editing *ed = seq_give_editing(scene, FALSE);
 
287
        Editing *ed = BKE_sequencer_editing_get(scene, FALSE);
306
288
 
307
289
        if (ed == NULL) return NULL;
308
290
 
334
316
{
335
317
        /* sel - 0==unselected, 1==selected, -1==done care*/
336
318
        Sequence *seq, *best_seq = NULL;
337
 
        Editing *ed = seq_give_editing(scene, FALSE);
 
319
        Editing *ed = BKE_sequencer_editing_get(scene, FALSE);
338
320
        
339
321
        int dist, best_dist;
340
322
        best_dist = MAXFRAME * 2;
382
364
Sequence *find_nearest_seq(Scene *scene, View2D *v2d, int *hand, const int mval[2])
383
365
{
384
366
        Sequence *seq;
385
 
        Editing *ed = seq_give_editing(scene, FALSE);
 
367
        Editing *ed = BKE_sequencer_editing_get(scene, FALSE);
386
368
        float x, y;
387
369
        float pixelx;
388
370
        float handsize;
392
374
        
393
375
        if (ed == NULL) return NULL;
394
376
        
395
 
        pixelx = (v2d->cur.xmax - v2d->cur.xmin) / (v2d->mask.xmax - v2d->mask.xmin);
 
377
        pixelx = BLI_rctf_size_x(&v2d->cur) / BLI_rcti_size_x(&v2d->mask);
396
378
 
397
379
        UI_view2d_region_to_view(v2d, mval[0], mval[1], &x, &y);
398
380
        
401
383
        while (seq) {
402
384
                if (seq->machine == (int)y) {
403
385
                        /* check for both normal strips, and strips that have been flipped horizontally */
404
 
                        if ( ((seq->startdisp < seq->enddisp) && (seq->startdisp <= x && seq->enddisp >= x)) ||
405
 
                             ((seq->startdisp > seq->enddisp) && (seq->startdisp >= x && seq->enddisp <= x)) )
 
386
                        if (((seq->startdisp < seq->enddisp) && (seq->startdisp <= x && seq->enddisp >= x)) ||
 
387
                            ((seq->startdisp > seq->enddisp) && (seq->startdisp >= x && seq->enddisp <= x)) )
406
388
                        {
407
 
                                if (seq_tx_test(seq)) {
 
389
                                if (BKE_sequence_tx_test(seq)) {
408
390
                                        
409
391
                                        /* clamp handles to defined size in pixel space */
410
392
                                        
454
436
        return 0;
455
437
}
456
438
 
457
 
void deselect_all_seq(Scene *scene)
 
439
void ED_sequencer_deselect_all(Scene *scene)
458
440
{
459
441
        Sequence *seq;
460
 
        Editing *ed = seq_give_editing(scene, FALSE);
 
442
        Editing *ed = BKE_sequencer_editing_get(scene, FALSE);
461
443
 
462
444
        
463
445
        if (ed == NULL) return;
464
446
 
465
 
        SEQP_BEGIN(ed, seq)
 
447
        SEQP_BEGIN (ed, seq)
466
448
        {
467
449
                seq->flag &= ~SEQ_ALLSEL;
468
450
        }
487
469
        }
488
470
}
489
471
 
 
472
int ED_space_sequencer_maskedit_mask_poll(bContext *C)
 
473
{
 
474
        /* in this case both funcs are the same, for clip editor not */
 
475
        return ED_space_sequencer_maskedit_poll(C);
 
476
}
 
477
 
 
478
int ED_space_sequencer_check_show_maskedit(SpaceSeq *sseq, Scene *scene)
 
479
{
 
480
        if (sseq && sseq->mainb == SEQ_DRAW_IMG_IMBUF) {
 
481
                return (BKE_sequencer_mask_get(scene) != NULL);
 
482
        }
 
483
 
 
484
        return FALSE;
 
485
}
 
486
 
 
487
int ED_space_sequencer_maskedit_poll(bContext *C)
 
488
{
 
489
        SpaceSeq *sseq = CTX_wm_space_seq(C);
 
490
 
 
491
        if (sseq) {
 
492
                Scene *scene = CTX_data_scene(C);
 
493
                return ED_space_sequencer_check_show_maskedit(sseq, scene);
 
494
        }
 
495
 
 
496
        return FALSE;
 
497
}
 
498
 
 
499
/* are we displaying the seq output (not channels or histogram)*/
 
500
int ED_space_sequencer_check_show_imbuf(SpaceSeq *sseq)
 
501
{
 
502
        return (ELEM(sseq->view, SEQ_VIEW_PREVIEW, SEQ_VIEW_SEQUENCE_PREVIEW) &&
 
503
                ELEM(sseq->mainb, SEQ_DRAW_SEQUENCE, SEQ_DRAW_IMG_IMBUF));
 
504
}
 
505
 
490
506
int seq_effect_find_selected(Scene *scene, Sequence *activeseq, int type, Sequence **selseq1, Sequence **selseq2, Sequence **selseq3, const char **error_str)
491
507
{
492
 
        Editing *ed = seq_give_editing(scene, FALSE);
 
508
        Editing *ed = BKE_sequencer_editing_get(scene, FALSE);
493
509
        Sequence *seq1 = NULL, *seq2 = NULL, *seq3 = NULL, *seq;
494
510
        
495
511
        *error_str = NULL;
496
512
 
497
513
        if (!activeseq)
498
 
                seq2 = seq_active_get(scene);
 
514
                seq2 = BKE_sequencer_active_get(scene);
499
515
 
500
516
        for (seq = ed->seqbasep->first; seq; seq = seq->next) {
501
517
                if (seq->flag & SELECT) {
502
 
                        if (seq->type == SEQ_SOUND && get_sequence_effect_num_inputs(type) != 0) {
503
 
                                *error_str = "Can't apply effects to audio sequence strips";
 
518
                        if (seq->type == SEQ_TYPE_SOUND_RAM && BKE_sequence_effect_get_num_inputs(type) != 0) {
 
519
                                *error_str = N_("Cannot apply effects to audio sequence strips");
504
520
                                return 0;
505
521
                        }
506
522
                        if ((seq != activeseq) && (seq != seq2)) {
508
524
                                else if (seq1 == NULL) seq1 = seq;
509
525
                                else if (seq3 == NULL) seq3 = seq;
510
526
                                else {
511
 
                                        *error_str = "Can't apply effect to more than 3 sequence strips";
 
527
                                        *error_str = N_("Cannot apply effect to more than 3 sequence strips");
512
528
                                        return 0;
513
529
                                }
514
530
                        }
524
540
        }
525
541
        
526
542
 
527
 
        switch (get_sequence_effect_num_inputs(type)) {
 
543
        switch (BKE_sequence_effect_get_num_inputs(type)) {
528
544
                case 0:
529
545
                        *selseq1 = *selseq2 = *selseq3 = NULL;
530
546
                        return 1; /* succsess */
531
547
                case 1:
532
548
                        if (seq2 == NULL) {
533
 
                                *error_str = "Need at least one selected sequence strip";
 
549
                                *error_str = N_("At least one selected sequence strip is needed");
534
550
                                return 0;
535
551
                        }
536
552
                        if (seq1 == NULL) seq1 = seq2;
537
553
                        if (seq3 == NULL) seq3 = seq2;
538
554
                case 2:
539
555
                        if (seq1 == NULL || seq2 == NULL) {
540
 
                                *error_str = "Need 2 selected sequence strips";
 
556
                                *error_str = N_("2 selected sequence strips are needed");
541
557
                                return 0;
542
558
                        }
543
559
                        if (seq3 == NULL) seq3 = seq2;
544
560
        }
545
561
        
546
562
        if (seq1 == NULL && seq2 == NULL && seq3 == NULL) {
547
 
                *error_str = "TODO: in what cases does this happen?";
 
563
                *error_str = N_("TODO: in what cases does this happen?");
548
564
                return 0;
549
565
        }
550
566
        
564
580
 
565
581
        if (!seq)
566
582
                return NULL;
567
 
        else if (!(seq->type & SEQ_EFFECT))
 
583
        else if (!(seq->type & SEQ_TYPE_EFFECT))
568
584
                return ((seq->flag & SELECT) ? NULL : seq);
569
585
        else if (!(seq->flag & SELECT)) {
570
586
                /* try to find replacement for effect inputs */
572
588
                seq2 = del_seq_find_replace_recurs(scene, seq->seq2);
573
589
                seq3 = del_seq_find_replace_recurs(scene, seq->seq3);
574
590
 
575
 
                if (seq1 == seq->seq1 && seq2 == seq->seq2 && seq3 == seq->seq3) ;
 
591
                if (seq1 == seq->seq1 && seq2 == seq->seq2 && seq3 == seq->seq3) {
 
592
                        /* pass */
 
593
                }
576
594
                else if (seq1 || seq2 || seq3) {
577
595
                        seq->seq1 = (seq1) ? seq1 : (seq2) ? seq2 : seq3;
578
596
                        seq->seq2 = (seq2) ? seq2 : (seq1) ? seq1 : seq3;
579
597
                        seq->seq3 = (seq3) ? seq3 : (seq1) ? seq1 : seq2;
580
598
 
581
 
                        update_changed_seq_and_deps(scene, seq, 1, 1);
 
599
                        BKE_sequencer_update_changed_seq_and_deps(scene, seq, 1, 1);
582
600
                }
583
601
                else
584
602
                        seq->flag |= SELECT;  /* mark for delete */
597
615
static void recurs_del_seq_flag(Scene *scene, ListBase *lb, short flag, short deleteall)
598
616
{
599
617
        Sequence *seq, *seqn;
600
 
        Sequence *last_seq = seq_active_get(scene);
 
618
        Sequence *last_seq = BKE_sequencer_active_get(scene);
601
619
 
602
620
        seq = lb->first;
603
621
        while (seq) {
604
622
                seqn = seq->next;
605
623
                if ((seq->flag & flag) || deleteall) {
606
624
                        BLI_remlink(lb, seq);
607
 
                        if (seq == last_seq) seq_active_set(scene, NULL);
608
 
                        if (seq->type == SEQ_META) recurs_del_seq_flag(scene, &seq->seqbase, flag, 1);
609
 
                        seq_free_sequence(scene, seq);
 
625
                        if (seq == last_seq) BKE_sequencer_active_set(scene, NULL);
 
626
                        if (seq->type == SEQ_TYPE_META) recurs_del_seq_flag(scene, &seq->seqbase, flag, 1);
 
627
                        BKE_sequence_free(scene, seq);
610
628
                }
611
629
                seq = seqn;
612
630
        }
637
655
        
638
656
        if ((seq->startstill) && (cutframe < seq->start)) {
639
657
                /* don't do funny things with METAs ... */
640
 
                if (seq->type == SEQ_META) {
 
658
                if (seq->type == SEQ_TYPE_META) {
641
659
                        skip_dup = TRUE;
642
660
                        seq->startstill = seq->start - cutframe;
643
661
                }
658
676
        else if (((seq->start + seq->len) < cutframe) && (seq->endstill)) {
659
677
                seq->endstill -= seq->enddisp - cutframe;
660
678
                /* don't do funny things with METAs ... */
661
 
                if (seq->type == SEQ_META) {
 
679
                if (seq->type == SEQ_TYPE_META) {
662
680
                        skip_dup = TRUE;
663
681
                }
664
682
        }
665
683
        
666
 
        reload_sequence_new_file(scene, seq, FALSE);
667
 
        calc_sequence(scene, seq);
 
684
        BKE_sequence_reload_new_file(scene, seq, FALSE);
 
685
        BKE_sequence_calc(scene, seq);
668
686
 
669
687
        if (!skip_dup) {
670
688
                /* Duplicate AFTER the first change */
671
 
                seqn = seq_dupli_recursive(scene, NULL, seq, SEQ_DUPE_UNIQUE_NAME | SEQ_DUPE_ANIM);
 
689
                seqn = BKE_sequence_dupli_recursive(scene, NULL, seq, SEQ_DUPE_UNIQUE_NAME | SEQ_DUPE_ANIM);
672
690
        }
673
691
        
674
 
        if (seqn) { 
 
692
        if (seqn) {
675
693
                seqn->flag |= SELECT;
676
694
                        
677
695
                /* Second Strip! */
692
710
                        seqn->anim_startofs += cutframe - ts.start;
693
711
                        seqn->anim_endofs = ts.anim_endofs;
694
712
                        seqn->endstill = ts.endstill;
695
 
                }                               
 
713
                }
696
714
                
697
715
                /* strips with extended stillframes after */
698
716
                else if (((seqn->start + seqn->len) < cutframe) && (seqn->endstill)) {
703
721
                        seqn->startstill = 0;
704
722
                }
705
723
                
706
 
                reload_sequence_new_file(scene, seqn, FALSE);
707
 
                calc_sequence(scene, seqn);
 
724
                BKE_sequence_reload_new_file(scene, seqn, FALSE);
 
725
                BKE_sequence_calc(scene, seqn);
708
726
        }
709
727
        return seqn;
710
728
}
733
751
        
734
752
        if ((seq->startstill) && (cutframe < seq->start)) {
735
753
                /* don't do funny things with METAs ... */
736
 
                if (seq->type == SEQ_META) {
 
754
                if (seq->type == SEQ_TYPE_META) {
737
755
                        skip_dup = TRUE;
738
756
                        seq->startstill = seq->start - cutframe;
739
757
                }
752
770
        else if (((seq->start + seq->len) < cutframe) && (seq->endstill)) {
753
771
                seq->endstill -= seq->enddisp - cutframe;
754
772
                /* don't do funny things with METAs ... */
755
 
                if (seq->type == SEQ_META) {
 
773
                if (seq->type == SEQ_TYPE_META) {
756
774
                        skip_dup = TRUE;
757
775
                }
758
776
        }
759
777
        
760
 
        calc_sequence(scene, seq);
 
778
        BKE_sequence_calc(scene, seq);
761
779
 
762
780
        if (!skip_dup) {
763
781
                /* Duplicate AFTER the first change */
764
 
                seqn = seq_dupli_recursive(scene, NULL, seq, SEQ_DUPE_UNIQUE_NAME | SEQ_DUPE_ANIM);
 
782
                seqn = BKE_sequence_dupli_recursive(scene, NULL, seq, SEQ_DUPE_UNIQUE_NAME | SEQ_DUPE_ANIM);
765
783
        }
766
784
        
767
 
        if (seqn) { 
 
785
        if (seqn) {
768
786
                seqn->flag |= SELECT;
769
787
                        
770
788
                /* Second Strip! */
782
800
                        seqn->startofs = cutframe - ts.start;
783
801
                        seqn->endofs = ts.endofs;
784
802
                        seqn->endstill = ts.endstill;
785
 
                }                               
 
803
                }
786
804
                
787
805
                /* strips with extended stillframes after */
788
806
                else if (((seqn->start + seqn->len) < cutframe) && (seqn->endstill)) {
792
810
                        seqn->startstill = 0;
793
811
                }
794
812
                
795
 
                calc_sequence(scene, seqn);
 
813
                BKE_sequence_calc(scene, seqn);
796
814
        }
797
815
        return seqn;
798
816
}
799
817
 
800
818
 
801
819
/* like duplicate, but only duplicate and cut overlapping strips,
802
 
 * strips to the left of the cutframe are ignored and strips to the right are moved into the new list */
803
 
static int cut_seq_list(Scene *scene, ListBase *old, ListBase *new, int cutframe,
 
820
 * strips to the left of the cutframe are ignored and strips to the right 
 
821
 * are moved to the end of slist
 
822
 * we have to work on the same slist (not using a seperate list), since
 
823
 * otherwise dupli_seq can't check for duplicate names properly and
 
824
 * may generate strips with the same name (which will mess up animdata)
 
825
 */
 
826
 
 
827
static int cut_seq_list(Scene *scene, ListBase *slist, int cutframe,
804
828
                        Sequence * (*cut_seq)(Scene *, Sequence *, int))
805
829
{
806
 
        int did_something = FALSE;
807
830
        Sequence *seq, *seq_next_iter;
808
 
        
809
 
        seq = old->first;
810
 
        
811
 
        while (seq) {
 
831
        Sequence *seq_first_new = NULL;
 
832
        
 
833
        seq = slist->first;
 
834
 
 
835
        while (seq && seq != seq_first_new) {
812
836
                seq_next_iter = seq->next; /* we need this because we may remove seq */
813
 
                
814
837
                seq->tmp = NULL;
815
838
                if (seq->flag & SELECT) {
816
839
                        if (cutframe > seq->startdisp && 
818
841
                        {
819
842
                                Sequence *seqn = cut_seq(scene, seq, cutframe);
820
843
                                if (seqn) {
821
 
                                        BLI_addtail(new, seqn);
 
844
                                        BLI_addtail(slist, seqn);
 
845
                                        if (seq_first_new == NULL) {
 
846
                                                seq_first_new = seqn;
 
847
                                        }
822
848
                                }
823
 
                                did_something = TRUE;
824
849
                        }
825
850
                        else if (seq->enddisp <= cutframe) {
826
851
                                /* do nothing */
827
852
                        }
828
853
                        else if (seq->startdisp >= cutframe) {
829
 
                                /* move into new list */
830
 
                                BLI_remlink(old, seq);
831
 
                                BLI_addtail(new, seq);
 
854
                                /* move to tail */
 
855
                                BLI_remlink(slist, seq);
 
856
                                BLI_addtail(slist, seq);
 
857
 
 
858
                                if (seq_first_new == NULL) {
 
859
                                        seq_first_new = seq;
 
860
                                }
832
861
                        }
833
862
                }
834
863
                seq = seq_next_iter;
835
864
        }
836
 
        return did_something;
 
865
 
 
866
        return (seq_first_new != NULL);
837
867
}
838
868
 
839
869
static int insert_gap(Scene *scene, int gap, int cfra)
840
870
{
841
871
        Sequence *seq;
842
 
        Editing *ed = seq_give_editing(scene, FALSE);
843
 
        int done = 0;
 
872
        Editing *ed = BKE_sequencer_editing_get(scene, FALSE);
 
873
        int done = FALSE;
844
874
 
845
875
        /* all strips >= cfra are shifted */
846
876
        
847
877
        if (ed == NULL) return 0;
848
878
 
849
 
        SEQP_BEGIN(ed, seq) {
 
879
        SEQP_BEGIN (ed, seq)
 
880
        {
850
881
                if (seq->startdisp >= cfra) {
851
882
                        seq->start += gap;
852
 
                        calc_sequence(scene, seq);
853
 
                        done = 1;
 
883
                        BKE_sequence_calc(scene, seq);
 
884
                        done = TRUE;
854
885
                }
855
886
        }
856
887
        SEQ_END
861
892
static void UNUSED_FUNCTION(touch_seq_files) (Scene * scene)
862
893
{
863
894
        Sequence *seq;
864
 
        Editing *ed = seq_give_editing(scene, FALSE);
 
895
        Editing *ed = BKE_sequencer_editing_get(scene, FALSE);
865
896
        char str[256];
866
897
 
867
898
        /* touch all strips with movies */
872
903
 
873
904
        WM_cursor_wait(1);
874
905
 
875
 
        SEQP_BEGIN(ed, seq)
 
906
        SEQP_BEGIN (ed, seq)
876
907
        {
877
908
                if (seq->flag & SELECT) {
878
 
                        if (seq->type == SEQ_MOVIE) {
 
909
                        if (seq->type == SEQ_TYPE_MOVIE) {
879
910
                                if (seq->strip && seq->strip->stripdata) {
880
911
                                        BLI_make_file_string(G.main->name, str, seq->strip->dir, seq->strip->stripdata->name);
881
912
                                        BLI_file_touch(seq->name);
893
924
static void set_filter_seq(Scene *scene)
894
925
{
895
926
        Sequence *seq;
896
 
        Editing *ed = seq_give_editing(scene, FALSE);
 
927
        Editing *ed = BKE_sequencer_editing_get(scene, FALSE);
897
928
 
898
929
        
899
930
        if (ed == NULL) return;
900
931
 
901
932
        if (okee("Set Deinterlace") == 0) return;
902
933
 
903
 
        SEQP_BEGIN(ed, seq)
 
934
        SEQP_BEGIN (ed, seq)
904
935
        {
905
936
                if (seq->flag & SELECT) {
906
 
                        if (seq->type == SEQ_MOVIE) {
 
937
                        if (seq->type == SEQ_TYPE_MOVIE) {
907
938
                                seq->flag |= SEQ_FILTERY;
908
939
                                reload_sequence_new_file(scene, seq, FALSE);
909
 
                                calc_sequence(scene, seq);
 
940
                                BKE_sequence_calc(scene, seq);
910
941
                        }
911
942
 
912
943
                }
917
948
 
918
949
static void UNUSED_FUNCTION(seq_remap_paths) (Scene * scene)
919
950
{
920
 
        Sequence *seq, *last_seq = seq_active_get(scene);
921
 
        Editing *ed = seq_give_editing(scene, FALSE);
 
951
        Sequence *seq, *last_seq = BKE_sequencer_active_get(scene);
 
952
        Editing *ed = BKE_sequencer_editing_get(scene, FALSE);
922
953
        char from[FILE_MAX], to[FILE_MAX], stripped[FILE_MAX];
923
954
        
924
955
        
926
957
                return;
927
958
        
928
959
        BLI_strncpy(from, last_seq->strip->dir, sizeof(from));
929
 
// XXX  if (0==sbutton(from, 0, sizeof(from)-1, "From: "))
 
960
// XXX  if (0 == sbutton(from, 0, sizeof(from)-1, "From: "))
930
961
//              return;
931
962
        
932
963
        BLI_strncpy(to, from, sizeof(to));
933
 
// XXX  if (0==sbutton(to, 0, sizeof(to)-1, "To: "))
 
964
// XXX  if (0 == sbutton(to, 0, sizeof(to)-1, "To: "))
934
965
//              return;
935
966
        
936
967
        if (strcmp(to, from) == 0)
937
968
                return;
938
969
        
939
 
        SEQP_BEGIN(ed, seq)
 
970
        SEQP_BEGIN (ed, seq)
940
971
        {
941
972
                if (seq->flag & SELECT) {
942
973
                        if (strncmp(seq->strip->dir, from, strlen(from)) == 0) {
959
990
 
960
991
static void UNUSED_FUNCTION(no_gaps) (Scene * scene)
961
992
{
962
 
        Editing *ed = seq_give_editing(scene, FALSE);
 
993
        Editing *ed = BKE_sequencer_editing_get(scene, FALSE);
963
994
        int cfra, first = 0, done;
964
995
 
965
996
        
967
998
 
968
999
        for (cfra = CFRA; cfra <= EFRA; cfra++) {
969
1000
                if (first == 0) {
970
 
                        if (evaluate_seq_frame(scene, cfra) ) first = 1;
 
1001
                        if (BKE_sequencer_evaluate_frame(scene, cfra) ) first = 1;
971
1002
                }
972
1003
                else {
973
 
                        done = 1;
974
 
                        while (evaluate_seq_frame(scene, cfra) == 0) {
 
1004
                        done = TRUE;
 
1005
                        while (BKE_sequencer_evaluate_frame(scene, cfra) == 0) {
975
1006
                                done = insert_gap(scene, -1, cfra);
976
1007
                                if (done == 0) break;
977
1008
                        }
1000
1031
/* Operator functions */
1001
1032
int sequencer_edit_poll(bContext *C)
1002
1033
{
1003
 
        return (seq_give_editing(CTX_data_scene(C), FALSE) != NULL);
 
1034
        return (BKE_sequencer_editing_get(CTX_data_scene(C), FALSE) != NULL);
1004
1035
}
1005
1036
 
1006
1037
#if 0 /* UNUSED */
1007
1038
int sequencer_strip_poll(bContext *C)
1008
1039
{
1009
1040
        Editing *ed;
1010
 
        return (((ed = seq_give_editing(CTX_data_scene(C), FALSE)) != NULL) && (ed->act_seq != NULL));
 
1041
        return (((ed = BKE_sequencer_editing_get(CTX_data_scene(C), FALSE)) != NULL) && (ed->act_seq != NULL));
1011
1042
}
1012
1043
#endif
1013
1044
 
1015
1046
{
1016
1047
        Editing *ed;
1017
1048
        Sequence *seq;
1018
 
        return (((ed = seq_give_editing(CTX_data_scene(C), FALSE)) != NULL) && ((seq = ed->act_seq) != NULL) && (SEQ_HAS_PATH(seq)));
 
1049
        return (((ed = BKE_sequencer_editing_get(CTX_data_scene(C), FALSE)) != NULL) && ((seq = ed->act_seq) != NULL) && (SEQ_HAS_PATH(seq)));
1019
1050
}
1020
1051
 
1021
1052
int sequencer_view_poll(bContext *C)
1022
1053
{
1023
1054
        SpaceSeq *sseq = CTX_wm_space_seq(C);
1024
 
        Editing *ed = seq_give_editing(CTX_data_scene(C), FALSE);
 
1055
        Editing *ed = BKE_sequencer_editing_get(CTX_data_scene(C), FALSE);
1025
1056
        if (ed && sseq && (sseq->mainb == SEQ_DRAW_IMG_IMBUF))
1026
1057
                return 1;
1027
1058
 
1033
1064
{
1034
1065
        Scene *scene = CTX_data_scene(C);
1035
1066
        
1036
 
        Editing *ed = seq_give_editing(scene, FALSE);
 
1067
        Editing *ed = BKE_sequencer_editing_get(scene, FALSE);
1037
1068
        Sequence *seq;
1038
1069
        int snap_frame;
1039
1070
 
1042
1073
        /* also check metas */
1043
1074
        for (seq = ed->seqbasep->first; seq; seq = seq->next) {
1044
1075
                if (seq->flag & SELECT && !(seq->depth == 0 && seq->flag & SEQ_LOCK) &&
1045
 
                    seq_tx_test(seq))
 
1076
                    BKE_sequence_tx_test(seq))
1046
1077
                {
1047
1078
                        if ((seq->flag & (SEQ_LEFTSEL + SEQ_RIGHTSEL)) == 0) {
1048
1079
                                /* simple but no anim update */
1049
 
                                /* seq->start= snap_frame-seq->startofs+seq->startstill; */
 
1080
                                /* seq->start = snap_frame-seq->startofs+seq->startstill; */
1050
1081
 
1051
 
                                seq_translate(scene, seq, (snap_frame - seq->startofs + seq->startstill) - seq->start);
 
1082
                                BKE_sequence_translate(scene, seq, (snap_frame - seq->startofs + seq->startstill) - seq->start);
1052
1083
                        }
1053
1084
                        else {
1054
1085
                                if (seq->flag & SEQ_LEFTSEL) {
1055
 
                                        seq_tx_set_final_left(seq, snap_frame);
 
1086
                                        BKE_sequence_tx_set_final_left(seq, snap_frame);
1056
1087
                                }
1057
1088
                                else { /* SEQ_RIGHTSEL */
1058
 
                                        seq_tx_set_final_right(seq, snap_frame);
 
1089
                                        BKE_sequence_tx_set_final_right(seq, snap_frame);
1059
1090
                                }
1060
 
                                seq_tx_handle_xlimits(seq, seq->flag & SEQ_LEFTSEL, seq->flag & SEQ_RIGHTSEL);
 
1091
                                BKE_sequence_tx_handle_xlimits(seq, seq->flag & SEQ_LEFTSEL, seq->flag & SEQ_RIGHTSEL);
1061
1092
                        }
1062
 
                        calc_sequence(scene, seq);
 
1093
                        BKE_sequence_calc(scene, seq);
1063
1094
                }
1064
1095
        }
1065
1096
 
1068
1099
        for (seq = ed->seqbasep->first; seq; seq = seq->next) {
1069
1100
                if (seq->flag & SELECT && !(seq->depth == 0 && seq->flag & SEQ_LOCK)) {
1070
1101
                        seq->flag &= ~SEQ_OVERLAP;
1071
 
                        if (seq_test_overlap(ed->seqbasep, seq) ) {
1072
 
                                shuffle_seq(ed->seqbasep, seq, scene);
 
1102
                        if (BKE_sequence_test_overlap(ed->seqbasep, seq) ) {
 
1103
                                BKE_sequence_base_shuffle(ed->seqbasep, seq, scene);
1073
1104
                        }
1074
1105
                }
1075
 
                else if (seq->type & SEQ_EFFECT) {
 
1106
                else if (seq->type & SEQ_TYPE_EFFECT) {
1076
1107
                        if (seq->seq1 && (seq->seq1->flag & SELECT)) 
1077
 
                                calc_sequence(scene, seq);
 
1108
                                BKE_sequence_calc(scene, seq);
1078
1109
                        else if (seq->seq2 && (seq->seq2->flag & SELECT)) 
1079
 
                                calc_sequence(scene, seq);
 
1110
                                BKE_sequence_calc(scene, seq);
1080
1111
                        else if (seq->seq3 && (seq->seq3->flag & SELECT)) 
1081
 
                                calc_sequence(scene, seq);
 
1112
                                BKE_sequence_calc(scene, seq);
1082
1113
                }
1083
1114
        }
1084
1115
 
1085
1116
        /* as last: */
1086
 
        sort_seq(scene);
 
1117
        BKE_sequencer_sort(scene);
1087
1118
        
1088
1119
        WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
1089
1120
        
1105
1136
void SEQUENCER_OT_snap(struct wmOperatorType *ot)
1106
1137
{
1107
1138
        /* identifiers */
1108
 
        ot->name = "Snap strips";
 
1139
        ot->name = "Snap Strips";
1109
1140
        ot->idname = "SEQUENCER_OT_snap";
1110
1141
        ot->description = "Frame where selected strips will be snapped";
1111
1142
        
1124
1155
static int sequencer_mute_exec(bContext *C, wmOperator *op)
1125
1156
{
1126
1157
        Scene *scene = CTX_data_scene(C);
1127
 
        Editing *ed = seq_give_editing(scene, FALSE);
 
1158
        Editing *ed = BKE_sequencer_editing_get(scene, FALSE);
1128
1159
        Sequence *seq;
1129
1160
        int selected;
1130
1161
 
1133
1164
        for (seq = ed->seqbasep->first; seq; seq = seq->next) {
1134
1165
                if ((seq->flag & SEQ_LOCK) == 0) {
1135
1166
                        if (selected) { /* mute unselected */
1136
 
                                if (seq->flag & SELECT)
 
1167
                                if (seq->flag & SELECT) {
1137
1168
                                        seq->flag |= SEQ_MUTE;
 
1169
                                        BKE_sequence_invalidate_dependent(scene, seq);
 
1170
                                }
1138
1171
                        }
1139
1172
                        else {
1140
 
                                if ((seq->flag & SELECT) == 0)
 
1173
                                if ((seq->flag & SELECT) == 0) {
1141
1174
                                        seq->flag |= SEQ_MUTE;
 
1175
                                        BKE_sequence_invalidate_dependent(scene, seq);
 
1176
                                }
1142
1177
                        }
1143
1178
                }
1144
1179
        }
1145
1180
        
1146
 
        seq_update_muting(ed);
 
1181
        BKE_sequencer_update_muting(ed);
1147
1182
        WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
1148
1183
        
1149
1184
        return OPERATOR_FINISHED;
1171
1206
static int sequencer_unmute_exec(bContext *C, wmOperator *op)
1172
1207
{
1173
1208
        Scene *scene = CTX_data_scene(C);
1174
 
        Editing *ed = seq_give_editing(scene, FALSE);
 
1209
        Editing *ed = BKE_sequencer_editing_get(scene, FALSE);
1175
1210
        Sequence *seq;
1176
1211
        int selected;
1177
1212
 
1180
1215
        for (seq = ed->seqbasep->first; seq; seq = seq->next) {
1181
1216
                if ((seq->flag & SEQ_LOCK) == 0) {
1182
1217
                        if (selected) { /* unmute unselected */
1183
 
                                if (seq->flag & SELECT)
 
1218
                                if (seq->flag & SELECT) {
1184
1219
                                        seq->flag &= ~SEQ_MUTE;
 
1220
                                        BKE_sequence_invalidate_dependent(scene, seq);
 
1221
                                }
1185
1222
                        }
1186
1223
                        else {
1187
 
                                if ((seq->flag & SELECT) == 0)
 
1224
                                if ((seq->flag & SELECT) == 0) {
1188
1225
                                        seq->flag &= ~SEQ_MUTE;
 
1226
                                        BKE_sequence_invalidate_dependent(scene, seq);
 
1227
                                }
1189
1228
                        }
1190
1229
                }
1191
1230
        }
1192
1231
        
1193
 
        seq_update_muting(ed);
 
1232
        BKE_sequencer_update_muting(ed);
1194
1233
        WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
1195
1234
        
1196
1235
        return OPERATOR_FINISHED;
1218
1257
static int sequencer_lock_exec(bContext *C, wmOperator *UNUSED(op))
1219
1258
{
1220
1259
        Scene *scene = CTX_data_scene(C);
1221
 
        Editing *ed = seq_give_editing(scene, FALSE);
 
1260
        Editing *ed = BKE_sequencer_editing_get(scene, FALSE);
1222
1261
        Sequence *seq;
1223
1262
 
1224
1263
        for (seq = ed->seqbasep->first; seq; seq = seq->next) {
1251
1290
static int sequencer_unlock_exec(bContext *C, wmOperator *UNUSED(op))
1252
1291
{
1253
1292
        Scene *scene = CTX_data_scene(C);
1254
 
        Editing *ed = seq_give_editing(scene, FALSE);
 
1293
        Editing *ed = BKE_sequencer_editing_get(scene, FALSE);
1255
1294
        Sequence *seq;
1256
1295
 
1257
1296
        for (seq = ed->seqbasep->first; seq; seq = seq->next) {
1284
1323
static int sequencer_reload_exec(bContext *C, wmOperator *op)
1285
1324
{
1286
1325
        Scene *scene = CTX_data_scene(C);
1287
 
        Editing *ed = seq_give_editing(scene, FALSE);
 
1326
        Editing *ed = BKE_sequencer_editing_get(scene, FALSE);
1288
1327
        Sequence *seq;
1289
1328
        int adjust_length = RNA_boolean_get(op->ptr, "adjust_length");
1290
1329
 
1291
1330
        for (seq = ed->seqbasep->first; seq; seq = seq->next) {
1292
1331
                if (seq->flag & SELECT) {
1293
 
                        update_changed_seq_and_deps(scene, seq, 0, 1);
1294
 
                        reload_sequence_new_file(scene, seq, !adjust_length);
 
1332
                        BKE_sequencer_update_changed_seq_and_deps(scene, seq, 0, 1);
 
1333
                        BKE_sequence_reload_new_file(scene, seq, !adjust_length);
1295
1334
 
1296
1335
                        if (adjust_length) {
1297
 
                                if (seq_test_overlap(ed->seqbasep, seq))
1298
 
                                        shuffle_seq(ed->seqbasep, seq, scene);
 
1336
                                if (BKE_sequence_test_overlap(ed->seqbasep, seq))
 
1337
                                        BKE_sequence_base_shuffle(ed->seqbasep, seq, scene);
1299
1338
                        }
1300
1339
                }
1301
1340
        }
1322
1361
        ot->flag = OPTYPE_REGISTER; /* no undo, the data changed is stored outside 'main' */
1323
1362
 
1324
1363
        prop = RNA_def_boolean(ot->srna, "adjust_length", 0, "Adjust Length",
1325
 
                               "Adjust lenght of strips to their data lenght");
 
1364
                               "Adjust length of strips to their data length");
1326
1365
        RNA_def_property_flag(prop, PROP_SKIP_SAVE);
1327
1366
}
1328
1367
 
1330
1369
static int sequencer_refresh_all_exec(bContext *C, wmOperator *UNUSED(op))
1331
1370
{
1332
1371
        Scene *scene = CTX_data_scene(C);
1333
 
        Editing *ed = seq_give_editing(scene, FALSE);
 
1372
        Editing *ed = BKE_sequencer_editing_get(scene, FALSE);
1334
1373
 
1335
 
        free_imbuf_seq(scene, &ed->seqbase, FALSE, FALSE);
 
1374
        BKE_sequencer_free_imbuf(scene, &ed->seqbase, FALSE);
1336
1375
 
1337
1376
        WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
1338
1377
 
1354
1393
static int sequencer_reassign_inputs_exec(bContext *C, wmOperator *op)
1355
1394
{
1356
1395
        Scene *scene = CTX_data_scene(C);
1357
 
        Sequence *seq1, *seq2, *seq3, *last_seq = seq_active_get(scene);
 
1396
        Sequence *seq1, *seq2, *seq3, *last_seq = BKE_sequencer_active_get(scene);
1358
1397
        const char *error_msg;
1359
1398
 
1360
1399
        if (!seq_effect_find_selected(scene, last_seq, last_seq->type, &seq1, &seq2, &seq3, &error_msg)) {
1364
1403
        /* see reassigning would create a cycle */
1365
1404
        if (seq_is_predecessor(seq1, last_seq) ||
1366
1405
            seq_is_predecessor(seq2, last_seq) ||
1367
 
            seq_is_predecessor(seq3, last_seq)
1368
 
            ) {
1369
 
                BKE_report(op->reports, RPT_ERROR, "Can't reassign inputs: no cycles allowed");
 
1406
            seq_is_predecessor(seq3, last_seq))
 
1407
        {
 
1408
                BKE_report(op->reports, RPT_ERROR, "Cannot reassign inputs: no cycles allowed");
1370
1409
                return OPERATOR_CANCELLED;
1371
1410
        }
1372
1411
 
1374
1413
        last_seq->seq2 = seq2;
1375
1414
        last_seq->seq3 = seq3;
1376
1415
 
1377
 
        update_changed_seq_and_deps(scene, last_seq, 1, 1);
 
1416
        BKE_sequencer_update_changed_seq_and_deps(scene, last_seq, 1, 1);
1378
1417
 
1379
1418
        WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
1380
1419
 
1384
1423
static int sequencer_effect_poll(bContext *C)
1385
1424
{
1386
1425
        Scene *scene = CTX_data_scene(C);
1387
 
        Editing *ed = seq_give_editing(scene, FALSE);
 
1426
        Editing *ed = BKE_sequencer_editing_get(scene, FALSE);
1388
1427
 
1389
1428
        if (ed) {
1390
 
                Sequence *last_seq = seq_active_get(scene);
1391
 
                if (last_seq && (last_seq->type & SEQ_EFFECT)) {
 
1429
                Sequence *last_seq = BKE_sequencer_active_get(scene);
 
1430
                if (last_seq && (last_seq->type & SEQ_TYPE_EFFECT)) {
1392
1431
                        return 1;
1393
1432
                }
1394
1433
        }
1415
1454
static int sequencer_swap_inputs_exec(bContext *C, wmOperator *op)
1416
1455
{
1417
1456
        Scene *scene = CTX_data_scene(C);
1418
 
        Sequence *seq, *last_seq = seq_active_get(scene);
 
1457
        Sequence *seq, *last_seq = BKE_sequencer_active_get(scene);
1419
1458
 
1420
1459
        if (last_seq->seq1 == NULL || last_seq->seq2 == NULL) {
1421
1460
                BKE_report(op->reports, RPT_ERROR, "No valid inputs to swap");
1426
1465
        last_seq->seq1 = last_seq->seq2;
1427
1466
        last_seq->seq2 = seq;
1428
1467
 
1429
 
        update_changed_seq_and_deps(scene, last_seq, 1, 1);
 
1468
        BKE_sequencer_update_changed_seq_and_deps(scene, last_seq, 1, 1);
1430
1469
 
1431
1470
        WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
1432
1471
 
1458
1497
static int sequencer_cut_exec(bContext *C, wmOperator *op)
1459
1498
{
1460
1499
        Scene *scene = CTX_data_scene(C);
1461
 
        Editing *ed = seq_give_editing(scene, FALSE);
 
1500
        Editing *ed = BKE_sequencer_editing_get(scene, FALSE);
1462
1501
        int cut_side, cut_hard, cut_frame;
1463
1502
 
1464
 
        ListBase newlist;
1465
1503
        int changed;
1466
1504
 
1467
1505
        cut_frame = RNA_int_get(op->ptr, "frame");
1468
1506
        cut_hard = RNA_enum_get(op->ptr, "type");
1469
1507
        cut_side = RNA_enum_get(op->ptr, "side");
1470
1508
        
1471
 
        newlist.first = newlist.last = NULL;
1472
 
 
1473
1509
        if (cut_hard == SEQ_CUT_HARD) {
1474
 
                changed = cut_seq_list(scene, ed->seqbasep, &newlist, cut_frame, cut_seq_hard);
 
1510
                changed = cut_seq_list(scene, ed->seqbasep, cut_frame, cut_seq_hard);
1475
1511
        }
1476
1512
        else {
1477
 
                changed = cut_seq_list(scene, ed->seqbasep, &newlist, cut_frame, cut_seq_soft);
 
1513
                changed = cut_seq_list(scene, ed->seqbasep, cut_frame, cut_seq_soft);
1478
1514
        }
1479
1515
        
1480
 
        if (newlist.first) { /* got new strips ? */
 
1516
        if (changed) { /* got new strips ? */
1481
1517
                Sequence *seq;
1482
 
                BLI_movelisttolist(ed->seqbasep, &newlist);
1483
1518
 
1484
1519
                if (cut_side != SEQ_SIDE_BOTH) {
1485
 
                        SEQP_BEGIN(ed, seq) {
 
1520
                        SEQP_BEGIN (ed, seq)
 
1521
                        {
1486
1522
                                if (cut_side == SEQ_SIDE_LEFT) {
1487
1523
                                        if (seq->startdisp >= cut_frame) {
1488
1524
                                                seq->flag &= ~SEQ_ALLSEL;
1497
1533
                        SEQ_END;
1498
1534
                }
1499
1535
                /* as last: */
1500
 
                sort_seq(scene);
 
1536
                BKE_sequencer_sort(scene);
1501
1537
        }
1502
1538
 
1503
1539
        if (changed) {
1555
1591
        Scene *scene = (Scene *)arg_pt;
1556
1592
        char name[sizeof(seq->name) - 2];
1557
1593
 
1558
 
        strcpy(name, seq->name + 2);
1559
 
        seqbase_unique_name_recursive(&scene->ed->seqbase, seq);
1560
 
        seq_dupe_animdata(scene, name, seq->name + 2);
 
1594
        BLI_strncpy_utf8(name, seq->name + 2, sizeof(name));
 
1595
        BKE_sequence_base_unique_name_recursive(&scene->ed->seqbase, seq);
 
1596
        BKE_sequencer_dupe_animdata(scene, name, seq->name + 2);
1561
1597
        return 1;
1562
1598
 
1563
1599
}
1565
1601
static int sequencer_add_duplicate_exec(bContext *C, wmOperator *UNUSED(op))
1566
1602
{
1567
1603
        Scene *scene = CTX_data_scene(C);
1568
 
        Editing *ed = seq_give_editing(scene, FALSE);
 
1604
        Editing *ed = BKE_sequencer_editing_get(scene, FALSE);
1569
1605
 
1570
1606
        ListBase nseqbase = {NULL, NULL};
1571
1607
 
1572
1608
        if (ed == NULL)
1573
1609
                return OPERATOR_CANCELLED;
1574
1610
 
1575
 
        seqbase_dupli_recursive(scene, NULL, &nseqbase, ed->seqbasep, SEQ_DUPE_CONTEXT);
 
1611
        BKE_sequence_base_dupli_recursive(scene, NULL, &nseqbase, ed->seqbasep, SEQ_DUPE_CONTEXT);
1576
1612
 
1577
1613
        if (nseqbase.first) {
1578
1614
                Sequence *seq = nseqbase.first;
1580
1616
                BLI_movelisttolist(ed->seqbasep, &nseqbase);
1581
1617
 
1582
1618
                for (; seq; seq = seq->next)
1583
 
                        seq_recursive_apply(seq, apply_unique_name_cb, scene);
 
1619
                        BKE_sequencer_recursive_apply(seq, apply_unique_name_cb, scene);
1584
1620
 
1585
1621
                WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
1586
1622
                return OPERATOR_FINISHED;
1589
1625
        return OPERATOR_CANCELLED;
1590
1626
}
1591
1627
 
1592
 
static int sequencer_add_duplicate_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
1593
 
{
1594
 
        sequencer_add_duplicate_exec(C, op);
1595
 
 
1596
 
        RNA_enum_set(op->ptr, "mode", TFM_TRANSLATION);
1597
 
        WM_operator_name_call(C, "TRANSFORM_OT_transform", WM_OP_INVOKE_REGION_WIN, op->ptr);
1598
 
 
1599
 
        return OPERATOR_FINISHED;
1600
 
}
1601
 
 
1602
1628
void SEQUENCER_OT_duplicate(wmOperatorType *ot)
1603
1629
{
1604
1630
        /* identifiers */
1607
1633
        ot->description = "Duplicate the selected strips";
1608
1634
        
1609
1635
        /* api callbacks */
1610
 
        ot->invoke = sequencer_add_duplicate_invoke;
1611
1636
        ot->exec = sequencer_add_duplicate_exec;
1612
1637
        ot->poll = ED_operator_sequencer_active;
1613
1638
        
1622
1647
static int sequencer_delete_exec(bContext *C, wmOperator *UNUSED(op))
1623
1648
{
1624
1649
        Scene *scene = CTX_data_scene(C);
1625
 
        Editing *ed = seq_give_editing(scene, FALSE);
 
1650
        Editing *ed = BKE_sequencer_editing_get(scene, FALSE);
1626
1651
        Sequence *seq;
1627
1652
        MetaStack *ms;
1628
1653
        int nothingSelected = TRUE;
1629
1654
 
1630
 
        seq = seq_active_get(scene);
 
1655
        seq = BKE_sequencer_active_get(scene);
1631
1656
        if (seq && seq->flag & SELECT) { /* avoid a loop since this is likely to be selected */
1632
1657
                nothingSelected = FALSE;
1633
1658
        }
1645
1670
 
1646
1671
        /* for effects, try to find a replacement input */
1647
1672
        for (seq = ed->seqbasep->first; seq; seq = seq->next)
1648
 
                if ((seq->type & SEQ_EFFECT) && !(seq->flag & SELECT))
 
1673
                if ((seq->type & SEQ_TYPE_EFFECT) && !(seq->flag & SELECT))
1649
1674
                        del_seq_find_replace_recurs(scene, seq);
1650
1675
 
1651
1676
        /* delete all selected strips */
1654
1679
        /* updates lengths etc */
1655
1680
        seq = ed->seqbasep->first;
1656
1681
        while (seq) {
1657
 
                calc_sequence(scene, seq);
 
1682
                BKE_sequence_calc(scene, seq);
1658
1683
                seq = seq->next;
1659
1684
        }
1660
1685
 
1661
1686
        /* free parent metas */
1662
1687
        ms = ed->metastack.last;
1663
1688
        while (ms) {
1664
 
                calc_sequence(scene, ms->parseq);
 
1689
                BKE_sequence_calc(scene, ms->parseq);
1665
1690
                ms = ms->prev;
1666
1691
        }
1667
1692
 
1670
1695
        return OPERATOR_FINISHED;
1671
1696
}
1672
1697
 
 
1698
static int sequencer_delete_invoke(bContext *C, wmOperator *op, wmEvent *event)
 
1699
{
 
1700
        ARegion *ar = CTX_wm_region(C);
 
1701
 
 
1702
        if (ar->regiontype == RGN_TYPE_WINDOW) {
 
1703
                /* bounding box of 30 pixels is used for markers shortcuts,
 
1704
                 * prevent conflict with markers shortcuts here
 
1705
                 */
 
1706
                if (event->mval[1] <= 30)
 
1707
                        return OPERATOR_PASS_THROUGH;
 
1708
        }
 
1709
 
 
1710
        return WM_operator_confirm(C, op, event);
 
1711
}
1673
1712
 
1674
1713
void SEQUENCER_OT_delete(wmOperatorType *ot)
1675
1714
{
1680
1719
        ot->description = "Erase selected strips from the sequencer";
1681
1720
        
1682
1721
        /* api callbacks */
1683
 
        ot->invoke = WM_operator_confirm;
 
1722
        ot->invoke = sequencer_delete_invoke;
1684
1723
        ot->exec = sequencer_delete_exec;
1685
1724
        ot->poll = sequencer_edit_poll;
1686
1725
        
1693
1732
static int sequencer_offset_clear_exec(bContext *C, wmOperator *UNUSED(op))
1694
1733
{
1695
1734
        Scene *scene = CTX_data_scene(C);
1696
 
        Editing *ed = seq_give_editing(scene, FALSE);
 
1735
        Editing *ed = BKE_sequencer_editing_get(scene, FALSE);
1697
1736
        Sequence *seq;
1698
1737
 
1699
1738
        /* for effects, try to find a replacement input */
1700
1739
        for (seq = ed->seqbasep->first; seq; seq = seq->next) {
1701
 
                if ((seq->type & SEQ_EFFECT) == 0 && (seq->flag & SELECT)) {
 
1740
                if ((seq->type & SEQ_TYPE_EFFECT) == 0 && (seq->flag & SELECT)) {
1702
1741
                        seq->startofs = seq->endofs = seq->startstill = seq->endstill = 0;
1703
1742
                }
1704
1743
        }
1706
1745
        /* updates lengths etc */
1707
1746
        seq = ed->seqbasep->first;
1708
1747
        while (seq) {
1709
 
                calc_sequence(scene, seq);
 
1748
                BKE_sequence_calc(scene, seq);
1710
1749
                seq = seq->next;
1711
1750
        }
1712
1751
 
1713
1752
        for (seq = ed->seqbasep->first; seq; seq = seq->next) {
1714
 
                if ((seq->type & SEQ_EFFECT) == 0 && (seq->flag & SELECT)) {
1715
 
                        if (seq_test_overlap(ed->seqbasep, seq)) {
1716
 
                                shuffle_seq(ed->seqbasep, seq, scene);
 
1753
                if ((seq->type & SEQ_TYPE_EFFECT) == 0 && (seq->flag & SELECT)) {
 
1754
                        if (BKE_sequence_test_overlap(ed->seqbasep, seq)) {
 
1755
                                BKE_sequence_base_shuffle(ed->seqbasep, seq, scene);
1717
1756
                        }
1718
1757
                }
1719
1758
        }
1745
1784
static int sequencer_separate_images_exec(bContext *C, wmOperator *op)
1746
1785
{
1747
1786
        Scene *scene = CTX_data_scene(C);
1748
 
        Editing *ed = seq_give_editing(scene, FALSE);
 
1787
        Editing *ed = BKE_sequencer_editing_get(scene, FALSE);
1749
1788
        
1750
1789
        Sequence *seq, *seq_new;
1751
1790
        Strip *strip_new;
1756
1795
        seq = ed->seqbasep->first; /* poll checks this is valid */
1757
1796
 
1758
1797
        while (seq) {
1759
 
                if ((seq->flag & SELECT) && (seq->type == SEQ_IMAGE) && (seq->len > 1)) {
 
1798
                if ((seq->flag & SELECT) && (seq->type == SEQ_TYPE_IMAGE) && (seq->len > 1)) {
1760
1799
                        /* remove seq so overlap tests don't conflict,
1761
1800
                         * see seq_free_sequence below for the real free'ing */
1762
1801
                        BLI_remlink(ed->seqbasep, seq);
1763
1802
                        /* if (seq->ipo) seq->ipo->id.us--; */
1764
1803
                        /* XXX, remove fcurve and assign to split image strips */
1765
1804
 
1766
 
                        start_ofs = cfra = seq_tx_get_final_left(seq, 0);
1767
 
                        frame_end = seq_tx_get_final_right(seq, 0);
 
1805
                        start_ofs = cfra = BKE_sequence_tx_get_final_left(seq, 0);
 
1806
                        frame_end = BKE_sequence_tx_get_final_right(seq, 0);
1768
1807
 
1769
1808
                        while (cfra < frame_end) {
1770
1809
                                /* new seq */
1771
 
                                se = give_stripelem(seq, cfra);
 
1810
                                se = BKE_sequencer_give_stripelem(seq, cfra);
1772
1811
 
1773
 
                                seq_new = seq_dupli_recursive(scene, scene, seq, SEQ_DUPE_UNIQUE_NAME);
 
1812
                                seq_new = BKE_sequence_dupli_recursive(scene, scene, seq, SEQ_DUPE_UNIQUE_NAME);
1774
1813
                                BLI_addtail(ed->seqbasep, seq_new);
1775
1814
 
1776
1815
                                seq_new->start = start_ofs;
1777
 
                                seq_new->type = SEQ_IMAGE;
 
1816
                                seq_new->type = SEQ_TYPE_IMAGE;
1778
1817
                                seq_new->len = 1;
1779
1818
                                seq_new->endstill = step - 1;
1780
1819
 
1785
1824
                                /* new stripdata */
1786
1825
                                se_new = strip_new->stripdata;
1787
1826
                                BLI_strncpy(se_new->name, se->name, sizeof(se_new->name));
1788
 
                                calc_sequence(scene, seq_new);
 
1827
                                BKE_sequence_calc(scene, seq_new);
1789
1828
 
1790
1829
                                if (step > 1) {
1791
1830
                                        seq_new->flag &= ~SEQ_OVERLAP;
1792
 
                                        if (seq_test_overlap(ed->seqbasep, seq_new)) {
1793
 
                                                shuffle_seq(ed->seqbasep, seq_new, scene);
 
1831
                                        if (BKE_sequence_test_overlap(ed->seqbasep, seq_new)) {
 
1832
                                                BKE_sequence_base_shuffle(ed->seqbasep, seq_new, scene);
1794
1833
                                        }
1795
1834
                                }
1796
1835
 
1800
1839
                                start_ofs += step;
1801
1840
                        }
1802
1841
 
1803
 
                        seq_free_sequence(scene, seq);
 
1842
                        BKE_sequence_free(scene, seq);
1804
1843
                        seq = seq->next;
1805
1844
                }
1806
1845
                else {
1809
1848
        }
1810
1849
 
1811
1850
        /* as last: */
1812
 
        sort_seq(scene);
 
1851
        BKE_sequencer_sort(scene);
1813
1852
        
1814
1853
        WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
1815
1854
 
1826
1865
        
1827
1866
        /* api callbacks */
1828
1867
        ot->exec = sequencer_separate_images_exec;
 
1868
        ot->invoke = WM_operator_props_popup;
1829
1869
        ot->poll = sequencer_edit_poll;
1830
1870
        
1831
1871
        /* flags */
1832
1872
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
1833
1873
 
1834
 
        RNA_def_int(ot->srna, "length", 1, 1, 1000, "Length", "Length of each frame", 1, INT_MAX);
 
1874
        RNA_def_int(ot->srna, "length", 1, 1, INT_MAX, "Length", "Length of each frame", 1, 1000);
1835
1875
}
1836
1876
 
1837
1877
 
1841
1881
static int sequencer_meta_toggle_exec(bContext *C, wmOperator *UNUSED(op))
1842
1882
{
1843
1883
        Scene *scene = CTX_data_scene(C);
1844
 
        Editing *ed = seq_give_editing(scene, FALSE);
1845
 
        Sequence *last_seq = seq_active_get(scene);
 
1884
        Editing *ed = BKE_sequencer_editing_get(scene, FALSE);
 
1885
        Sequence *last_seq = BKE_sequencer_active_get(scene);
1846
1886
        MetaStack *ms;
1847
1887
 
1848
 
        if (last_seq && last_seq->type == SEQ_META && last_seq->flag & SELECT) {
 
1888
        if (last_seq && last_seq->type == SEQ_TYPE_META && last_seq->flag & SELECT) {
1849
1889
                /* Enter Metastrip */
1850
1890
                ms = MEM_mallocN(sizeof(MetaStack), "metastack");
1851
1891
                BLI_addtail(&ed->metastack, ms);
1854
1894
 
1855
1895
                ed->seqbasep = &last_seq->seqbase;
1856
1896
 
1857
 
                seq_active_set(scene, NULL);
 
1897
                BKE_sequencer_active_set(scene, NULL);
1858
1898
 
1859
1899
        }
1860
1900
        else {
1872
1912
 
1873
1913
                /* recalc all: the meta can have effects connected to it */
1874
1914
                for (seq = ed->seqbasep->first; seq; seq = seq->next)
1875
 
                        calc_sequence(scene, seq);
1876
 
 
1877
 
                seq_active_set(scene, ms->parseq);
 
1915
                        BKE_sequence_calc(scene, seq);
 
1916
 
 
1917
                if (BKE_sequence_test_overlap(ed->seqbasep, ms->parseq))
 
1918
                        BKE_sequence_base_shuffle(ed->seqbasep, ms->parseq, scene);
 
1919
 
 
1920
                BKE_sequencer_active_set(scene, ms->parseq);
1878
1921
 
1879
1922
                ms->parseq->flag |= SELECT;
1880
1923
                recurs_sel_seq(ms->parseq);
1883
1926
 
1884
1927
        }
1885
1928
 
1886
 
        seq_update_muting(ed);
 
1929
        BKE_sequencer_update_muting(ed);
1887
1930
        WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
1888
1931
 
1889
1932
        return OPERATOR_FINISHED;
1909
1952
static int sequencer_meta_make_exec(bContext *C, wmOperator *op)
1910
1953
{
1911
1954
        Scene *scene = CTX_data_scene(C);
1912
 
        Editing *ed = seq_give_editing(scene, FALSE);
 
1955
        Editing *ed = BKE_sequencer_editing_get(scene, FALSE);
1913
1956
        
1914
 
        Sequence *seq, *seqm, *next, *last_seq = seq_active_get(scene);
 
1957
        Sequence *seq, *seqm, *next, *last_seq = BKE_sequencer_active_get(scene);
1915
1958
        int channel_max = 1;
1916
1959
 
1917
 
        if (seqbase_isolated_sel_check(ed->seqbasep) == FALSE) {
 
1960
        if (BKE_sequence_base_isolated_sel_check(ed->seqbasep) == FALSE) {
1918
1961
                BKE_report(op->reports, RPT_ERROR, "Please select all related strips");
1919
1962
                return OPERATOR_CANCELLED;
1920
1963
        }
1921
1964
 
1922
1965
        /* remove all selected from main list, and put in meta */
1923
1966
 
1924
 
        seqm = alloc_sequence(ed->seqbasep, 1, 1); /* channel number set later */
 
1967
        seqm = BKE_sequence_alloc(ed->seqbasep, 1, 1); /* channel number set later */
1925
1968
        strcpy(seqm->name + 2, "MetaStrip");
1926
 
        seqm->type = SEQ_META;
 
1969
        seqm->type = SEQ_TYPE_META;
1927
1970
        seqm->flag = SELECT;
1928
1971
 
1929
1972
        seq = ed->seqbasep->first;
1930
1973
        while (seq) {
1931
1974
                next = seq->next;
1932
1975
                if (seq != seqm && (seq->flag & SELECT)) {
1933
 
                        channel_max = MAX2(seq->machine, channel_max);
 
1976
                        channel_max = max_ii(seq->machine, channel_max);
1934
1977
                        BLI_remlink(ed->seqbasep, seq);
1935
1978
                        BLI_addtail(&seqm->seqbase, seq);
1936
1979
                }
1937
1980
                seq = next;
1938
1981
        }
1939
1982
        seqm->machine = last_seq ? last_seq->machine : channel_max;
1940
 
        calc_sequence(scene, seqm);
 
1983
        BKE_sequence_calc(scene, seqm);
1941
1984
 
1942
1985
        seqm->strip = MEM_callocN(sizeof(Strip), "metastrip");
1943
1986
        seqm->strip->us = 1;
1944
1987
        
1945
 
        seq_active_set(scene, seqm);
1946
 
 
1947
 
        if (seq_test_overlap(ed->seqbasep, seqm) ) shuffle_seq(ed->seqbasep, seqm, scene);
1948
 
 
1949
 
        seq_update_muting(ed);
1950
 
 
1951
 
        seqbase_unique_name_recursive(&scene->ed->seqbase, seqm);
 
1988
        BKE_sequencer_active_set(scene, seqm);
 
1989
 
 
1990
        if (BKE_sequence_test_overlap(ed->seqbasep, seqm) ) BKE_sequence_base_shuffle(ed->seqbasep, seqm, scene);
 
1991
 
 
1992
        BKE_sequencer_update_muting(ed);
 
1993
 
 
1994
        BKE_sequence_base_unique_name_recursive(&scene->ed->seqbase, seqm);
1952
1995
 
1953
1996
        WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
1954
1997
 
1985
2028
static int sequencer_meta_separate_exec(bContext *C, wmOperator *UNUSED(op))
1986
2029
{
1987
2030
        Scene *scene = CTX_data_scene(C);
1988
 
        Editing *ed = seq_give_editing(scene, FALSE);
1989
 
 
1990
 
        Sequence *seq, *last_seq = seq_active_get(scene); /* last_seq checks ed==NULL */
1991
 
 
1992
 
        if (last_seq == NULL || last_seq->type != SEQ_META)
 
2031
        Editing *ed = BKE_sequencer_editing_get(scene, FALSE);
 
2032
 
 
2033
        Sequence *seq, *last_seq = BKE_sequencer_active_get(scene); /* last_seq checks (ed == NULL) */
 
2034
 
 
2035
        if (last_seq == NULL || last_seq->type != SEQ_TYPE_META)
1993
2036
                return OPERATOR_CANCELLED;
1994
2037
 
1995
2038
        BLI_movelisttolist(ed->seqbasep, &last_seq->seqbase);
1998
2041
        last_seq->seqbase.last = NULL;
1999
2042
 
2000
2043
        BLI_remlink(ed->seqbasep, last_seq);
2001
 
        seq_free_sequence(scene, last_seq);
 
2044
        BKE_sequence_free(scene, last_seq);
2002
2045
 
2003
2046
        /* emtpy meta strip, delete all effects depending on it */
2004
2047
        for (seq = ed->seqbasep->first; seq; seq = seq->next)
2005
 
                if ((seq->type & SEQ_EFFECT) && seq_depends_on_meta(seq, last_seq))
 
2048
                if ((seq->type & SEQ_TYPE_EFFECT) && seq_depends_on_meta(seq, last_seq))
2006
2049
                        seq->flag |= SEQ_FLAG_DELETE;
2007
2050
 
2008
2051
        recurs_del_seq_flag(scene, ed->seqbasep, SEQ_FLAG_DELETE, 0);
2012
2055
        for (seq = ed->seqbasep->first; seq; seq = seq->next) {
2013
2056
                if (seq->flag & SELECT) {
2014
2057
                        seq->flag &= ~SEQ_OVERLAP;
2015
 
                        if (seq_test_overlap(ed->seqbasep, seq)) {
2016
 
                                shuffle_seq(ed->seqbasep, seq, scene);
 
2058
                        if (BKE_sequence_test_overlap(ed->seqbasep, seq)) {
 
2059
                                BKE_sequence_base_shuffle(ed->seqbasep, seq, scene);
2017
2060
                        }
2018
2061
                }
2019
2062
        }
2020
2063
 
2021
 
        sort_seq(scene);
2022
 
        seq_update_muting(ed);
 
2064
        BKE_sequencer_sort(scene);
 
2065
        BKE_sequencer_update_muting(ed);
2023
2066
 
2024
2067
        WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
2025
2068
 
2045
2088
/* view_all operator */
2046
2089
static int sequencer_view_all_exec(bContext *C, wmOperator *UNUSED(op))
2047
2090
{
2048
 
        //Scene *scene= CTX_data_scene(C);
2049
 
        bScreen *sc = CTX_wm_screen(C);
2050
 
        ScrArea *area = CTX_wm_area(C);
2051
 
        //ARegion *ar= CTX_wm_region(C);
 
2091
        ARegion *ar = CTX_wm_region(C);
2052
2092
        View2D *v2d = UI_view2d_fromcontext(C);
2053
2093
 
2054
 
        v2d->cur = v2d->tot;
2055
 
        UI_view2d_curRect_validate(v2d);
2056
 
        UI_view2d_sync(sc, area, v2d, V2D_LOCK_COPY);
2057
 
        
2058
 
        ED_area_tag_redraw(CTX_wm_area(C));
 
2094
        UI_view2d_smooth_view(C, ar, &v2d->tot);
2059
2095
        return OPERATOR_FINISHED;
2060
2096
}
2061
2097
 
2107
2143
        imgwidth = (int)(imgwidth * (scene->r.xasp / scene->r.yasp));
2108
2144
 
2109
2145
        if (((imgwidth >= width) || (imgheight >= height)) &&
2110
 
            ((width > 0) && (height > 0))) {
2111
 
 
 
2146
            ((width > 0) && (height > 0)))
 
2147
        {
2112
2148
                /* Find the zoom value that will fit the image in the image space */
2113
2149
                zoomX = ((float)width) / ((float)imgwidth);
2114
2150
                zoomY = ((float)height) / ((float)imgheight);
2115
2151
                sseq->zoom = (zoomX < zoomY) ? zoomX : zoomY;
2116
2152
 
2117
 
                sseq->zoom = 1.0f / power_of_2(1 / MIN2(zoomX, zoomY) );
 
2153
                sseq->zoom = 1.0f / power_of_2(1 / min_ff(zoomX, zoomY));
2118
2154
        }
2119
2155
        else {
2120
2156
                sseq->zoom = 1.0f;
2143
2179
 
2144
2180
static int sequencer_view_zoom_ratio_exec(bContext *C, wmOperator *op)
2145
2181
{
2146
 
        RenderData *r = &CTX_data_scene(C)->r;
 
2182
        RenderData *rd = &CTX_data_scene(C)->r;
2147
2183
        View2D *v2d = UI_view2d_fromcontext(C);
2148
2184
 
2149
2185
        float ratio = RNA_float_get(op->ptr, "ratio");
2150
2186
 
2151
 
        float winx = (int)(r->size * r->xsch) / 100;
2152
 
        float winy = (int)(r->size * r->ysch) / 100;
2153
 
 
2154
 
        float facx = (v2d->mask.xmax - v2d->mask.xmin) / winx;
2155
 
        float facy = (v2d->mask.ymax - v2d->mask.ymin) / winy;
2156
 
 
2157
 
        BLI_resize_rctf(&v2d->cur, (int)(winx * facx * ratio) + 1, (int)(winy * facy * ratio) + 1);
 
2187
        float winx = (int)(rd->size * rd->xsch) / 100;
 
2188
        float winy = (int)(rd->size * rd->ysch) / 100;
 
2189
 
 
2190
        float facx = BLI_rcti_size_x(&v2d->mask) / winx;
 
2191
        float facy = BLI_rcti_size_y(&v2d->mask) / winy;
 
2192
 
 
2193
        BLI_rctf_resize(&v2d->cur, (int)(winx * facx * ratio) + 1, (int)(winy * facy * ratio) + 1);
2158
2194
 
2159
2195
        ED_region_tag_redraw(CTX_wm_region(C));
2160
2196
 
2173
2209
        ot->poll = ED_operator_sequencer_active;
2174
2210
 
2175
2211
        /* properties */
2176
 
        RNA_def_float(ot->srna, "ratio", 1.0f, 0.0f, FLT_MAX,
 
2212
        RNA_def_float(ot->srna, "ratio", 1.0f, -FLT_MAX, FLT_MAX,
2177
2213
                      "Ratio", "Zoom ratio, 1.0 is 1:1, higher is zoomed in, lower is zoomed out", -FLT_MAX, FLT_MAX);
2178
2214
}
2179
2215
 
2221
2257
{
2222
2258
        Scene *scene = CTX_data_scene(C);
2223
2259
        View2D *v2d = UI_view2d_fromcontext(C);
2224
 
        ScrArea *area = CTX_wm_area(C);
2225
 
        bScreen *sc = CTX_wm_screen(C);
2226
 
        Editing *ed = seq_give_editing(scene, FALSE);
 
2260
        ARegion *ar = CTX_wm_region(C);
 
2261
        Editing *ed = BKE_sequencer_editing_get(scene, FALSE);
2227
2262
        Sequence *seq;
 
2263
        rctf cur_new = v2d->cur;
2228
2264
 
2229
2265
        int xmin =  MAXFRAME * 2;
2230
2266
        int xmax = -MAXFRAME * 2;
2240
2276
 
2241
2277
        for (seq = ed->seqbasep->first; seq; seq = seq->next) {
2242
2278
                if (seq->flag & SELECT) {
2243
 
                        xmin = MIN2(xmin, seq->startdisp);
2244
 
                        xmax = MAX2(xmax, seq->enddisp);
 
2279
                        xmin = min_ii(xmin, seq->startdisp);
 
2280
                        xmax = max_ii(xmax, seq->enddisp);
2245
2281
 
2246
 
                        ymin = MIN2(ymin, seq->machine);
2247
 
                        ymax = MAX2(ymax, seq->machine);
 
2282
                        ymin = min_ii(ymin, seq->machine);
 
2283
                        ymax = max_ii(ymax, seq->machine);
2248
2284
                }
2249
2285
        }
2250
2286
 
2255
2291
                ymax += ymargin;
2256
2292
                ymin -= ymargin;
2257
2293
 
2258
 
                orig_height = v2d->cur.ymax - v2d->cur.ymin;
2259
 
 
2260
 
                v2d->cur.xmin = xmin;
2261
 
                v2d->cur.xmax = xmax;
2262
 
 
2263
 
                v2d->cur.ymin = ymin;
2264
 
                v2d->cur.ymax = ymax;
 
2294
                orig_height = BLI_rctf_size_y(&cur_new);
 
2295
 
 
2296
                cur_new.xmin = xmin;
 
2297
                cur_new.xmax = xmax;
 
2298
 
 
2299
                cur_new.ymin = ymin;
 
2300
                cur_new.ymax = ymax;
2265
2301
 
2266
2302
                /* only zoom out vertically */
2267
 
                if (orig_height > v2d->cur.ymax - v2d->cur.ymin) {
2268
 
                        ymid = (v2d->cur.ymax + v2d->cur.ymin) / 2;
 
2303
                if (orig_height > BLI_rctf_size_y(&cur_new)) {
 
2304
                        ymid = BLI_rctf_cent_y(&cur_new);
2269
2305
 
2270
 
                        v2d->cur.ymin = ymid - (orig_height / 2);
2271
 
                        v2d->cur.ymax = ymid + (orig_height / 2);
 
2306
                        cur_new.ymin = ymid - (orig_height / 2);
 
2307
                        cur_new.ymax = ymid + (orig_height / 2);
2272
2308
                }
2273
2309
 
2274
 
                UI_view2d_curRect_validate(v2d);
2275
 
                UI_view2d_sync(sc, area, v2d, V2D_LOCK_COPY);
 
2310
                UI_view2d_smooth_view(C, ar, &cur_new);
2276
2311
 
2277
 
                ED_area_tag_redraw(CTX_wm_area(C));
 
2312
                return OPERATOR_FINISHED;
 
2313
        }
 
2314
        else {
 
2315
                return OPERATOR_CANCELLED;
2278
2316
        }
2279
2317
        
2280
 
        return OPERATOR_FINISHED;
2281
2318
}
2282
2319
 
2283
2320
void SEQUENCER_OT_view_selected(wmOperatorType *ot)
2296
2333
}
2297
2334
 
2298
2335
 
2299
 
static int find_next_prev_edit(Scene *scene, int cfra, int side)
 
2336
static int find_next_prev_edit(Scene *scene, int cfra,
 
2337
                               const short side,
 
2338
                               const short do_skip_mute, const short do_center)
2300
2339
{
2301
 
        Editing *ed = seq_give_editing(scene, FALSE);
 
2340
        Editing *ed = BKE_sequencer_editing_get(scene, FALSE);
2302
2341
        Sequence *seq, *best_seq = NULL, *frame_seq = NULL;
2303
2342
        
2304
2343
        int dist, best_dist;
2307
2346
        if (ed == NULL) return cfra;
2308
2347
        
2309
2348
        for (seq = ed->seqbasep->first; seq; seq = seq->next) {
 
2349
                int seq_frame;
 
2350
 
 
2351
                if (do_skip_mute && (seq->flag & SEQ_MUTE)) {
 
2352
                        continue;
 
2353
                }
 
2354
 
 
2355
                if (do_center) {
 
2356
                        seq_frame = (seq->startdisp + seq->enddisp) / 2;
 
2357
                }
 
2358
                else {
 
2359
                        seq_frame = seq->startdisp;
 
2360
                }
 
2361
 
2310
2362
                dist = MAXFRAME * 2;
2311
2363
                        
2312
2364
                switch (side) {
2313
2365
                        case SEQ_SIDE_LEFT:
2314
 
                                if (seq->startdisp < cfra) {
2315
 
                                        dist = cfra - seq->startdisp;
 
2366
                                if (seq_frame < cfra) {
 
2367
                                        dist = cfra - seq_frame;
2316
2368
                                }
2317
2369
                                break;
2318
2370
                        case SEQ_SIDE_RIGHT:
2319
 
                                if (seq->startdisp > cfra) {
2320
 
                                        dist = seq->startdisp - cfra;
 
2371
                                if (seq_frame > cfra) {
 
2372
                                        dist = seq_frame - cfra;
2321
2373
                                }
2322
 
                                else if (seq->startdisp == cfra) {
 
2374
                                else if (seq_frame == cfra) {
2323
2375
                                        frame_seq = seq;
2324
2376
                                }
2325
2377
                                break;
2334
2386
        /* if no sequence to the right is found and the
2335
2387
         * frame is on the start of the last sequence,
2336
2388
         * move to the end of the last sequence */
2337
 
        if (frame_seq) cfra = frame_seq->enddisp;
2338
 
 
2339
 
        return best_seq ? best_seq->startdisp : cfra;
 
2389
        if (frame_seq) {
 
2390
                if (do_center) {
 
2391
                        cfra = (frame_seq->startdisp + frame_seq->enddisp) / 2;
 
2392
                }
 
2393
                else {
 
2394
                        cfra = frame_seq->enddisp;
 
2395
                }
 
2396
        }
 
2397
 
 
2398
        if (best_seq) {
 
2399
                if (do_center) {
 
2400
                        cfra = (best_seq->startdisp + best_seq->enddisp) / 2;
 
2401
                }
 
2402
                else {
 
2403
                        cfra = best_seq->startdisp;
 
2404
                }
 
2405
        }
 
2406
 
 
2407
        return cfra;
2340
2408
}
2341
2409
 
2342
 
static int next_prev_edit_internal(Scene *scene, int side)
 
2410
static int strip_jump_internal(Scene *scene,
 
2411
                               const short side,
 
2412
                               const short do_skip_mute, const short do_center)
2343
2413
{
2344
 
        int change = 0;
 
2414
        int change = FALSE;
2345
2415
        int cfra = CFRA;
2346
 
        int nfra = find_next_prev_edit(scene, cfra, side);
 
2416
        int nfra = find_next_prev_edit(scene, cfra, side, do_skip_mute, do_center);
2347
2417
        
2348
2418
        if (nfra != cfra) {
2349
2419
                CFRA = nfra;
2350
 
                change = 1;
 
2420
                change = TRUE;
2351
2421
        }
2352
2422
 
2353
2423
        return change;
2354
2424
}
2355
2425
 
2356
 
/* move frame to next edit point operator */
2357
 
static int sequencer_next_edit_exec(bContext *C, wmOperator *UNUSED(op))
2358
 
{
2359
 
        Scene *scene = CTX_data_scene(C);
2360
 
        
2361
 
        if (!next_prev_edit_internal(scene, SEQ_SIDE_RIGHT))
2362
 
                return OPERATOR_CANCELLED;
2363
 
 
2364
 
        WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
2365
 
 
2366
 
        return OPERATOR_FINISHED;
2367
 
}
2368
 
 
2369
 
void SEQUENCER_OT_next_edit(wmOperatorType *ot)
2370
 
{
2371
 
        /* identifiers */
2372
 
        ot->name = "Next Edit";
2373
 
        ot->idname = "SEQUENCER_OT_next_edit";
2374
 
        ot->description = "Move frame to next edit point";
2375
 
        
2376
 
        /* api callbacks */
2377
 
        ot->exec = sequencer_next_edit_exec;
2378
 
        ot->poll = sequencer_edit_poll;
2379
 
        
2380
 
        /* flags */
2381
 
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
2382
 
        
2383
 
        /* properties */
2384
 
}
2385
 
 
2386
 
/* move frame to previous edit point operator */
2387
 
static int sequencer_previous_edit_exec(bContext *C, wmOperator *UNUSED(op))
2388
 
{
2389
 
        Scene *scene = CTX_data_scene(C);
2390
 
        
2391
 
        if (!next_prev_edit_internal(scene, SEQ_SIDE_LEFT))
2392
 
                return OPERATOR_CANCELLED;
2393
 
 
2394
 
        WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
2395
 
        
2396
 
        return OPERATOR_FINISHED;
2397
 
}
2398
 
 
2399
 
void SEQUENCER_OT_previous_edit(wmOperatorType *ot)
2400
 
{
2401
 
        /* identifiers */
2402
 
        ot->name = "Previous Edit";
2403
 
        ot->idname = "SEQUENCER_OT_previous_edit";
 
2426
static int sequencer_strip_jump_poll(bContext *C)
 
2427
{
 
2428
        /* prevent changes during render */
 
2429
        if (G.is_rendering)
 
2430
                return 0;
 
2431
 
 
2432
        return sequencer_edit_poll(C);
 
2433
}
 
2434
 
 
2435
/* jump frame to edit point operator */
 
2436
static int sequencer_strip_jump_exec(bContext *C, wmOperator *op)
 
2437
{
 
2438
        Scene *scene = CTX_data_scene(C);
 
2439
        short next = RNA_boolean_get(op->ptr, "next");
 
2440
        short center = RNA_boolean_get(op->ptr, "center");
 
2441
 
 
2442
        /* currently do_skip_mute is always TRUE */
 
2443
        if (!strip_jump_internal(scene, next ? SEQ_SIDE_RIGHT : SEQ_SIDE_LEFT, TRUE, center)) {
 
2444
                return OPERATOR_CANCELLED;
 
2445
        }
 
2446
 
 
2447
        WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
 
2448
        
 
2449
        return OPERATOR_FINISHED;
 
2450
}
 
2451
 
 
2452
void SEQUENCER_OT_strip_jump(wmOperatorType *ot)
 
2453
{
 
2454
        /* identifiers */
 
2455
        ot->name = "Jump to Strip";
 
2456
        ot->idname = "SEQUENCER_OT_strip_jump";
2404
2457
        ot->description = "Move frame to previous edit point";
2405
 
        
 
2458
 
2406
2459
        /* api callbacks */
2407
 
        ot->exec = sequencer_previous_edit_exec;
2408
 
        ot->poll = sequencer_edit_poll;
2409
 
        
 
2460
        ot->exec = sequencer_strip_jump_exec;
 
2461
        ot->poll = sequencer_strip_jump_poll;
 
2462
 
2410
2463
        /* flags */
2411
2464
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
2412
2465
        
2413
2466
        /* properties */
 
2467
        RNA_def_boolean(ot->srna, "next", TRUE, "Next Strip", "");
 
2468
        RNA_def_boolean(ot->srna, "center", TRUE, "Use strip center", "");
2414
2469
}
2415
2470
 
2416
2471
static void swap_sequence(Scene *scene, Sequence *seqa, Sequence *seqb)
2417
2472
{
2418
2473
        int gap = seqb->startdisp - seqa->enddisp;
2419
 
        seqb->start = (seqb->start - seqb->startdisp) + seqa->startdisp;
2420
 
        calc_sequence(scene, seqb);
2421
 
        seqa->start = (seqa->start - seqa->startdisp) + seqb->enddisp + gap;
2422
 
        calc_sequence(scene, seqa);
 
2474
        int seq_a_start;
 
2475
        int seq_b_start;
 
2476
 
 
2477
        seq_b_start = (seqb->start - seqb->startdisp) + seqa->startdisp;
 
2478
        BKE_sequence_translate(scene, seqb, seq_b_start - seqb->start);
 
2479
        BKE_sequence_calc(scene, seqb);
 
2480
 
 
2481
        seq_a_start = (seqa->start - seqa->startdisp) + seqb->enddisp + gap;
 
2482
        BKE_sequence_translate(scene, seqa, seq_a_start - seqa->start);
 
2483
        BKE_sequence_calc(scene, seqa);
2423
2484
}
2424
2485
 
2425
2486
#if 0
2426
2487
static Sequence *sequence_find_parent(Scene *scene, Sequence *child)
2427
2488
{
2428
 
        Editing *ed = seq_give_editing(scene, FALSE);
 
2489
        Editing *ed = BKE_sequencer_editing_get(scene, FALSE);
2429
2490
        Sequence *parent = NULL;
2430
2491
        Sequence *seq;
2431
2492
 
2432
2493
        if (ed == NULL) return NULL;
2433
2494
 
2434
2495
        for (seq = ed->seqbasep->first; seq; seq = seq->next) {
2435
 
                if ( (seq != child) && seq_is_parent(seq, child) ) {
 
2496
                if ((seq != child) && seq_is_parent(seq, child)) {
2436
2497
                        parent = seq;
2437
2498
                        break;
2438
2499
                }
2445
2506
static int sequencer_swap_exec(bContext *C, wmOperator *op)
2446
2507
{
2447
2508
        Scene *scene = CTX_data_scene(C);
2448
 
        Editing *ed = seq_give_editing(scene, FALSE);
2449
 
        Sequence *active_seq = seq_active_get(scene);
 
2509
        Editing *ed = BKE_sequencer_editing_get(scene, FALSE);
 
2510
        Sequence *active_seq = BKE_sequencer_active_get(scene);
2450
2511
        Sequence *seq, *iseq;
2451
2512
        int side = RNA_enum_get(op->ptr, "side");
2452
2513
 
2457
2518
        if (seq) {
2458
2519
                
2459
2520
                /* disallow effect strips */
2460
 
                if (get_sequence_effect_num_inputs(seq->type) >= 1 && (seq->effectdata || seq->seq1 || seq->seq2 || seq->seq3))
 
2521
                if (BKE_sequence_effect_get_num_inputs(seq->type) >= 1 && (seq->effectdata || seq->seq1 || seq->seq2 || seq->seq3))
2461
2522
                        return OPERATOR_CANCELLED;
2462
 
                if ((get_sequence_effect_num_inputs(active_seq->type) >= 1) && (active_seq->effectdata || active_seq->seq1 || active_seq->seq2 || active_seq->seq3))
 
2523
                if ((BKE_sequence_effect_get_num_inputs(active_seq->type) >= 1) && (active_seq->effectdata || active_seq->seq1 || active_seq->seq2 || active_seq->seq3))
2463
2524
                        return OPERATOR_CANCELLED;
2464
2525
 
2465
2526
                switch (side) {
2473
2534
 
2474
2535
                // XXX - should be a generic function
2475
2536
                for (iseq = scene->ed->seqbasep->first; iseq; iseq = iseq->next) {
2476
 
                        if ((iseq->type & SEQ_EFFECT) && (seq_is_parent(iseq, active_seq) || seq_is_parent(iseq, seq))) {
2477
 
                                calc_sequence(scene, iseq);
 
2537
                        if ((iseq->type & SEQ_TYPE_EFFECT) && (seq_is_parent(iseq, active_seq) || seq_is_parent(iseq, seq))) {
 
2538
                                BKE_sequence_calc(scene, iseq);
2478
2539
                        }
2479
2540
                }
2480
2541
 
2481
2542
                /* do this in a new loop since both effects need to be calculated first */
2482
2543
                for (iseq = scene->ed->seqbasep->first; iseq; iseq = iseq->next) {
2483
 
                        if ((iseq->type & SEQ_EFFECT) && (seq_is_parent(iseq, active_seq) || seq_is_parent(iseq, seq))) {
 
2544
                        if ((iseq->type & SEQ_TYPE_EFFECT) && (seq_is_parent(iseq, active_seq) || seq_is_parent(iseq, seq))) {
2484
2545
                                /* this may now overlap */
2485
 
                                if (seq_test_overlap(ed->seqbasep, iseq) ) {
2486
 
                                        shuffle_seq(ed->seqbasep, iseq, scene);
 
2546
                                if (BKE_sequence_test_overlap(ed->seqbasep, iseq) ) {
 
2547
                                        BKE_sequence_base_shuffle(ed->seqbasep, iseq, scene);
2487
2548
                                }
2488
2549
                        }
2489
2550
                }
2490
2551
 
2491
2552
 
2492
2553
 
2493
 
                sort_seq(scene);
 
2554
                BKE_sequencer_sort(scene);
2494
2555
 
2495
2556
                WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
2496
2557
 
2522
2583
{
2523
2584
        int retval = OPERATOR_CANCELLED;
2524
2585
        Scene *scene = CTX_data_scene(C);
2525
 
        Sequence *active_seq = seq_active_get(scene);
 
2586
        Sequence *active_seq = BKE_sequencer_active_get(scene);
2526
2587
        StripElem *se = NULL;
2527
2588
 
2528
2589
        if (active_seq == NULL)
2531
2592
 
2532
2593
        if (active_seq->strip) {
2533
2594
                switch (active_seq->type) {
2534
 
                        case SEQ_IMAGE:
2535
 
                                se = give_stripelem(active_seq, scene->r.cfra);
 
2595
                        case SEQ_TYPE_IMAGE:
 
2596
                                se = BKE_sequencer_give_stripelem(active_seq, scene->r.cfra);
2536
2597
                                break;
2537
 
                        case SEQ_MOVIE:
 
2598
                        case SEQ_TYPE_MOVIE:
2538
2599
                                se = active_seq->strip->stripdata;
2539
2600
                                break;
2540
 
                        case SEQ_SCENE:
2541
 
                        case SEQ_META:
2542
 
                        case SEQ_RAM_SOUND:
2543
 
                        case SEQ_HD_SOUND:
 
2601
                        case SEQ_TYPE_SCENE:
 
2602
                        case SEQ_TYPE_META:
 
2603
                        case SEQ_TYPE_SOUND_RAM:
 
2604
                        case SEQ_TYPE_SOUND_HD:
2544
2605
                        default:
2545
2606
                                break;
2546
2607
                }
2548
2609
 
2549
2610
        if (se) {
2550
2611
                // prevent setting the render size if sequence values aren't initialized
2551
 
                if ( (se->orig_width > 0) && (se->orig_height > 0) ) {
 
2612
                if ((se->orig_width > 0) && (se->orig_height > 0)) {
2552
2613
                        scene->r.xsch = se->orig_width;
2553
2614
                        scene->r.ysch = se->orig_height;
2554
2615
                        WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene);
2578
2639
 
2579
2640
static void seq_copy_del_sound(Scene *scene, Sequence *seq)
2580
2641
{
2581
 
        if (seq->type == SEQ_META) {
 
2642
        if (seq->type == SEQ_TYPE_META) {
2582
2643
                Sequence *iseq;
2583
2644
                for (iseq = seq->seqbase.first; iseq; iseq = iseq->next) {
2584
2645
                        seq_copy_del_sound(scene, iseq);
2594
2655
static int sequencer_copy_exec(bContext *C, wmOperator *op)
2595
2656
{
2596
2657
        Scene *scene = CTX_data_scene(C);
2597
 
        Editing *ed = seq_give_editing(scene, FALSE);
2598
 
        Sequence *seq;
 
2658
        Editing *ed = BKE_sequencer_editing_get(scene, FALSE);
2599
2659
 
2600
2660
        ListBase nseqbase = {NULL, NULL};
2601
2661
 
2602
 
        seq_free_clipboard();
 
2662
        BKE_sequencer_free_clipboard();
2603
2663
 
2604
 
        if (seqbase_isolated_sel_check(ed->seqbasep) == FALSE) {
 
2664
        if (BKE_sequence_base_isolated_sel_check(ed->seqbasep) == FALSE) {
2605
2665
                BKE_report(op->reports, RPT_ERROR, "Please select all related strips");
2606
2666
                return OPERATOR_CANCELLED;
2607
2667
        }
2608
2668
 
2609
 
        seqbase_dupli_recursive(scene, NULL, &nseqbase, ed->seqbasep, SEQ_DUPE_UNIQUE_NAME);
 
2669
        BKE_sequence_base_dupli_recursive(scene, NULL, &nseqbase, ed->seqbasep, SEQ_DUPE_UNIQUE_NAME);
2610
2670
 
2611
2671
        /* To make sure the copied strips have unique names between each other add
2612
2672
         * them temporarily to the end of the original seqbase. (bug 25932)
2616
2676
                BLI_movelisttolist(ed->seqbasep, &nseqbase);
2617
2677
 
2618
2678
                for (seq = first_seq; seq; seq = seq->next)
2619
 
                        seq_recursive_apply(seq, apply_unique_name_cb, scene);
 
2679
                        BKE_sequencer_recursive_apply(seq, apply_unique_name_cb, scene);
2620
2680
 
2621
2681
                seqbase_clipboard.first = first_seq;
2622
2682
                seqbase_clipboard.last = ed->seqbasep->last;
2631
2691
        seqbase_clipboard_frame = scene->r.cfra;
2632
2692
 
2633
2693
        /* Need to remove anything that references the current scene */
2634
 
        for (seq = seqbase_clipboard.first; seq; seq = seq->next) {
2635
 
                seq_copy_del_sound(scene, seq);
 
2694
        {
 
2695
                Sequence *seq;
 
2696
                for (seq = seqbase_clipboard.first; seq; seq = seq->next) {
 
2697
                        seq_copy_del_sound(scene, seq);
 
2698
                }
2636
2699
        }
2637
2700
 
2638
2701
        return OPERATOR_FINISHED;
2655
2718
        /* properties */
2656
2719
}
2657
2720
 
2658
 
static void seq_paste_add_sound(Scene *scene, Sequence *seq)
2659
 
{
2660
 
        if (seq->type == SEQ_META) {
2661
 
                Sequence *iseq;
2662
 
                for (iseq = seq->seqbase.first; iseq; iseq = iseq->next) {
2663
 
                        seq_paste_add_sound(scene, iseq);
2664
 
                }
2665
 
        }
2666
 
        else if (seq->type == SEQ_SOUND) {
2667
 
                seq->scene_sound = sound_add_scene_sound_defaults(scene, seq);
2668
 
        }
2669
 
}
2670
 
 
2671
2721
static int sequencer_paste_exec(bContext *C, wmOperator *UNUSED(op))
2672
2722
{
2673
2723
        Scene *scene = CTX_data_scene(C);
2674
 
        Editing *ed = seq_give_editing(scene, TRUE); /* create if needed */
 
2724
        Editing *ed = BKE_sequencer_editing_get(scene, TRUE); /* create if needed */
2675
2725
        ListBase nseqbase = {NULL, NULL};
2676
2726
        int ofs;
2677
2727
        Sequence *iseq;
2678
2728
 
2679
 
        deselect_all_seq(scene);
 
2729
        ED_sequencer_deselect_all(scene);
2680
2730
        ofs = scene->r.cfra - seqbase_clipboard_frame;
2681
2731
 
2682
 
        seqbase_dupli_recursive(scene, NULL, &nseqbase, &seqbase_clipboard, SEQ_DUPE_UNIQUE_NAME);
 
2732
        BKE_sequence_base_dupli_recursive(scene, NULL, &nseqbase, &seqbase_clipboard, SEQ_DUPE_UNIQUE_NAME);
2683
2733
 
2684
2734
        /* transform pasted strips before adding */
2685
2735
        if (ofs) {
2686
2736
                for (iseq = nseqbase.first; iseq; iseq = iseq->next) {
2687
 
                        seq_translate(scene, iseq, ofs);
2688
 
                        seq_sound_init(scene, iseq);
 
2737
                        BKE_sequence_translate(scene, iseq, ofs);
 
2738
                        BKE_sequence_sound_init(scene, iseq);
2689
2739
                }
2690
2740
        }
2691
2741
 
2695
2745
 
2696
2746
        /* make sure the pasted strips have unique names between them */
2697
2747
        for (; iseq; iseq = iseq->next) {
2698
 
                seq_recursive_apply(iseq, apply_unique_name_cb, scene);
2699
 
 
2700
 
                /* restore valid sound_scene for newly added strips */
2701
 
                seq_paste_add_sound(scene, iseq);
 
2748
                BKE_sequencer_recursive_apply(iseq, apply_unique_name_cb, scene);
2702
2749
        }
2703
2750
 
2704
2751
        WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
2730
2777
        Sequence *seq_other;
2731
2778
        const char *error_msg;
2732
2779
 
2733
 
        if (seq_active_pair_get(scene, &seq_act, &seq_other) == 0) {
2734
 
                BKE_report(op->reports, RPT_ERROR, "Must select 2 strips");
 
2780
        if (BKE_sequencer_active_get_pair(scene, &seq_act, &seq_other) == 0) {
 
2781
                BKE_report(op->reports, RPT_ERROR, "Please select two strips");
2735
2782
                return OPERATOR_CANCELLED;
2736
2783
        }
2737
2784
 
2738
 
        if (seq_swap(seq_act, seq_other, &error_msg) == 0) {
 
2785
        if (BKE_sequence_swap(seq_act, seq_other, &error_msg) == 0) {
2739
2786
                BKE_report(op->reports, RPT_ERROR, error_msg);
2740
2787
                return OPERATOR_CANCELLED;
2741
2788
        }
2742
2789
 
2743
 
        sound_remove_scene_sound(scene, seq_act->scene_sound);
2744
 
        sound_remove_scene_sound(scene, seq_other->scene_sound);
 
2790
        if (seq_act->scene_sound)
 
2791
                sound_remove_scene_sound(scene, seq_act->scene_sound);
 
2792
 
 
2793
        if (seq_other->scene_sound)
 
2794
                sound_remove_scene_sound(scene, seq_other->scene_sound);
2745
2795
 
2746
2796
        seq_act->scene_sound = NULL;
2747
2797
        seq_other->scene_sound = NULL;
2748
2798
 
2749
 
        calc_sequence(scene, seq_act);
2750
 
        calc_sequence(scene, seq_other);
 
2799
        BKE_sequence_calc(scene, seq_act);
 
2800
        BKE_sequence_calc(scene, seq_other);
2751
2801
 
2752
2802
        if (seq_act->sound) sound_add_scene_sound_defaults(scene, seq_act);
2753
2803
        if (seq_other->sound) sound_add_scene_sound_defaults(scene, seq_other);
2778
2828
static int view_ghost_border_exec(bContext *C, wmOperator *op)
2779
2829
{
2780
2830
        Scene *scene = CTX_data_scene(C);
2781
 
        Editing *ed = seq_give_editing(scene, FALSE);
 
2831
        Editing *ed = BKE_sequencer_editing_get(scene, FALSE);
2782
2832
        View2D *v2d = UI_view2d_fromcontext(C);
2783
2833
 
2784
2834
        rctf rect;
2790
2840
        if (ed == NULL)
2791
2841
                return OPERATOR_CANCELLED;
2792
2842
 
2793
 
        rect.xmin /=  (float)(ABS(v2d->tot.xmax - v2d->tot.xmin));
2794
 
        rect.ymin /=  (float)(ABS(v2d->tot.ymax - v2d->tot.ymin));
 
2843
        rect.xmin /=  fabsf(BLI_rctf_size_x(&v2d->tot));
 
2844
        rect.ymin /=  fabsf(BLI_rctf_size_y(&v2d->tot));
2795
2845
 
2796
 
        rect.xmax /=  (float)(ABS(v2d->tot.xmax - v2d->tot.xmin));
2797
 
        rect.ymax /=  (float)(ABS(v2d->tot.ymax - v2d->tot.ymin));
 
2846
        rect.xmax /=  fabsf(BLI_rctf_size_x(&v2d->tot));
 
2847
        rect.ymax /=  fabsf(BLI_rctf_size_y(&v2d->tot));
2798
2848
 
2799
2849
        rect.xmin += 0.5f;
2800
2850
        rect.xmax += 0.5f;
2848
2898
        /* identifiers */
2849
2899
        ot->name = "Rebuild Proxy and Timecode Indices";
2850
2900
        ot->idname = "SEQUENCER_OT_rebuild_proxy";
2851
 
        ot->description = "Rebuild all selected proxies and timecode indeces using the job system";
 
2901
        ot->description = "Rebuild all selected proxies and timecode indices using the job system";
2852
2902
        
2853
2903
        /* api callbacks */
2854
2904
        ot->exec = sequencer_rebuild_proxy_exec;
2870
2920
static int sequencer_change_effect_input_exec(bContext *C, wmOperator *op)
2871
2921
{
2872
2922
        Scene *scene = CTX_data_scene(C);
2873
 
        Editing *ed = seq_give_editing(scene, FALSE);
2874
 
        Sequence *seq = seq_active_get(scene);
 
2923
        Editing *ed = BKE_sequencer_editing_get(scene, FALSE);
 
2924
        Sequence *seq = BKE_sequencer_active_get(scene);
2875
2925
 
2876
2926
        Sequence **seq_1, **seq_2;
2877
2927
 
2891
2941
        }
2892
2942
 
2893
2943
        if (*seq_1 == NULL || *seq_2 == NULL) {
2894
 
                BKE_report(op->reports, RPT_ERROR, "One of the effect inputs is unset, can't swap");
 
2944
                BKE_report(op->reports, RPT_ERROR, "One of the effect inputs is unset, cannot swap");
2895
2945
                return OPERATOR_CANCELLED;
2896
2946
        }
2897
2947
        else {
2898
2948
                SWAP(Sequence *, *seq_1, *seq_2);
2899
2949
        }
2900
2950
 
2901
 
        update_changed_seq_and_deps(scene, seq, 0, 1);
 
2951
        BKE_sequencer_update_changed_seq_and_deps(scene, seq, 0, 1);
2902
2952
 
2903
2953
        /* important else we don't get the imbuf cache flushed */
2904
 
        free_imbuf_seq(scene, &ed->seqbase, FALSE, FALSE);
 
2954
        BKE_sequencer_free_imbuf(scene, &ed->seqbase, FALSE);
2905
2955
 
2906
2956
        WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
2907
2957
 
2928
2978
static int sequencer_change_effect_type_exec(bContext *C, wmOperator *op)
2929
2979
{
2930
2980
        Scene *scene = CTX_data_scene(C);
2931
 
        Editing *ed = seq_give_editing(scene, FALSE);
2932
 
        Sequence *seq = seq_active_get(scene);
 
2981
        Editing *ed = BKE_sequencer_editing_get(scene, FALSE);
 
2982
        Sequence *seq = BKE_sequencer_active_get(scene);
2933
2983
        const int new_type = RNA_enum_get(op->ptr, "type");
2934
2984
 
2935
2985
        /* free previous effect and init new effect */
2936
2986
        struct SeqEffectHandle sh;
2937
2987
 
2938
 
        if ((seq->type & SEQ_EFFECT) == 0) {
 
2988
        if ((seq->type & SEQ_TYPE_EFFECT) == 0) {
2939
2989
                return OPERATOR_CANCELLED;
2940
2990
        }
2941
2991
 
2942
2992
        /* can someone explain the logic behind only allowing to increase this,
2943
2993
         * copied from 2.4x - campbell */
2944
 
        if (get_sequence_effect_num_inputs(seq->type) <
2945
 
            get_sequence_effect_num_inputs(new_type))
 
2994
        if (BKE_sequence_effect_get_num_inputs(seq->type) <
 
2995
            BKE_sequence_effect_get_num_inputs(new_type))
2946
2996
        {
2947
2997
                BKE_report(op->reports, RPT_ERROR, "New effect needs more input strips");
2948
2998
                return OPERATOR_CANCELLED;
2949
2999
        }
2950
3000
        else {
2951
 
                sh = get_sequence_effect(seq);
 
3001
                sh = BKE_sequence_get_effect(seq);
2952
3002
                sh.free(seq);
2953
3003
 
2954
3004
                seq->type = new_type;
2955
3005
 
2956
 
                sh = get_sequence_effect(seq);
 
3006
                sh = BKE_sequence_get_effect(seq);
2957
3007
                sh.init(seq);
2958
3008
        }
2959
3009
 
2960
3010
        /* update */
2961
 
        update_changed_seq_and_deps(scene, seq, 0, 1);
 
3011
        BKE_sequencer_update_changed_seq_and_deps(scene, seq, 0, 1);
2962
3012
 
2963
3013
        /* important else we don't get the imbuf cache flushed */
2964
 
        free_imbuf_seq(scene, &ed->seqbase, FALSE, FALSE);
 
3014
        BKE_sequencer_free_imbuf(scene, &ed->seqbase, FALSE);
2965
3015
 
2966
3016
        WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
2967
3017
 
2982
3032
        /* flags */
2983
3033
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
2984
3034
 
2985
 
        ot->prop = RNA_def_enum(ot->srna, "type", sequencer_prop_effect_types, SEQ_CROSS, "Type", "Sequencer effect type");
 
3035
        ot->prop = RNA_def_enum(ot->srna, "type", sequencer_prop_effect_types, SEQ_TYPE_CROSS, "Type", "Sequencer effect type");
2986
3036
}
2987
3037
 
2988
3038
static int sequencer_change_path_exec(bContext *C, wmOperator *op)
2989
3039
{
2990
3040
        Main *bmain = CTX_data_main(C);
2991
3041
        Scene *scene = CTX_data_scene(C);
2992
 
        Editing *ed = seq_give_editing(scene, FALSE);
2993
 
        Sequence *seq = seq_active_get(scene);
 
3042
        Editing *ed = BKE_sequencer_editing_get(scene, FALSE);
 
3043
        Sequence *seq = BKE_sequencer_active_get(scene);
2994
3044
        const int is_relative_path = RNA_boolean_get(op->ptr, "relative_path");
2995
3045
 
2996
 
        if (seq->type == SEQ_IMAGE) {
 
3046
        if (seq->type == SEQ_TYPE_IMAGE) {
2997
3047
                char directory[FILE_MAX];
2998
3048
                const int len = RNA_property_collection_length(op->ptr, RNA_struct_find_property(op->ptr, "files"));
2999
3049
                StripElem *se;
3015
3065
                }
3016
3066
                seq->strip->stripdata = se = MEM_callocN(len * sizeof(StripElem), "stripelem");
3017
3067
 
3018
 
                RNA_BEGIN(op->ptr, itemptr, "files") {
 
3068
                RNA_BEGIN (op->ptr, itemptr, "files")
 
3069
                {
3019
3070
                        char *filename = RNA_string_get_alloc(&itemptr, "name", NULL, 0);
3020
3071
                        BLI_strncpy(se->name, filename, sizeof(se->name));
3021
3072
                        MEM_freeN(filename);
3027
3078
                seq->anim_startofs = seq->anim_endofs = 0;
3028
3079
 
3029
3080
                /* correct start/end frames so we don't move
3030
 
                 * important not to set seq->len= len; allow the function to handle it */
3031
 
                reload_sequence_new_file(scene, seq, TRUE);
 
3081
                 * important not to set seq->len = len; allow the function to handle it */
 
3082
                BKE_sequence_reload_new_file(scene, seq, TRUE);
3032
3083
 
3033
 
                calc_sequence(scene, seq);
 
3084
                BKE_sequence_calc(scene, seq);
3034
3085
 
3035
3086
                /* important else we don't get the imbuf cache flushed */
3036
 
                free_imbuf_seq(scene, &ed->seqbase, FALSE, FALSE);
 
3087
                BKE_sequencer_free_imbuf(scene, &ed->seqbase, FALSE);
3037
3088
        }
3038
3089
        else {
3039
3090
                /* lame, set rna filepath */
3057
3108
static int sequencer_change_path_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
3058
3109
{
3059
3110
        Scene *scene = CTX_data_scene(C);
3060
 
        Sequence *seq = seq_active_get(scene);
 
3111
        Sequence *seq = BKE_sequencer_active_get(scene);
 
3112
        char filepath[FILE_MAX];
 
3113
 
 
3114
        BLI_join_dirfile(filepath, sizeof(filepath), seq->strip->dir, seq->strip->stripdata->name);
3061
3115
 
3062
3116
        RNA_string_set(op->ptr, "directory", seq->strip->dir);
 
3117
        RNA_string_set(op->ptr, "filepath",  filepath);
3063
3118
 
3064
3119
        /* set default display depending on seq type */
3065
 
        if (seq->type == SEQ_IMAGE) {
 
3120
        if (seq->type == SEQ_TYPE_IMAGE) {
3066
3121
                RNA_boolean_set(op->ptr, "filter_movie", FALSE);
3067
3122
        }
3068
3123
        else {
3089
3144
        /* flags */
3090
3145
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
3091
3146
 
3092
 
        WM_operator_properties_filesel(ot, FOLDERFILE | IMAGEFILE | MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_DIRECTORY | WM_FILESEL_RELPATH | WM_FILESEL_FILEPATH | WM_FILESEL_FILES, FILE_DEFAULTDISPLAY);
 
3147
        WM_operator_properties_filesel(ot, FOLDERFILE | IMAGEFILE | MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE,
 
3148
                                       WM_FILESEL_DIRECTORY | WM_FILESEL_RELPATH | WM_FILESEL_FILEPATH | WM_FILESEL_FILES,
 
3149
                                       FILE_DEFAULTDISPLAY);
3093
3150
}
3094
3151