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}
164
165
static void proxy_endjob(void *pjv)
166
167
ProxyJob *pj = pjv;
167
Editing *ed = seq_give_editing(pj->scene, FALSE);
168
Editing *ed = BKE_sequencer_editing_get(pj->scene, FALSE);
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);
174
free_imbuf_seq(pj->scene, &ed->seqbase, FALSE, FALSE);
175
BKE_sequencer_free_imbuf(pj->scene, &ed->seqbase, FALSE);
176
177
WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, pj->scene);
179
180
static void seq_proxy_build_job(const bContext *C)
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;
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);
192
pj = WM_jobs_get_customdata(steve);
194
pj = WM_jobs_customdata_get(wm_job);
195
197
pj = MEM_callocN(sizeof(ProxyJob), "proxy rebuild job");
197
199
pj->scene = scene;
198
200
pj->main = CTX_data_main(C);
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);
205
SEQP_BEGIN(ed, seq) {
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);
214
if (!WM_jobs_is_running(steve)) {
216
WM_jobs_start(CTX_wm_manager(C), steve);
217
if (!WM_jobs_is_running(wm_job)) {
219
WM_jobs_start(CTX_wm_manager(C), wm_job);
219
222
ED_area_tag_redraw(CTX_wm_area(C));
231
234
rectf->ymax = seq->machine + SEQ_STRIP_OFSTOP;
234
static void UNUSED_FUNCTION(change_plugin_seq) (Scene * scene, char *str) /* called from fileselect */
236
Editing *ed = seq_give_editing(scene, FALSE);
237
struct SeqEffectHandle sh;
238
Sequence *last_seq = seq_active_get(scene);
240
if (last_seq == NULL || last_seq->type != SEQ_PLUGIN) return;
242
sh = get_sequence_effect(last_seq);
244
sh.init_plugin(last_seq, str);
246
last_seq->machine = MAX3(last_seq->seq1->machine,
247
last_seq->seq2->machine,
248
last_seq->seq3->machine);
250
if (seq_test_overlap(ed->seqbasep, last_seq) ) shuffle_seq(ed->seqbasep, last_seq, scene);
255
237
void boundbox_seq(Scene *scene, rctf *rect)
258
Editing *ed = seq_give_editing(scene, FALSE);
240
Editing *ed = BKE_sequencer_editing_get(scene, FALSE);
259
241
float min[2], max[2];
472
int ED_space_sequencer_maskedit_mask_poll(bContext *C)
474
/* in this case both funcs are the same, for clip editor not */
475
return ED_space_sequencer_maskedit_poll(C);
478
int ED_space_sequencer_check_show_maskedit(SpaceSeq *sseq, Scene *scene)
480
if (sseq && sseq->mainb == SEQ_DRAW_IMG_IMBUF) {
481
return (BKE_sequencer_mask_get(scene) != NULL);
487
int ED_space_sequencer_maskedit_poll(bContext *C)
489
SpaceSeq *sseq = CTX_wm_space_seq(C);
492
Scene *scene = CTX_data_scene(C);
493
return ED_space_sequencer_check_show_maskedit(sseq, scene);
499
/* are we displaying the seq output (not channels or histogram)*/
500
int ED_space_sequencer_check_show_imbuf(SpaceSeq *sseq)
502
return (ELEM(sseq->view, SEQ_VIEW_PREVIEW, SEQ_VIEW_SEQUENCE_PREVIEW) &&
503
ELEM(sseq->mainb, SEQ_DRAW_SEQUENCE, SEQ_DRAW_IMG_IMBUF));
490
506
int seq_effect_find_selected(Scene *scene, Sequence *activeseq, int type, Sequence **selseq1, Sequence **selseq2, Sequence **selseq3, const char **error_str)
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;
495
511
*error_str = NULL;
498
seq2 = seq_active_get(scene);
514
seq2 = BKE_sequencer_active_get(scene);
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");
506
522
if ((seq != activeseq) && (seq != seq2)) {
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) {
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);
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);
675
693
seqn->flag |= SELECT;
677
695
/* Second Strip! */
792
810
seqn->startstill = 0;
795
calc_sequence(scene, seqn);
813
BKE_sequence_calc(scene, seqn);
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)
827
static int cut_seq_list(Scene *scene, ListBase *slist, int cutframe,
804
828
Sequence * (*cut_seq)(Scene *, Sequence *, int))
806
int did_something = FALSE;
807
830
Sequence *seq, *seq_next_iter;
831
Sequence *seq_first_new = NULL;
835
while (seq && seq != seq_first_new) {
812
836
seq_next_iter = seq->next; /* we need this because we may remove seq */
815
838
if (seq->flag & SELECT) {
816
839
if (cutframe > seq->startdisp &&
819
842
Sequence *seqn = cut_seq(scene, seq, cutframe);
821
BLI_addtail(new, seqn);
844
BLI_addtail(slist, seqn);
845
if (seq_first_new == NULL) {
846
seq_first_new = seqn;
823
did_something = TRUE;
825
850
else if (seq->enddisp <= cutframe) {
828
853
else if (seq->startdisp >= cutframe) {
829
/* move into new list */
830
BLI_remlink(old, seq);
831
BLI_addtail(new, seq);
855
BLI_remlink(slist, seq);
856
BLI_addtail(slist, seq);
858
if (seq_first_new == NULL) {
834
863
seq = seq_next_iter;
836
return did_something;
866
return (seq_first_new != NULL);
839
869
static int insert_gap(Scene *scene, int gap, int cfra)
842
Editing *ed = seq_give_editing(scene, FALSE);
872
Editing *ed = BKE_sequencer_editing_get(scene, FALSE);
845
875
/* all strips >= cfra are shifted */
847
877
if (ed == NULL) return 0;
849
SEQP_BEGIN(ed, seq) {
850
881
if (seq->startdisp >= cfra) {
851
882
seq->start += gap;
852
calc_sequence(scene, seq);
883
BKE_sequence_calc(scene, seq);
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: "))
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: "))
936
967
if (strcmp(to, from) == 0)
941
972
if (seq->flag & SELECT) {
942
973
if (strncmp(seq->strip->dir, from, strlen(from)) == 0) {
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) &&
1076
BKE_sequence_tx_test(seq))
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; */
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);
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);
1057
1088
else { /* SEQ_RIGHTSEL */
1058
seq_tx_set_final_right(seq, snap_frame);
1089
BKE_sequence_tx_set_final_right(seq, snap_frame);
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);
1062
calc_sequence(scene, seq);
1093
BKE_sequence_calc(scene, seq);
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);
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);
1117
BKE_sequencer_sort(scene);
1088
1119
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
1284
1323
static int sequencer_reload_exec(bContext *C, wmOperator *op)
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);
1289
1328
int adjust_length = RNA_boolean_get(op->ptr, "adjust_length");
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);
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);
1458
1497
static int sequencer_cut_exec(bContext *C, wmOperator *op)
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;
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");
1471
newlist.first = newlist.last = NULL;
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);
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);
1480
if (newlist.first) { /* got new strips ? */
1516
if (changed) { /* got new strips ? */
1482
BLI_movelisttolist(ed->seqbasep, &newlist);
1484
1519
if (cut_side != SEQ_SIDE_BOTH) {
1485
SEQP_BEGIN(ed, seq) {
1520
SEQP_BEGIN (ed, seq)
1486
1522
if (cut_side == SEQ_SIDE_LEFT) {
1487
1523
if (seq->startdisp >= cut_frame) {
1488
1524
seq->flag &= ~SEQ_ALLSEL;
1756
1795
seq = ed->seqbasep->first; /* poll checks this is valid */
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 */
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);
1769
1808
while (cfra < frame_end) {
1771
se = give_stripelem(seq, cfra);
1810
se = BKE_sequencer_give_stripelem(seq, cfra);
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);
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;
1909
1952
static int sequencer_meta_make_exec(bContext *C, wmOperator *op)
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);
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;
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;
1922
1965
/* remove all selected from main list, and put in meta */
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;
1929
1972
seq = ed->seqbasep->first;
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);
1939
1982
seqm->machine = last_seq ? last_seq->machine : channel_max;
1940
calc_sequence(scene, seqm);
1983
BKE_sequence_calc(scene, seqm);
1942
1985
seqm->strip = MEM_callocN(sizeof(Strip), "metastrip");
1943
1986
seqm->strip->us = 1;
1945
seq_active_set(scene, seqm);
1947
if (seq_test_overlap(ed->seqbasep, seqm) ) shuffle_seq(ed->seqbasep, seqm, scene);
1949
seq_update_muting(ed);
1951
seqbase_unique_name_recursive(&scene->ed->seqbase, seqm);
1988
BKE_sequencer_active_set(scene, seqm);
1990
if (BKE_sequence_test_overlap(ed->seqbasep, seqm) ) BKE_sequence_base_shuffle(ed->seqbasep, seqm, scene);
1992
BKE_sequencer_update_muting(ed);
1994
BKE_sequence_base_unique_name_recursive(&scene->ed->seqbase, seqm);
1953
1996
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
2144
2180
static int sequencer_view_zoom_ratio_exec(bContext *C, wmOperator *op)
2146
RenderData *r = &CTX_data_scene(C)->r;
2182
RenderData *rd = &CTX_data_scene(C)->r;
2147
2183
View2D *v2d = UI_view2d_fromcontext(C);
2149
2185
float ratio = RNA_float_get(op->ptr, "ratio");
2151
float winx = (int)(r->size * r->xsch) / 100;
2152
float winy = (int)(r->size * r->ysch) / 100;
2154
float facx = (v2d->mask.xmax - v2d->mask.xmin) / winx;
2155
float facy = (v2d->mask.ymax - v2d->mask.ymin) / winy;
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;
2190
float facx = BLI_rcti_size_x(&v2d->mask) / winx;
2191
float facy = BLI_rcti_size_y(&v2d->mask) / winy;
2193
BLI_rctf_resize(&v2d->cur, (int)(winx * facx * ratio) + 1, (int)(winy * facy * ratio) + 1);
2159
2195
ED_region_tag_redraw(CTX_wm_region(C));
2255
2291
ymax += ymargin;
2256
2292
ymin -= ymargin;
2258
orig_height = v2d->cur.ymax - v2d->cur.ymin;
2260
v2d->cur.xmin = xmin;
2261
v2d->cur.xmax = xmax;
2263
v2d->cur.ymin = ymin;
2264
v2d->cur.ymax = ymax;
2294
orig_height = BLI_rctf_size_y(&cur_new);
2296
cur_new.xmin = xmin;
2297
cur_new.xmax = xmax;
2299
cur_new.ymin = ymin;
2300
cur_new.ymax = ymax;
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);
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);
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);
2277
ED_area_tag_redraw(CTX_wm_area(C));
2312
return OPERATOR_FINISHED;
2315
return OPERATOR_CANCELLED;
2280
return OPERATOR_FINISHED;
2283
2320
void SEQUENCER_OT_view_selected(wmOperatorType *ot)
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;
2339
return best_seq ? best_seq->startdisp : cfra;
2391
cfra = (frame_seq->startdisp + frame_seq->enddisp) / 2;
2394
cfra = frame_seq->enddisp;
2400
cfra = (best_seq->startdisp + best_seq->enddisp) / 2;
2403
cfra = best_seq->startdisp;
2342
static int next_prev_edit_internal(Scene *scene, int side)
2410
static int strip_jump_internal(Scene *scene,
2412
const short do_skip_mute, const short do_center)
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);
2348
2418
if (nfra != cfra) {
2356
/* move frame to next edit point operator */
2357
static int sequencer_next_edit_exec(bContext *C, wmOperator *UNUSED(op))
2359
Scene *scene = CTX_data_scene(C);
2361
if (!next_prev_edit_internal(scene, SEQ_SIDE_RIGHT))
2362
return OPERATOR_CANCELLED;
2364
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
2366
return OPERATOR_FINISHED;
2369
void SEQUENCER_OT_next_edit(wmOperatorType *ot)
2372
ot->name = "Next Edit";
2373
ot->idname = "SEQUENCER_OT_next_edit";
2374
ot->description = "Move frame to next edit point";
2377
ot->exec = sequencer_next_edit_exec;
2378
ot->poll = sequencer_edit_poll;
2381
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
2386
/* move frame to previous edit point operator */
2387
static int sequencer_previous_edit_exec(bContext *C, wmOperator *UNUSED(op))
2389
Scene *scene = CTX_data_scene(C);
2391
if (!next_prev_edit_internal(scene, SEQ_SIDE_LEFT))
2392
return OPERATOR_CANCELLED;
2394
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
2396
return OPERATOR_FINISHED;
2399
void SEQUENCER_OT_previous_edit(wmOperatorType *ot)
2402
ot->name = "Previous Edit";
2403
ot->idname = "SEQUENCER_OT_previous_edit";
2426
static int sequencer_strip_jump_poll(bContext *C)
2428
/* prevent changes during render */
2432
return sequencer_edit_poll(C);
2435
/* jump frame to edit point operator */
2436
static int sequencer_strip_jump_exec(bContext *C, wmOperator *op)
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");
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;
2447
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
2449
return OPERATOR_FINISHED;
2452
void SEQUENCER_OT_strip_jump(wmOperatorType *ot)
2455
ot->name = "Jump to Strip";
2456
ot->idname = "SEQUENCER_OT_strip_jump";
2404
2457
ot->description = "Move frame to previous edit point";
2406
2459
/* api callbacks */
2407
ot->exec = sequencer_previous_edit_exec;
2408
ot->poll = sequencer_edit_poll;
2460
ot->exec = sequencer_strip_jump_exec;
2461
ot->poll = sequencer_strip_jump_poll;
2411
2464
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
2413
2466
/* properties */
2467
RNA_def_boolean(ot->srna, "next", TRUE, "Next Strip", "");
2468
RNA_def_boolean(ot->srna, "center", TRUE, "Use strip center", "");
2416
2471
static void swap_sequence(Scene *scene, Sequence *seqa, Sequence *seqb)
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);
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);
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);
2426
2487
static Sequence *sequence_find_parent(Scene *scene, Sequence *child)
2428
Editing *ed = seq_give_editing(scene, FALSE);
2489
Editing *ed = BKE_sequencer_editing_get(scene, FALSE);
2429
2490
Sequence *parent = NULL;
2432
2493
if (ed == NULL) return NULL;
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)) {
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);
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);
2554
BKE_sequencer_sort(scene);
2495
2556
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
2594
2655
static int sequencer_copy_exec(bContext *C, wmOperator *op)
2596
2657
Scene *scene = CTX_data_scene(C);
2597
Editing *ed = seq_give_editing(scene, FALSE);
2658
Editing *ed = BKE_sequencer_editing_get(scene, FALSE);
2600
2660
ListBase nseqbase = {NULL, NULL};
2602
seq_free_clipboard();
2662
BKE_sequencer_free_clipboard();
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;
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);
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)
2655
2718
/* properties */
2658
static void seq_paste_add_sound(Scene *scene, Sequence *seq)
2660
if (seq->type == SEQ_META) {
2662
for (iseq = seq->seqbase.first; iseq; iseq = iseq->next) {
2663
seq_paste_add_sound(scene, iseq);
2666
else if (seq->type == SEQ_SOUND) {
2667
seq->scene_sound = sound_add_scene_sound_defaults(scene, seq);
2671
2721
static int sequencer_paste_exec(bContext *C, wmOperator *UNUSED(op))
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};
2677
2727
Sequence *iseq;
2679
deselect_all_seq(scene);
2729
ED_sequencer_deselect_all(scene);
2680
2730
ofs = scene->r.cfra - seqbase_clipboard_frame;
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);
2684
2734
/* transform pasted strips before adding */
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);
2730
2777
Sequence *seq_other;
2731
2778
const char *error_msg;
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;
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;
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);
2793
if (seq_other->scene_sound)
2794
sound_remove_scene_sound(scene, seq_other->scene_sound);
2746
2796
seq_act->scene_sound = NULL;
2747
2797
seq_other->scene_sound = NULL;
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);
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);
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;
2898
2948
SWAP(Sequence *, *seq_1, *seq_2);
2901
update_changed_seq_and_deps(scene, seq, 0, 1);
2951
BKE_sequencer_update_changed_seq_and_deps(scene, seq, 0, 1);
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);
2906
2956
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
2928
2978
static int sequencer_change_effect_type_exec(bContext *C, wmOperator *op)
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");
2935
2985
/* free previous effect and init new effect */
2936
2986
struct SeqEffectHandle sh;
2938
if ((seq->type & SEQ_EFFECT) == 0) {
2988
if ((seq->type & SEQ_TYPE_EFFECT) == 0) {
2939
2989
return OPERATOR_CANCELLED;
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))
2947
2997
BKE_report(op->reports, RPT_ERROR, "New effect needs more input strips");
2948
2998
return OPERATOR_CANCELLED;
2951
sh = get_sequence_effect(seq);
3001
sh = BKE_sequence_get_effect(seq);
2954
3004
seq->type = new_type;
2956
sh = get_sequence_effect(seq);
3006
sh = BKE_sequence_get_effect(seq);
2961
update_changed_seq_and_deps(scene, seq, 0, 1);
3011
BKE_sequencer_update_changed_seq_and_deps(scene, seq, 0, 1);
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);
2966
3016
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
2983
3033
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
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");
2988
3038
static int sequencer_change_path_exec(bContext *C, wmOperator *op)
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");
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"));
3027
3078
seq->anim_startofs = seq->anim_endofs = 0;
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);
3033
calc_sequence(scene, seq);
3084
BKE_sequence_calc(scene, seq);
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);
3039
3090
/* lame, set rna filepath */