You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

4221 lines
115 KiB

/*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*/
/** \file
* \ingroup spseq
*/
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
#include "BLI_ghash.h"
#include "BLI_math.h"
#include "BLI_timecode.h"
#include "BLI_utildefines.h"
#include "BLT_translation.h"
#include "DNA_scene_types.h"
#include "DNA_sound_types.h"
#include "BKE_context.h"
#include "BKE_global.h"
#include "BKE_lib_id.h"
#include "BKE_main.h"
#include "BKE_report.h"
#include "BKE_sequencer.h"
#include "BKE_sound.h"
#include "WM_api.h"
#include "WM_types.h"
#include "RNA_define.h"
/* For menu, popup, icons, etc. */
#include "ED_numinput.h"
#include "ED_outliner.h"
#include "ED_screen.h"
#include "ED_sequencer.h"
#include "UI_interface.h"
#include "UI_view2d.h"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_build.h"
/* Own include. */
#include "sequencer_intern.h"
/* -------------------------------------------------------------------- */
/** \name Structs & Enums
* \{ */
/* RNA Enums, used in multiple files. */
EnumPropertyItem sequencer_prop_effect_types[] = {
{SEQ_TYPE_CROSS, "CROSS", 0, "Crossfade", "Crossfade effect strip type"},
{SEQ_TYPE_ADD, "ADD", 0, "Add", "Add effect strip type"},
{SEQ_TYPE_SUB, "SUBTRACT", 0, "Subtract", "Subtract effect strip type"},
{SEQ_TYPE_ALPHAOVER, "ALPHA_OVER", 0, "Alpha Over", "Alpha Over effect strip type"},
{SEQ_TYPE_ALPHAUNDER, "ALPHA_UNDER", 0, "Alpha Under", "Alpha Under effect strip type"},
{SEQ_TYPE_GAMCROSS, "GAMMA_CROSS", 0, "Gamma Cross", "Gamma Cross effect strip type"},
{SEQ_TYPE_MUL, "MULTIPLY", 0, "Multiply", "Multiply effect strip type"},
{SEQ_TYPE_OVERDROP, "OVER_DROP", 0, "Alpha Over Drop", "Alpha Over Drop effect strip type"},
{SEQ_TYPE_WIPE, "WIPE", 0, "Wipe", "Wipe effect strip type"},
{SEQ_TYPE_GLOW, "GLOW", 0, "Glow", "Glow effect strip type"},
{SEQ_TYPE_TRANSFORM, "TRANSFORM", 0, "Transform", "Transform effect strip type"},
{SEQ_TYPE_COLOR, "COLOR", 0, "Color", "Color effect strip type"},
{SEQ_TYPE_SPEED, "SPEED", 0, "Speed", "Color effect strip type"},
{SEQ_TYPE_MULTICAM, "MULTICAM", 0, "Multicam Selector", ""},
{SEQ_TYPE_ADJUSTMENT, "ADJUSTMENT", 0, "Adjustment Layer", ""},
{SEQ_TYPE_GAUSSIAN_BLUR, "GAUSSIAN_BLUR", 0, "Gaussian Blur", ""},
{SEQ_TYPE_TEXT, "TEXT", 0, "Text", ""},
{SEQ_TYPE_COLORMIX, "COLORMIX", 0, "Color Mix", ""},
{0, NULL, 0, NULL, NULL},
};
#define SEQ_SIDE_MOUSE -1
EnumPropertyItem prop_side_types[] = {
{SEQ_SIDE_MOUSE, "MOUSE", 0, "Mouse position", ""},
{SEQ_SIDE_LEFT, "LEFT", 0, "Left", ""},
{SEQ_SIDE_RIGHT, "RIGHT", 0, "Right", ""},
{SEQ_SIDE_BOTH, "BOTH", 0, "Both", ""},
{SEQ_SIDE_NO_CHANGE, "NO_CHANGE", 0, "No change", ""},
{0, NULL, 0, NULL, NULL},
};
static const EnumPropertyItem prop_side_lr_types[] = {
{SEQ_SIDE_LEFT, "LEFT", 0, "Left", ""},
{SEQ_SIDE_RIGHT, "RIGHT", 0, "Right", ""},
{0, NULL, 0, NULL, NULL},
};
typedef struct TransSeq {
int start, machine;
int startstill, endstill;
int startdisp, enddisp;
int startofs, endofs;
int anim_startofs, anim_endofs;
/* int final_left, final_right; */ /* UNUSED */
int len;
} TransSeq;
/** \} */
/* -------------------------------------------------------------------- */
/** \name Proxy Job Manager
* \{ */
typedef struct ProxyBuildJob {
struct Main *main;
struct Depsgraph *depsgraph;
Scene *scene;
ListBase queue;
int stop;
} ProxyJob;
static void proxy_freejob(void *pjv)
{
ProxyJob *pj = pjv;
BLI_freelistN(&pj->queue);
MEM_freeN(pj);
}
/* Only this runs inside thread. */
static void proxy_startjob(void *pjv, short *stop, short *do_update, float *progress)
{
ProxyJob *pj = pjv;
LinkData *link;
for (link = pj->queue.first; link; link = link->next) {
struct SeqIndexBuildContext *context = link->data;
BKE_sequencer_proxy_rebuild(context, stop, do_update, progress);
if (*stop) {
pj->stop = 1;
fprintf(stderr, "Canceling proxy rebuild on users request...\n");
break;
}
}
}
static void proxy_endjob(void *pjv)
{
ProxyJob *pj = pjv;
Editing *ed = BKE_sequencer_editing_get(pj->scene, false);
LinkData *link;
for (link = pj->queue.first; link; link = link->next) {
BKE_sequencer_proxy_rebuild_finish(link->data, pj->stop);
}
BKE_sequencer_free_imbuf(pj->scene, &ed->seqbase, false);
WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, pj->scene);
}
static void seq_proxy_build_job(const bContext *C, ReportList *reports)
{
wmJob *wm_job;
ProxyJob *pj;
struct Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
Scene *scene = CTX_data_scene(C);
Editing *ed = BKE_sequencer_editing_get(scene, false);
ScrArea *area = CTX_wm_area(C);
Sequence *seq;
GSet *file_list;
if (ed == NULL) {
return;
}
wm_job = WM_jobs_get(CTX_wm_manager(C),
CTX_wm_window(C),
scene,
"Building Proxies",
WM_JOB_PROGRESS,
WM_JOB_TYPE_SEQ_BUILD_PROXY);
pj = WM_jobs_customdata_get(wm_job);
if (!pj) {
pj = MEM_callocN(sizeof(ProxyJob), "proxy rebuild job");
pj->depsgraph = depsgraph;
pj->scene = scene;
pj->main = CTX_data_main(C);
WM_jobs_customdata_set(wm_job, pj, proxy_freejob);
WM_jobs_timer(wm_job, 0.1, NC_SCENE | ND_SEQUENCER, NC_SCENE | ND_SEQUENCER);
WM_jobs_callbacks(wm_job, proxy_startjob, NULL, NULL, proxy_endjob);
}
file_list = BLI_gset_new(BLI_ghashutil_strhash_p, BLI_ghashutil_strcmp, "file list");
bool selected = false; /* Check for no selected strips */
SEQP_BEGIN (ed, seq) {
if (!ELEM(seq->type, SEQ_TYPE_MOVIE, SEQ_TYPE_IMAGE, SEQ_TYPE_META) ||
(seq->flag & SELECT) == 0) {
continue;
}
selected = true;
if (!(seq->flag & SEQ_USE_PROXY)) {
BKE_reportf(reports, RPT_WARNING, "Proxy is not enabled for %s, skipping", seq->name);
continue;
}
if (seq->strip->proxy->build_size_flags == 0) {
BKE_reportf(reports, RPT_WARNING, "Resolution is not selected for %s, skipping", seq->name);
continue;
}
bool success = BKE_sequencer_proxy_rebuild_context(
pj->main, pj->depsgraph, pj->scene, seq, file_list, &pj->queue);
if (!success && (seq->strip->proxy->build_flags & SEQ_PROXY_SKIP_EXISTING) != 0) {
BKE_reportf(reports, RPT_WARNING, "Overwrite is not checked for %s, skipping", seq->name);
}
}
SEQ_END;
if (!selected) {
BKE_reportf(reports, RPT_WARNING, "Select movie or image strips");
return;
}
BLI_gset_free(file_list, MEM_freeN);
if (selected && !WM_jobs_is_running(wm_job)) {
G.is_break = false;
WM_jobs_start(CTX_wm_manager(C), wm_job);
}
ED_area_tag_redraw(area);
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name Sequence Query Utilities
* \{ */
void seq_rectf(Sequence *seq, rctf *rect)
{
rect->xmin = seq->startdisp;
rect->xmax = seq->enddisp;
rect->ymin = seq->machine + SEQ_STRIP_OFSBOTTOM;
rect->ymax = seq->machine + SEQ_STRIP_OFSTOP;
}
void boundbox_seq(Scene *scene, rctf *rect)
{
Sequence *seq;
Editing *ed = BKE_sequencer_editing_get(scene, false);
float min[2], max[2];
if (ed == NULL) {
return;
}
min[0] = SFRA;
max[0] = EFRA + 1;
min[1] = 0.0;
max[1] = 8.0;
seq = ed->seqbasep->first;
while (seq) {
if (min[0] > seq->startdisp - 1) {
min[0] = seq->startdisp - 1;
}
if (max[0] < seq->enddisp + 1) {
max[0] = seq->enddisp + 1;
}
if (max[1] < seq->machine + 2) {
max[1] = seq->machine + 2;
}
seq = seq->next;
}
rect->xmin = min[0];
rect->xmax = max[0];
rect->ymin = min[1];
rect->ymax = max[1];
}
static int mouse_frame_side(View2D *v2d, short mouse_x, int frame)
{
int mval[2];
float mouseloc[2];
mval[0] = mouse_x;
mval[1] = 0;
/* Choose the side based on which side of the current frame the mouse is on. */
UI_view2d_region_to_view(v2d, mval[0], mval[1], &mouseloc[0], &mouseloc[1]);
return mouseloc[0] > frame ? SEQ_SIDE_RIGHT : SEQ_SIDE_LEFT;
}
Sequence *find_neighboring_sequence(Scene *scene, Sequence *test, int lr, int sel)
{
/* sel: 0==unselected, 1==selected, -1==don't care. */
Sequence *seq;
Editing *ed = BKE_sequencer_editing_get(scene, false);
if (ed == NULL) {
return NULL;
}
if (sel > 0) {
sel = SELECT;
}
for (seq = ed->seqbasep->first; seq; seq = seq->next) {
if ((seq != test) && (test->machine == seq->machine) &&
((sel == -1) || (sel && (seq->flag & SELECT)) ||
(sel == 0 && (seq->flag & SELECT) == 0))) {
switch (lr) {
case SEQ_SIDE_LEFT:
if (test->startdisp == (seq->enddisp)) {
return seq;
}
break;
case SEQ_SIDE_RIGHT:
if (test->enddisp == (seq->startdisp)) {
return seq;
}
break;
}
}
}
return NULL;
}
static Sequence *find_next_prev_sequence(Scene *scene, Sequence *test, int lr, int sel)
{
/* sel: 0==unselected, 1==selected, -1==don't care. */
Sequence *seq, *best_seq = NULL;
Editing *ed = BKE_sequencer_editing_get(scene, false);
int dist, best_dist;
best_dist = MAXFRAME * 2;
if (ed == NULL) {
return NULL;
}
seq = ed->seqbasep->first;
while (seq) {
if ((seq != test) && (test->machine == seq->machine) && (test->depth == seq->depth) &&
((sel == -1) || (sel == (seq->flag & SELECT)))) {
dist = MAXFRAME * 2;
switch (lr) {
case SEQ_SIDE_LEFT:
if (seq->enddisp <= test->startdisp) {
dist = test->enddisp - seq->startdisp;
}
break;
case SEQ_SIDE_RIGHT:
if (seq->startdisp >= test->enddisp) {
dist = seq->startdisp - test->enddisp;
}
break;
}
if (dist == 0) {
best_seq = seq;
break;
}
if (dist < best_dist) {
best_dist = dist;
best_seq = seq;
}
}
seq = seq->next;
}
return best_seq; /* Can be null. */
}
Sequence *find_nearest_seq(Scene *scene, View2D *v2d, int *hand, const int mval[2])
{
Sequence *seq;
Editing *ed = BKE_sequencer_editing_get(scene, false);
float x, y;
float pixelx;
float handsize;
float displen;
*hand = SEQ_SIDE_NONE;
if (ed == NULL) {
return NULL;
}
pixelx = BLI_rctf_size_x(&v2d->cur) / BLI_rcti_size_x(&v2d->mask);
UI_view2d_region_to_view(v2d, mval[0], mval[1], &x, &y);
seq = ed->seqbasep->first;
while (seq) {
if (seq->machine == (int)y) {
/* Check for both normal strips, and strips that have been flipped horizontally. */
if (((seq->startdisp < seq->enddisp) && (seq->startdisp <= x && seq->enddisp >= x)) ||
((seq->startdisp > seq->enddisp) && (seq->startdisp >= x && seq->enddisp <= x))) {
if (BKE_sequence_tx_test(seq)) {
/* Clamp handles to defined size in pixel space. */
handsize = 2.0f * sequence_handle_size_get_clamped(seq, pixelx);
displen = (float)abs(seq->startdisp - seq->enddisp);
/* Don't even try to grab the handles of small strips. */
if (displen / pixelx > 16) {
/* Set the max value to handle to 1/3 of the total len when its
* less than 28. This is important because otherwise selecting
* handles happens even when you click in the middle. */
if ((displen / 3) < 30 * pixelx) {
handsize = displen / 3;
}
else {
CLAMP(handsize, 7 * pixelx, 30 * pixelx);
}
if (handsize + seq->startdisp >= x) {
*hand = SEQ_SIDE_LEFT;
}
else if (-handsize + seq->enddisp <= x) {
*hand = SEQ_SIDE_RIGHT;
}
}
}
return seq;
}
}
seq = seq->next;
}
return NULL;
}
static bool seq_is_parent(Sequence *par, Sequence *seq)
{
return ((par->seq1 == seq) || (par->seq2 == seq) || (par->seq3 == seq));
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name Selection Utilities
* \{ */
void ED_sequencer_deselect_all(Scene *scene)
{
Sequence *seq;
Editing *ed = BKE_sequencer_editing_get(scene, false);
if (ed == NULL) {
return;
}
SEQP_BEGIN (ed, seq) {
seq->flag &= ~SEQ_ALLSEL;
}
SEQ_END;
}
void recurs_sel_seq(Sequence *seqm)
{
Sequence *seq;
seq = seqm->seqbase.first;
while (seq) {
if (seqm->flag & (SEQ_LEFTSEL + SEQ_RIGHTSEL)) {
seq->flag &= ~SEQ_ALLSEL;
}
else if (seqm->flag & SELECT) {
seq->flag |= SELECT;
}
else {
seq->flag &= ~SEQ_ALLSEL;
}
if (seq->seqbase.first) {
recurs_sel_seq(seq);
}
seq = seq->next;
}
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name Public Context Checks
* \{ */
bool ED_space_sequencer_maskedit_mask_poll(bContext *C)
{
return ED_space_sequencer_maskedit_poll(C);
}
bool ED_space_sequencer_check_show_maskedit(SpaceSeq *sseq, Scene *scene)
{
if (sseq && sseq->mainb == SEQ_DRAW_IMG_IMBUF) {
return (BKE_sequencer_mask_get(scene) != NULL);
}
return false;
}
bool ED_space_sequencer_maskedit_poll(bContext *C)
{
SpaceSeq *sseq = CTX_wm_space_seq(C);
if (sseq) {
Scene *scene = CTX_data_scene(C);
return ED_space_sequencer_check_show_maskedit(sseq, scene);
}
return false;
}
/* Are we displaying the seq output (not channels or histogram). */
bool ED_space_sequencer_check_show_imbuf(SpaceSeq *sseq)
{
return (ELEM(sseq->view, SEQ_VIEW_PREVIEW, SEQ_VIEW_SEQUENCE_PREVIEW) &&
ELEM(sseq->mainb, SEQ_DRAW_SEQUENCE, SEQ_DRAW_IMG_IMBUF));
}
bool ED_space_sequencer_check_show_strip(SpaceSeq *sseq)
{
return (ELEM(sseq->view, SEQ_VIEW_SEQUENCE, SEQ_VIEW_SEQUENCE_PREVIEW) &&
ELEM(sseq->mainb, SEQ_DRAW_SEQUENCE, SEQ_DRAW_IMG_IMBUF));
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name Find Selected Strips as Inputs to an Effects Strip
* \{ */
int seq_effect_find_selected(Scene *scene,
Sequence *activeseq,
int type,
Sequence **r_selseq1,
Sequence **r_selseq2,
Sequence **r_selseq3,
const char **r_error_str)
{
Editing *ed = BKE_sequencer_editing_get(scene, false);
Sequence *seq1 = NULL, *seq2 = NULL, *seq3 = NULL, *seq;
*r_error_str = NULL;
if (!activeseq) {
seq2 = BKE_sequencer_active_get(scene);
}
for (seq = ed->seqbasep->first; seq; seq = seq->next) {
if (seq->flag & SELECT) {
if (seq->type == SEQ_TYPE_SOUND_RAM && BKE_sequence_effect_get_num_inputs(type) != 0) {
*r_error_str = N_("Cannot apply effects to audio sequence strips");
return 0;
}
if ((seq != activeseq) && (seq != seq2)) {
if (seq2 == NULL) {
seq2 = seq;
}
else if (seq1 == NULL) {
seq1 = seq;
}
else if (seq3 == NULL) {
seq3 = seq;
}
else {
*r_error_str = N_("Cannot apply effect to more than 3 sequence strips");
return 0;
}
}
}
}
/* Make sequence selection a little bit more intuitive
* for 3 strips: the last-strip should be seq3. */
if (seq3 != NULL && seq2 != NULL) {
Sequence *tmp = seq2;
seq2 = seq3;
seq3 = tmp;
}
switch (BKE_sequence_effect_get_num_inputs(type)) {
case 0:
*r_selseq1 = *r_selseq2 = *r_selseq3 = NULL;
return 1; /* Success. */
case 1:
if (seq2 == NULL) {
*r_error_str = N_("At least one selected sequence strip is needed");
return 0;
}
if (seq1 == NULL) {
seq1 = seq2;
}
if (seq3 == NULL) {
seq3 = seq2;
}
ATTR_FALLTHROUGH;
case 2:
if (seq1 == NULL || seq2 == NULL) {
*r_error_str = N_("2 selected sequence strips are needed");
return 0;
}
if (seq3 == NULL) {
seq3 = seq2;
}
break;
}
if (seq1 == NULL && seq2 == NULL && seq3 == NULL) {
*r_error_str = N_("TODO: in what cases does this happen?");
return 0;
}
*r_selseq1 = seq1;
*r_selseq2 = seq2;
*r_selseq3 = seq3;
/* TODO(Richard): This function needs some refactoring, this is just quick hack for T73828. */
if (BKE_sequence_effect_get_num_inputs(type) < 3) {
*r_selseq3 = NULL;
}
if (BKE_sequence_effect_get_num_inputs(type) < 2) {
*r_selseq2 = NULL;
}
return 1;
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name Delete Utilities
* \{ */
static Sequence *del_seq_find_replace_recurs(Scene *scene, Sequence *seq)
{
Sequence *seq1, *seq2, *seq3;
/* Try to find a replacement input sequence, and flag for later deletion if
* no replacement can be found. */
if (!seq) {
return NULL;
}
if (!(seq->type & SEQ_TYPE_EFFECT)) {
return ((seq->flag & SELECT) ? NULL : seq);
}
if (!(seq->flag & SELECT)) {
/* Try to find replacement for effect inputs. */
seq1 = del_seq_find_replace_recurs(scene, seq->seq1);
seq2 = del_seq_find_replace_recurs(scene, seq->seq2);
seq3 = del_seq_find_replace_recurs(scene, seq->seq3);
if (seq1 == seq->seq1 && seq2 == seq->seq2 && seq3 == seq->seq3) {
/* Pass. */
}
else if (seq1 || seq2 || seq3) {
seq->seq1 = (seq1) ? seq1 : (seq2) ? seq2 : seq3;
seq->seq2 = (seq2) ? seq2 : (seq1) ? seq1 : seq3;
seq->seq3 = (seq3) ? seq3 : (seq1) ? seq1 : seq2;
BKE_sequencer_update_changed_seq_and_deps(scene, seq, 1, 1);
}
else {
seq->flag |= SELECT; /* Mark for delete. */
}
}
if (seq->flag & SELECT) {
if ((seq1 = del_seq_find_replace_recurs(scene, seq->seq1))) {
return seq1;
}
if ((seq2 = del_seq_find_replace_recurs(scene, seq->seq2))) {
return seq2;
}
if ((seq3 = del_seq_find_replace_recurs(scene, seq->seq3))) {
return seq3;
}
return NULL;
}
return seq;
}
static void del_seq_clear_modifiers_recurs(Scene *scene, Sequence *deleting_sequence)
{
Editing *ed = BKE_sequencer_editing_get(scene, false);
Sequence *current_sequence;
SEQP_BEGIN (ed, current_sequence) {
if (!(current_sequence->flag & SELECT) && current_sequence != deleting_sequence) {
SequenceModifierData *smd;
for (smd = current_sequence->modifiers.first; smd; smd = smd->next) {
if (smd->mask_sequence == deleting_sequence) {
smd->mask_sequence = NULL;
}
}
}
}
SEQ_END;
}
static void recurs_del_seq_flag(Scene *scene, ListBase *lb, short flag, short deleteall)
{
Sequence *seq, *seqn;
Sequence *last_seq = BKE_sequencer_active_get(scene);
seq = lb->first;
while (seq) {
seqn = seq->next;
if ((seq->flag & flag) || deleteall) {
BLI_remlink(lb, seq);
if (seq == last_seq) {
BKE_sequencer_active_set(scene, NULL);
}
if (seq->type == SEQ_TYPE_META) {
recurs_del_seq_flag(scene, &seq->seqbase, flag, 1);
}
BKE_sequence_free(scene, seq, true);
}
seq = seqn;
}
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name Split (Hard) Utility
* \{ */
static Sequence *split_seq_hard(
Main *bmain, Scene *scene, Sequence *seq, ListBase *new_seq_list, int split_frame)
{
TransSeq ts;
Sequence *seqn = NULL;
bool skip_dup = false;
/* Unlike soft-split, it's important to use the same value for both strips. */
const bool is_end_exact = ((seq->start + seq->len) == split_frame);
/* Backup values. */
ts.start = seq->start;
ts.machine = seq->machine;
ts.startstill = seq->startstill;
ts.endstill = seq->endstill;
ts.startdisp = seq->startdisp;
ts.enddisp = seq->enddisp;
ts.startofs = seq->startofs;
ts.endofs = seq->endofs;
ts.anim_startofs = seq->anim_startofs;
ts.anim_endofs = seq->anim_endofs;
ts.len = seq->len;
if (seq->type != SEQ_TYPE_META) {
/* Precaution, needed because the length saved on-disk may not match the length saved in the
* blend file, or our code may have minor differences reading file length between versions.
* This causes hard-split to fail, see: T47862. */
BKE_sequence_reload_new_file(bmain, scene, seq, true);
BKE_sequence_calc(scene, seq);
}
/* First Strip. */
/* Important to offset the start when 'split_frame == seq->start'
* because we need at least one frame of content after start/end still have clipped it. */
if ((seq->startstill) && (split_frame <= seq->start)) {
/* Don't do funny things with METAs. */
if (seq->type == SEQ_TYPE_META) {
skip_dup = true;
seq->startstill = seq->start - split_frame;
}
else {
seq->start = split_frame - 1;
seq->startstill = split_frame - seq->startdisp - 1;
seq->anim_endofs += seq->len - 1;
seq->endstill = 0;
}
}
/* Normal strip. */
else if ((is_end_exact == false) &&
((split_frame >= seq->start) && (split_frame <= (seq->start + seq->len)))) {
seq->endofs = 0;
seq->endstill = 0;
seq->anim_endofs += (seq->start + seq->len) - split_frame;
}
/* Strips with extended stillframes. */
else if ((is_end_exact == true) ||
(((seq->start + seq->len) < split_frame) && (seq->endstill))) {
seq->endstill -= seq->enddisp - split_frame;
/* Don't do funny things with METAs. */
if (seq->type == SEQ_TYPE_META) {
skip_dup = true;
}
}
BKE_sequence_reload_new_file(bmain, scene, seq, false);
BKE_sequence_calc(scene, seq);
if (!skip_dup) {
/* Duplicate AFTER the first change. */
seqn = BKE_sequence_dupli_recursive(
scene, scene, new_seq_list, seq, SEQ_DUPE_UNIQUE_NAME | SEQ_DUPE_ANIM);
}
if (seqn) {
seqn->flag |= SELECT;
#if 0
is_end_exact = ((seqn->start + seqn->len) == split_frame);
#endif
/* Second Strip. */
/* strips with extended stillframes. */
if ((seqn->startstill) && (split_frame == seqn->start + 1)) {
seqn->start = ts.start;
seqn->startstill = ts.start - split_frame;
seqn->anim_endofs = ts.anim_endofs;
seqn->endstill = ts.endstill;
}
/* Normal strip. */
else if ((is_end_exact == false) &&
((split_frame >= seqn->start) && (split_frame <= (seqn->start + seqn->len)))) {
seqn->start = split_frame;
seqn->startstill = 0;
seqn->startofs = 0;
seqn->endofs = ts.endofs;
seqn->anim_startofs += split_frame - ts.start;
seqn->anim_endofs = ts.anim_endofs;
seqn->endstill = ts.endstill;
}
/* Strips with extended stillframes after. */
else if ((is_end_exact == true) ||
(((seqn->start + seqn->len) < split_frame) && (seqn->endstill))) {
seqn->start = split_frame;
seqn->startofs = 0;
seqn->anim_startofs += ts.len - 1;
seqn->endstill = ts.enddisp - split_frame - 1;
seqn->startstill = 0;
}
BKE_sequence_reload_new_file(bmain, scene, seqn, false);
BKE_sequence_calc(scene, seqn);
BKE_sequence_invalidate_cache_in_range(scene, seq, seqn, SEQ_CACHE_ALL_TYPES);
}
return seqn;
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name Split (Soft) Utility
* \{ */
static Sequence *split_seq_soft(
Main *UNUSED(bmain), Scene *scene, Sequence *seq, ListBase *new_seq_list, int split_frame)
{
TransSeq ts;
Sequence *seqn = NULL;
bool skip_dup = false;
bool is_end_exact = ((seq->start + seq->len) == split_frame);
/* Backup values. */
ts.start = seq->start;
ts.machine = seq->machine;
ts.startstill = seq->startstill;
ts.endstill = seq->endstill;
ts.startdisp = seq->startdisp;
ts.enddisp = seq->enddisp;
ts.startofs = seq->startofs;
ts.endofs = seq->endofs;
ts.anim_startofs = seq->anim_startofs;
ts.anim_endofs = seq->anim_endofs;
ts.len = seq->len;
/* First Strip. */
/* Strips with extended stillfames. */
/* Important to offset the start when 'split_frame == seq->start'
* because we need at least one frame of content after start/end still have clipped it. */
if ((seq->startstill) && (split_frame <= seq->start)) {
/* don't do funny things with METAs ... */
if (seq->type == SEQ_TYPE_META) {
skip_dup = true;
seq->startstill = seq->start - split_frame;
}
else {
seq->start = split_frame - 1;
seq->startstill = split_frame - seq->startdisp - 1;
seq->endofs = seq->len - 1;
seq->endstill = 0;
}
}
/* Normal strip. */
else if ((is_end_exact == false) && (split_frame >= seq->start) &&
(split_frame <= (seq->start + seq->len))) {
seq->endofs = (seq->start + seq->len) - split_frame;
}
/* Strips with extended stillframes. */
else if ((is_end_exact == true) ||
(((seq->start + seq->len) < split_frame) && (seq->endstill))) {
seq->endstill -= seq->enddisp - split_frame;
/* Don't do funny things with METAs. */
if (seq->type == SEQ_TYPE_META) {
skip_dup = true;
}
}
BKE_sequence_calc(scene, seq);
if (!skip_dup) {
/* Duplicate AFTER the first change. */
seqn = BKE_sequence_dupli_recursive(
scene, scene, new_seq_list, seq, SEQ_DUPE_UNIQUE_NAME | SEQ_DUPE_ANIM);
}
if (seqn) {
seqn->flag |= SELECT;
is_end_exact = ((seqn->start + seqn->len) == split_frame);
/* Second Strip. */
/* Strips with extended stillframes. */
if ((seqn->startstill) && (split_frame == seqn->start + 1)) {
seqn->start = ts.start;
seqn->startstill = ts.start - split_frame;
seqn->endofs = ts.endofs;
seqn->endstill = ts.endstill;
}
/* Normal strip. */
else if ((is_end_exact == false) && (split_frame >= seqn->start) &&
(split_frame <= (seqn->start + seqn->len))) {
seqn->startstill = 0;
seqn->startofs = split_frame - ts.start;
seqn->endofs = ts.endofs;
seqn->endstill = ts.endstill;
}
/* Strips with extended stillframes. */
else if ((is_end_exact == true) ||
(((seqn->start + seqn->len) < split_frame) && (seqn->endstill))) {
seqn->start = split_frame - ts.len + 1;
seqn->startofs = ts.len - 1;
seqn->endstill = ts.enddisp - split_frame - 1;
seqn->startstill = 0;
}
BKE_sequence_calc(scene, seqn);
BKE_sequence_invalidate_cache_in_range(scene, seq, seqn, SEQ_CACHE_ALL_TYPES);
}
return seqn;
}
/* Like duplicate, but only duplicate and split overlapping strips,
* strips to the left of the split_frame are ignored and strips to the right
* are moved to the end of slist.
* We have to work on the same slist (not using a separate list), since
* otherwise dupli_seq can't check for duplicate names properly and
* may generate strips with the same name which will mess up animdata.
*/
static bool split_seq_list(
Main *bmain,
Scene *scene,
ListBase *slist,
int split_frame,
int channel,
bool use_cursor_position,
Sequence *(*split_seq)(Main *bmain, Scene *, Sequence *, ListBase *, int))
{
Sequence *seq, *seq_next_iter;
Sequence *seq_first_new = NULL;
seq = slist->first;
while (seq && seq != seq_first_new) {
seq_next_iter = seq->next; /* We need this because we may remove seq. */
seq->tmp = NULL;
if (use_cursor_position) {
if (seq->machine == channel && seq->startdisp < split_frame && seq->enddisp > split_frame) {
Sequence *seqn = split_seq(bmain, scene, seq, slist, split_frame);
if (seqn) {
if (seq_first_new == NULL) {
seq_first_new = seqn;
}
}
}
}
else {
if (seq->flag & SELECT) {
if (split_frame > seq->startdisp && split_frame < seq->enddisp) {
Sequence *seqn = split_seq(bmain, scene, seq, slist, split_frame);
if (seqn) {
if (seq_first_new == NULL) {
seq_first_new = seqn;
}
}
}
else if (seq->enddisp <= split_frame) {
/* Pass. */
}
else if (seq->startdisp >= split_frame) {
/* Move to tail. */
BLI_remlink(slist, seq);
BLI_addtail(slist, seq);
if (seq_first_new == NULL) {
seq_first_new = seq;
}
}
}
}
seq = seq_next_iter;
}
return (seq_first_new != NULL);
}
static bool sequence_offset_after_frame(Scene *scene, const int delta, const int cfra)
{
Sequence *seq;
Editing *ed = BKE_sequencer_editing_get(scene, false);
bool done = false;
TimeMarker *marker;
/* All strips >= cfra are shifted. */
if (ed == NULL) {
return 0;
}
for (seq = ed->seqbasep->first; seq; seq = seq->next) {
if (seq->startdisp >= cfra) {
BKE_sequence_translate(scene, seq, delta);
BKE_sequence_calc(scene, seq);
BKE_sequence_invalidate_cache_preprocessed(scene, seq);
done = true;
}
}
if (!scene->toolsettings->lock_markers) {
for (marker = scene->markers.first; marker; marker = marker->next) {
if (marker->frame >= cfra) {
marker->frame += delta;
}
}
}
return done;
}
#if 0
static void set_filter_seq(Scene *scene)
{
Sequence *seq;
Editing *ed = BKE_sequencer_editing_get(scene, false);
if (ed == NULL) {
return;
}
if (okee("Set Deinterlace") == 0) {
return;
}
SEQP_BEGIN (ed, seq) {
if (seq->flag & SELECT) {
if (seq->type == SEQ_TYPE_MOVIE) {
seq->flag |= SEQ_FILTERY;
BKE_sequence_reload_new_file(bmain, scene, seq, false);
BKE_sequence_calc(scene, seq);
}
}
}
SEQ_END;
}
#endif
static void UNUSED_FUNCTION(seq_remap_paths)(Scene *scene)
{
Sequence *seq, *last_seq = BKE_sequencer_active_get(scene);
Editing *ed = BKE_sequencer_editing_get(scene, false);
char from[FILE_MAX], to[FILE_MAX], stripped[FILE_MAX];
if (last_seq == NULL) {
return;
}
BLI_strncpy(from, last_seq->strip->dir, sizeof(from));
/* XXX if (0 == sbutton(from, 0, sizeof(from) - 1, "From: "))
* return; */
BLI_strncpy(to, from, sizeof(to));
/* XXX if (0 == sbutton(to, 0, sizeof(to) - 1, "To: "))
* return; */
if (STREQ(to, from)) {
return;
}
SEQP_BEGIN (ed, seq) {
if (seq->flag & SELECT) {
if (STREQLEN(seq->strip->dir, from, strlen(from))) {
printf("found %s\n", seq->strip->dir);
/* Strip off the beginning. */
stripped[0] = 0;
BLI_strncpy(stripped, seq->strip->dir + strlen(from), FILE_MAX);
/* New path. */
BLI_snprintf(seq->strip->dir, sizeof(seq->strip->dir), "%s%s", to, stripped);
printf("new %s\n", seq->strip->dir);
}
}
}
SEQ_END;
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name Remove Gaps Operator
* \{ */
static int sequencer_gap_remove_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
rctf rectf;
int cfra, efra, sfra;
bool first = false, done;
bool do_all = RNA_boolean_get(op->ptr, "all");
/* Get first and last frame. */
boundbox_seq(scene, &rectf);
sfra = (int)rectf.xmin;
efra = (int)rectf.xmax;
/* Check if the current frame has a gap already. */
for (cfra = CFRA; cfra >= sfra; cfra--) {
if (BKE_sequencer_evaluate_frame(scene, cfra)) {
first = true;
break;
}
}
for (; cfra < efra; cfra++) {
/* There's still no strip to remove a gap for. */
if (first == false) {
if (BKE_sequencer_evaluate_frame(scene, cfra)) {
first = true;
}
}
else if (BKE_sequencer_evaluate_frame(scene, cfra) == 0) {
done = true;
while (BKE_sequencer_evaluate_frame(scene, cfra) == 0) {
done = sequence_offset_after_frame(scene, -1, cfra);
if (done == false) {
break;
}
}
if (done == false || do_all == false) {
break;
}
}
}
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS);
return OPERATOR_FINISHED;
}
void SEQUENCER_OT_gap_remove(struct wmOperatorType *ot)
{
/* Identifiers. */
ot->name = "Remove Gaps";
ot->idname = "SEQUENCER_OT_gap_remove";
ot->description =
"Remove gap at current frame to first strip at the right, independent of selection or "
"locked state of strips";
/* Api callbacks. */
// ot->invoke = sequencer_snap_invoke;
ot->exec = sequencer_gap_remove_exec;
ot->poll = sequencer_edit_poll;
/* Flags. */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_boolean(ot->srna, "all", 0, "All Gaps", "Do all gaps to right of current frame");
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name Insert Gaps Operator
* \{ */
static int sequencer_gap_insert_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
int frames = RNA_int_get(op->ptr, "frames");
sequence_offset_after_frame(scene, frames, CFRA);
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
return OPERATOR_FINISHED;
}
void SEQUENCER_OT_gap_insert(struct wmOperatorType *ot)
{
/* Identifiers. */
ot->name = "Insert Gaps";
ot->idname = "SEQUENCER_OT_gap_insert";
ot->description =
"Insert gap at current frame to first strips at the right, independent of selection or "
"locked state of strips";
/* Api callbacks. */
// ot->invoke = sequencer_snap_invoke;
ot->exec = sequencer_gap_insert_exec;
ot->poll = sequencer_edit_poll;
/* Flags. */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_int(ot->srna,
"frames",
10,
0,
INT_MAX,
"Frames",
"Frames to insert after current strip",
0,
1000);
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name Shared Poll Functions
* \{ */
#if 0
static int seq_get_snaplimit(View2D *v2d)
{
/* fake mouse coords to get the snap value
* a bit lazy but its only done once pre transform */
float xmouse, ymouse, x;
int mval[2] = {24, 0}; /* 24 screen px snap */
UI_view2d_region_to_view(v2d, mval[0], mval[1], &xmouse, &ymouse);
x = xmouse;
mval[0] = 0;
UI_view2d_region_to_view(v2d, mval[0], mval[1], &xmouse, &ymouse);
return (int)(x - xmouse);
}
#endif
/* Operator functions. */
bool sequencer_edit_poll(bContext *C)
{
return (BKE_sequencer_editing_get(CTX_data_scene(C), false) != NULL);
}
#if 0 /* UNUSED */
bool sequencer_strip_poll(bContext *C)
{
Editing *ed;
return (((ed = BKE_sequencer_editing_get(CTX_data_scene(C), false)) != NULL) &&
(ed->act_seq != NULL));
}
#endif
bool sequencer_strip_has_path_poll(bContext *C)
{
Editing *ed;
Sequence *seq;
return (((ed = BKE_sequencer_editing_get(CTX_data_scene(C), false)) != NULL) &&
((seq = ed->act_seq) != NULL) && (SEQ_HAS_PATH(seq)));
}
bool sequencer_view_preview_poll(bContext *C)
{
SpaceSeq *sseq = CTX_wm_space_seq(C);
Editing *ed = BKE_sequencer_editing_get(CTX_data_scene(C), false);
if (ed && sseq && (sseq->mainb == SEQ_DRAW_IMG_IMBUF)) {
return 1;
}
return 0;
}
bool sequencer_view_strips_poll(bContext *C)
{
SpaceSeq *sseq = CTX_wm_space_seq(C);
if (sseq && ED_space_sequencer_check_show_strip(sseq)) {
return 1;
}
return 0;
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name Snap Strips to the Current Frame Operator
* \{ */
static int sequencer_snap_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
Editing *ed = BKE_sequencer_editing_get(scene, false);
Sequence *seq;
int snap_frame;
snap_frame = RNA_int_get(op->ptr, "frame");
/* Check metas. */
for (seq = ed->seqbasep->first; seq; seq = seq->next) {
if (seq->flag & SELECT && !(seq->depth == 0 && seq->flag & SEQ_LOCK) &&
BKE_sequence_tx_test(seq)) {
if ((seq->flag & (SEQ_LEFTSEL + SEQ_RIGHTSEL)) == 0) {
BKE_sequence_translate(
scene, seq, (snap_frame - seq->startofs + seq->startstill) - seq->start);
}
else {
if (seq->flag & SEQ_LEFTSEL) {
BKE_sequence_tx_set_final_left(seq, snap_frame);
}
else { /* SEQ_RIGHTSEL */
BKE_sequence_tx_set_final_right(seq, snap_frame);
}
BKE_sequence_tx_handle_xlimits(seq, seq->flag & SEQ_LEFTSEL, seq->flag & SEQ_RIGHTSEL);
BKE_sequence_single_fix(seq);
}
BKE_sequence_calc(scene, seq);
}
}
/* Test for effects and overlap.
* Don't use SEQP_BEGIN since that would be recursive. */
for (seq = ed->seqbasep->first; seq; seq = seq->next) {
if (seq->flag & SELECT && !(seq->depth == 0 && seq->flag & SEQ_LOCK)) {
seq->flag &= ~SEQ_OVERLAP;
if (BKE_sequence_test_overlap(ed->seqbasep, seq)) {
BKE_sequence_base_shuffle(ed->seqbasep, seq, scene);
}
}
}
/* Recalculate bounds of effect strips. */
for (seq = ed->seqbasep->first; seq; seq = seq->next) {
if (seq->type & SEQ_TYPE_EFFECT) {
if (seq->seq1 && (seq->seq1->flag & SELECT)) {
BKE_sequencer_offset_animdata(scene, seq, (snap_frame - seq->startdisp));
BKE_sequence_calc(scene, seq);
}
else if (seq->seq2 && (seq->seq2->flag & SELECT)) {
BKE_sequencer_offset_animdata(scene, seq, (snap_frame - seq->startdisp));
BKE_sequence_calc(scene, seq);
}
else if (seq->seq3 && (seq->seq3->flag & SELECT)) {
BKE_sequencer_offset_animdata(scene, seq, (snap_frame - seq->startdisp));
BKE_sequence_calc(scene, seq);
}
}
}
BKE_sequencer_sort(scene);
DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS);
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
return OPERATOR_FINISHED;
}
static int sequencer_snap_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
Scene *scene = CTX_data_scene(C);
int snap_frame;
snap_frame = CFRA;
RNA_int_set(op->ptr, "frame", snap_frame);
return sequencer_snap_exec(C, op);
}
void SEQUENCER_OT_snap(struct wmOperatorType *ot)
{
/* Identifiers. */
ot->name = "Snap Strips to the Current Frame";
ot->idname = "SEQUENCER_OT_snap";
ot->description = "Frame where selected strips will be snapped";
/* Api callbacks. */
ot->invoke = sequencer_snap_invoke;
ot->exec = sequencer_snap_exec;
ot->poll = sequencer_edit_poll;
/* Flags. */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_int(ot->srna,
"frame",
0,
INT_MIN,
INT_MAX,
"Frame",
"Frame where selected strips will be snapped",
INT_MIN,
INT_MAX);
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name Trim Strips Operator
* \{ */
typedef struct SlipData {
int init_mouse[2];
float init_mouseloc[2];
TransSeq *ts;
Sequence **seq_array;
bool *trim;
int num_seq;
bool slow;
int slow_offset; /* Offset at the point where offset was turned on. */
NumInput num_input;
} SlipData;
static void transseq_backup(TransSeq *ts, Sequence *seq)
{
ts->start = seq->start;
ts->machine = seq->machine;
ts->startstill = seq->startstill;
ts->endstill = seq->endstill;
ts->startdisp = seq->startdisp;
ts->enddisp = seq->enddisp;
ts->startofs = seq->startofs;
ts->endofs = seq->endofs;
ts->anim_startofs = seq->anim_startofs;
ts->anim_endofs = seq->anim_endofs;
ts->len = seq->len;
}
static void transseq_restore(TransSeq *ts, Sequence *seq)
{
seq->start = ts->start;
seq->machine = ts->machine;
seq->startstill = ts->startstill;
seq->endstill = ts->endstill;
seq->startdisp = ts->startdisp;
seq->enddisp = ts->enddisp;
seq->startofs = ts->startofs;
seq->endofs = ts->endofs;
seq->anim_startofs = ts->anim_startofs;
seq->anim_endofs = ts->anim_endofs;
seq->len = ts->len;
}
static int slip_add_sequences_recursive(
ListBase *seqbasep, Sequence **seq_array, bool *trim, int offset, bool do_trim)
{
Sequence *seq;
int num_items = 0;
for (seq = seqbasep->first; seq; seq = seq->next) {
if (!do_trim || (!(seq->type & SEQ_TYPE_EFFECT) && (seq->flag & SELECT))) {
seq_array[offset + num_items] = seq;
trim[offset + num_items] = do_trim;
num_items++;
if (seq->type == SEQ_TYPE_META) {
/* Trim the sub-sequences. */
num_items += slip_add_sequences_recursive(
&seq->seqbase, seq_array, trim, num_items + offset, false);
}
else if (seq->type & SEQ_TYPE_EFFECT) {
trim[offset + num_items] = false;
}
}
}
return num_items;
}
static int slip_count_sequences_recursive(ListBase *seqbasep, bool first_level)
{
Sequence *seq;
int trimmed_sequences = 0;
for (seq = seqbasep->first; seq; seq = seq->next) {
if (!first_level || (!(seq->type & SEQ_TYPE_EFFECT) && (seq->flag & SELECT))) {
trimmed_sequences++;
if (seq->type == SEQ_TYPE_META) {
/* Trim the sub-sequences. */
trimmed_sequences += slip_count_sequences_recursive(&seq->seqbase, false);
}
}
}
return trimmed_sequences;
}
static int sequencer_slip_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
SlipData *data;
Scene *scene = CTX_data_scene(C);
Editing *ed = BKE_sequencer_editing_get(scene, false);
float mouseloc[2];
int num_seq, i;
View2D *v2d = UI_view2d_fromcontext(C);
/* Recursively count the trimmed elements. */
num_seq = slip_count_sequences_recursive(ed->seqbasep, true);
if (num_seq == 0) {
return OPERATOR_CANCELLED;
}
data = op->customdata = MEM_mallocN(sizeof(SlipData), "trimdata");
data->ts = MEM_mallocN(num_seq * sizeof(TransSeq), "trimdata_transform");
data->seq_array = MEM_mallocN(num_seq * sizeof(Sequence *), "trimdata_sequences");
data->trim = MEM_mallocN(num_seq * sizeof(bool), "trimdata_trim");
data->num_seq = num_seq;
initNumInput(&data->num_input);
data->num_input.idx_max = 0;
data->num_input.val_flag[0] |= NUM_NO_FRACTION;
data->num_input.unit_sys = USER_UNIT_NONE;
data->num_input.unit_type[0] = 0;
slip_add_sequences_recursive(ed->seqbasep, data->seq_array, data->trim, 0, true);
for (i = 0; i < num_seq; i++) {
transseq_backup(data->ts + i, data->seq_array[i]);
}
UI_view2d_region_to_view(v2d, event->mval[0], event->mval[1], &mouseloc[0], &mouseloc[1]);
copy_v2_v2_int(data->init_mouse, event->mval);
copy_v2_v2(data->init_mouseloc, mouseloc);
data->slow = false;
WM_event_add_modal_handler(C, op);
/* Notify so we draw extensions immediately. */
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
return OPERATOR_RUNNING_MODAL;
}
static bool sequencer_slip_recursively(Scene *scene, SlipData *data, int offset)
{
/* Only data types supported for now. */
Editing *ed = BKE_sequencer_editing_get(scene, false);
bool changed = false;
/* Iterate in reverse so meta-strips are iterated after their children. */
for (int i = data->num_seq - 1; i >= 0; i--) {
Sequence *seq = data->seq_array[i];
int endframe;
/* Offset seq start. */
seq->start = data->ts[i].start + offset;
if (data->trim[i]) {
/* Find the end-frame. */
endframe = seq->start + seq->len;
/* Compute the sequence offsets. */
if (endframe > seq->enddisp) {
seq->endstill = 0;
seq->endofs = endframe - seq->enddisp;
changed = true;
}
else if (endframe <= seq->enddisp) {
seq->endstill = seq->enddisp - endframe;
seq->endofs = 0;
changed = true;
}
if (seq->start > seq->startdisp) {
seq->startstill = seq->start - seq->startdisp;
seq->startofs = 0;
changed = true;
}
else if (seq->start <= seq->startdisp) {
seq->startstill = 0;
seq->startofs = seq->startdisp - seq->start;
changed = true;
}
}
else {
/* No transform data (likely effect strip). Only move start and end. */
seq->startdisp = data->ts[i].startdisp + offset;
seq->enddisp = data->ts[i].enddisp + offset;
changed = true;
}
/* Effects are only added if we they are in a meta-strip.
* In this case, dependent strips will just be transformed and
* we can skip calculating for effects.
* This way we can avoid an extra loop just for effects. */
if (!(seq->type & SEQ_TYPE_EFFECT)) {
BKE_sequence_calc(scene, seq);
}
}
if (changed) {
BKE_sequencer_free_imbuf(scene, &ed->seqbase, false);
}
return changed;
}
/* Make sure, that each strip contains at least 1 frame of content. */
static void sequencer_slip_apply_limits(SlipData *data, int *offset)
{
for (int i = 0; i < data->num_seq; i++) {
if (data->trim[i]) {
Sequence *seq = data->seq_array[i];
int seq_content_start = data->ts[i].start + *offset;
int seq_content_end = seq_content_start + seq->len + seq->anim_startofs + seq->anim_endofs;
int diff = 0;
if (seq_content_start >= seq->enddisp) {
diff = seq->enddisp - seq_content_start - 1;
}
if (seq_content_end <= seq->startdisp) {
diff = seq->startdisp - seq_content_end + 1;
}
*offset += diff;
}
}
}
static int sequencer_slip_exec(bContext *C, wmOperator *op)
{
SlipData *data;
Scene *scene = CTX_data_scene(C);
Editing *ed = BKE_sequencer_editing_get(scene, false);
int num_seq, i;
int offset = RNA_int_get(op->ptr, "offset");
bool success = false;
/* Recursively count the trimmed elements. */
num_seq = slip_count_sequences_recursive(ed->seqbasep, true);
if (num_seq == 0) {
return OPERATOR_CANCELLED;
}
data = op->customdata = MEM_mallocN(sizeof(SlipData), "trimdata");
data->ts = MEM_mallocN(num_seq * sizeof(TransSeq), "trimdata_transform");
data->seq_array = MEM_mallocN(num_seq * sizeof(Sequence *), "trimdata_sequences");
data->trim = MEM_mallocN(num_seq * sizeof(bool), "trimdata_trim");
data->num_seq = num_seq;
slip_add_sequences_recursive(ed->seqbasep, data->seq_array, data->trim, 0, true);
for (i = 0; i < num_seq; i++) {
transseq_backup(data->ts + i, data->seq_array[i]);
}
sequencer_slip_apply_limits(data, &offset);
success = sequencer_slip_recursively(scene, data, offset);
MEM_freeN(data->seq_array);
MEM_freeN(data->trim);
MEM_freeN(data->ts);
MEM_freeN(data);
if (success) {
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS);
return OPERATOR_FINISHED;
}
return OPERATOR_CANCELLED;
}
static void sequencer_slip_update_header(Scene *scene, ScrArea *area, SlipData *data, int offset)
{
char msg[UI_MAX_DRAW_STR];
if (area) {
if (hasNumInput(&data->num_input)) {
char num_str[NUM_STR_REP_LEN];
outputNumInput(&data->num_input, num_str, &scene->unit);
BLI_snprintf(msg, sizeof(msg), TIP_("Slip offset: %s"), num_str);
}
else {
BLI_snprintf(msg, sizeof(msg), TIP_("Slip offset: %d"), offset);
}
}
ED_area_status_text(area, msg);
}
static int sequencer_slip_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
SlipData *data = (SlipData *)op->customdata;
ScrArea *area = CTX_wm_area(C);
const bool has_numInput = hasNumInput(&data->num_input);
bool handled = true;
/* Modal numinput active, try to handle numeric inputs. */
if (event->val == KM_PRESS && has_numInput && handleNumInput(C, &data->num_input, event)) {
float offset_fl;
applyNumInput(&data->num_input, &offset_fl);
int offset = round_fl_to_int(offset_fl);
sequencer_slip_apply_limits(data, &offset);
sequencer_slip_update_header(scene, area, data, offset);
RNA_int_set(op->ptr, "offset", offset);
if (sequencer_slip_recursively(scene, data, offset)) {
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
}
return OPERATOR_RUNNING_MODAL;
}
switch (event->type) {
case MOUSEMOVE: {
if (!has_numInput) {
float mouseloc[2];
int offset;
int mouse_x;
View2D *v2d = UI_view2d_fromcontext(C);
if (data->slow) {
mouse_x = event->mval[0] - data->slow_offset;
mouse_x *= 0.1f;
mouse_x += data->slow_offset;
}
else {
mouse_x = event->mval[0];
}
/* Choose the side based on which side of the current frame the mouse is. */
UI_view2d_region_to_view(v2d, mouse_x, 0, &mouseloc[0], &mouseloc[1]);
offset = mouseloc[0] - data->init_mouseloc[0];
sequencer_slip_apply_limits(data, &offset);
sequencer_slip_update_header(scene, area, data, offset);
RNA_int_set(op->ptr, "offset", offset);
if (sequencer_slip_recursively(scene, data, offset)) {
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
}
}
break;
}
case LEFTMOUSE:
case EVT_RETKEY:
case EVT_SPACEKEY: {
MEM_freeN(data->seq_array);
MEM_freeN(data->trim);
MEM_freeN(data->ts);
MEM_freeN(data);
op->customdata = NULL;
if (area) {
ED_area_status_text(area, NULL);
}
DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS);
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
return OPERATOR_FINISHED;
}
case EVT_ESCKEY:
case RIGHTMOUSE: {
int i;
Editing *ed = BKE_sequencer_editing_get(scene, false);
for (i = 0; i < data->num_seq; i++) {
transseq_restore(data->ts + i, data->seq_array[i]);
}
for (i = 0; i < data->num_seq; i++) {
Sequence *seq = data->seq_array[i];
BKE_sequence_reload_new_file(bmain, scene, seq, false);
BKE_sequence_calc(scene, seq);
}
MEM_freeN(data->seq_array);
MEM_freeN(data->ts);
MEM_freeN(data->trim);
MEM_freeN(data);
op->customdata = NULL;
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
BKE_sequencer_free_imbuf(scene, &ed->seqbase, false);
if (area) {
ED_area_status_text(area, NULL);
}
return OPERATOR_CANCELLED;
}
case EVT_RIGHTSHIFTKEY:
case EVT_LEFTSHIFTKEY:
if (!has_numInput) {
if (event->val == KM_PRESS) {
data->slow = true;
data->slow_offset = event->mval[0];
}
else if (event->val == KM_RELEASE) {
data->slow = false;
}
}
break;
default:
handled = false;
break;
}
/* Modal numinput inactive, try to handle numeric inputs. */
if (!handled && event->val == KM_PRESS && handleNumInput(C, &data->num_input, event)) {
float offset_fl;
applyNumInput(&data->num_input, &offset_fl);
int offset = round_fl_to_int(offset_fl);
sequencer_slip_apply_limits(data, &offset);
sequencer_slip_update_header(scene, area, data, offset);
RNA_int_set(op->ptr, "offset", offset);
if (sequencer_slip_recursively(scene, data, offset)) {
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
}
}
return OPERATOR_RUNNING_MODAL;
}
void SEQUENCER_OT_slip(struct wmOperatorType *ot)
{
/* Identifiers. */
ot->name = "Trim Strips";
ot->idname = "SEQUENCER_OT_slip";
ot->description = "Trim the contents of the active strip";
/* Api callbacks. */
ot->invoke = sequencer_slip_invoke;
ot->modal = sequencer_slip_modal;
ot->exec = sequencer_slip_exec;
ot->poll = sequencer_edit_poll;
/* Flags. */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_int(ot->srna,
"offset",
0,
INT32_MIN,
INT32_MAX,
"Offset",
"Offset to the data of the strip",
INT32_MIN,
INT32_MAX);
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name Mute Strips Operator
* \{ */
static int sequencer_mute_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
Editing *ed = BKE_sequencer_editing_get(scene, false);
Sequence *seq;
bool selected;
selected = !RNA_boolean_get(op->ptr, "unselected");
for (seq = ed->seqbasep->first; seq; seq = seq->next) {
if ((seq->flag & SEQ_LOCK) == 0) {
if (selected) {
if (seq->flag & SELECT) {
seq->flag |= SEQ_MUTE;
BKE_sequence_invalidate_dependent(scene, seq);
}
}
else {
if ((seq->flag & SELECT) == 0) {
seq->flag |= SEQ_MUTE;
BKE_sequence_invalidate_dependent(scene, seq);
}
}
}
}
DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS);
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
return OPERATOR_FINISHED;
}
void SEQUENCER_OT_mute(struct wmOperatorType *ot)
{
/* Identifiers. */
ot->name = "Mute Strips";
ot->idname = "SEQUENCER_OT_mute";
ot->description = "Mute (un)selected strips";
/* Api callbacks. */
ot->exec = sequencer_mute_exec;
ot->poll = sequencer_edit_poll;
/* Flags. */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_boolean(
ot->srna, "unselected", 0, "Unselected", "Mute unselected rather than selected strips");
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name Unmute Strips Operator
* \{ */
static int sequencer_unmute_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
Editing *ed = BKE_sequencer_editing_get(scene, false);
Sequence *seq;
bool selected;
selected = !RNA_boolean_get(op->ptr, "unselected");
for (seq = ed->seqbasep->first; seq; seq = seq->next) {
if ((seq->flag & SEQ_LOCK) == 0) {
if (selected) {
if (seq->flag & SELECT) {
seq->flag &= ~SEQ_MUTE;
BKE_sequence_invalidate_dependent(scene, seq);
}
}
else {
if ((seq->flag & SELECT) == 0) {
seq->flag &= ~SEQ_MUTE;
BKE_sequence_invalidate_dependent(scene, seq);
}
}
}
}
DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS);
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
return OPERATOR_FINISHED;
}
void SEQUENCER_OT_unmute(struct wmOperatorType *ot)
{
/* Identifiers. */
ot->name = "Unmute Strips";
ot->idname = "SEQUENCER_OT_unmute";
ot->description = "Unmute (un)selected strips";
/* Api callbacks. */
ot->exec = sequencer_unmute_exec;
ot->poll = sequencer_edit_poll;
/* Flags. */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_boolean(
ot->srna, "unselected", 0, "Unselected", "Unmute unselected rather than selected strips");
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name Lock Strips Operator
* \{ */
static int sequencer_lock_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene = CTX_data_scene(C);
Editing *ed = BKE_sequencer_editing_get(scene, false);
Sequence *seq;
for (seq = ed->seqbasep->first; seq; seq = seq->next) {
if (seq->flag & SELECT) {
seq->flag |= SEQ_LOCK;
}
}
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
return OPERATOR_FINISHED;
}
void SEQUENCER_OT_lock(struct wmOperatorType *ot)
{
/* Identifiers. */
ot->name = "Lock Strips";
ot->idname = "SEQUENCER_OT_lock";
ot->description = "Lock strips so they can't be transformed";
/* Api callbacks. */
ot->exec = sequencer_lock_exec;
ot->poll = sequencer_edit_poll;
/* Flags. */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name Unlock Strips Operator
* \{ */
static int sequencer_unlock_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene = CTX_data_scene(C);
Editing *ed = BKE_sequencer_editing_get(scene, false);
Sequence *seq;
for (seq = ed->seqbasep->first; seq; seq = seq->next) {
if (seq->flag & SELECT) {
seq->flag &= ~SEQ_LOCK;
}
}
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
return OPERATOR_FINISHED;
}
void SEQUENCER_OT_unlock(struct wmOperatorType *ot)
{
/* Identifiers. */
ot->name = "Unlock Strips";
ot->idname = "SEQUENCER_OT_unlock";
ot->description = "Unlock strips so they can be transformed";
/* Api callbacks. */
ot->exec = sequencer_unlock_exec;
ot->poll = sequencer_edit_poll;
/* Flags. */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name Reload Strips Operator
* \{ */
static int sequencer_reload_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
Editing *ed = BKE_sequencer_editing_get(scene, false);
Sequence *seq;
const bool adjust_length = RNA_boolean_get(op->ptr, "adjust_length");
for (seq = ed->seqbasep->first; seq; seq = seq->next) {
if (seq->flag & SELECT) {
BKE_sequencer_update_changed_seq_and_deps(scene, seq, 0, 1);
BKE_sequence_reload_new_file(bmain, scene, seq, !adjust_length);
if (adjust_length) {
if (BKE_sequence_test_overlap(ed->seqbasep, seq)) {
BKE_sequence_base_shuffle(ed->seqbasep, seq, scene);
}
}
}
}
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
return OPERATOR_FINISHED;
}
void SEQUENCER_OT_reload(struct wmOperatorType *ot)
{
PropertyRNA *prop;
/* Identifiers. */
ot->name = "Reload Strips";
ot->idname = "SEQUENCER_OT_reload";
ot->description = "Reload strips in the sequencer";
/* Api callbacks. */
ot->exec = sequencer_reload_exec;
ot->poll = sequencer_edit_poll;
/* Flags. */
ot->flag = OPTYPE_REGISTER; /* No undo, the data changed is stored outside 'main'. */
prop = RNA_def_boolean(ot->srna,
"adjust_length",
0,
"Adjust Length",
"Adjust length of strips to their data length");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name Refresh Sequencer Operator
* \{ */
static bool sequencer_refresh_all_poll(bContext *C)
{
if (G.is_rendering) {
return 0;
}
return sequencer_edit_poll(C);
}
static int sequencer_refresh_all_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene = CTX_data_scene(C);
Editing *ed = BKE_sequencer_editing_get(scene, false);
BKE_sequencer_free_imbuf(scene, &ed->seqbase, false);
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
return OPERATOR_FINISHED;
}
void SEQUENCER_OT_refresh_all(struct wmOperatorType *ot)
{
/* Identifiers. */
ot->name = "Refresh Sequencer";
ot->idname = "SEQUENCER_OT_refresh_all";
ot->description = "Refresh the sequencer editor";
/* Api callbacks. */
ot->exec = sequencer_refresh_all_exec;
ot->poll = sequencer_refresh_all_poll;
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name Reassign Inputs Operator
* \{ */
static int sequencer_reassign_inputs_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
Sequence *seq1, *seq2, *seq3, *last_seq = BKE_sequencer_active_get(scene);
const char *error_msg;
if (BKE_sequence_effect_get_num_inputs(last_seq->type) != 0) {
BKE_report(op->reports, RPT_ERROR, "Cannot reassign inputs: strip has no inputs");
return OPERATOR_CANCELLED;
}
if (!seq_effect_find_selected(
scene, last_seq, last_seq->type, &seq1, &seq2, &seq3, &error_msg) ||
BKE_sequence_effect_get_num_inputs(last_seq->type) == 0) {
BKE_report(op->reports, RPT_ERROR, error_msg);
return OPERATOR_CANCELLED;
}
/* Check if reassigning would create recursivity. */
if (BKE_sequencer_render_loop_check(seq1, last_seq) ||
BKE_sequencer_render_loop_check(seq2, last_seq) ||
BKE_sequencer_render_loop_check(seq3, last_seq)) {
BKE_report(op->reports, RPT_ERROR, "Cannot reassign inputs: recursion detected");
return OPERATOR_CANCELLED;
}
last_seq->seq1 = seq1;
last_seq->seq2 = seq2;
last_seq->seq3 = seq3;
BKE_sequencer_update_changed_seq_and_deps(scene, last_seq, 1, 1);
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
return OPERATOR_FINISHED;
}
static bool sequencer_effect_poll(bContext *C)
{
Scene *scene = CTX_data_scene(C);
Editing *ed = BKE_sequencer_editing_get(scene, false);
if (ed) {
Sequence *last_seq = BKE_sequencer_active_get(scene);
if (last_seq && (last_seq->type & SEQ_TYPE_EFFECT)) {
return 1;
}
}
return 0;
}
void SEQUENCER_OT_reassign_inputs(struct wmOperatorType *ot)
{
/* Identifiers. */
ot->name = "Reassign Inputs";
ot->idname = "SEQUENCER_OT_reassign_inputs";
ot->description = "Reassign the inputs for the effect strip";
/* Api callbacks. */
ot->exec = sequencer_reassign_inputs_exec;
ot->poll = sequencer_effect_poll;
/* Flags. */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name Swap Inputs Operator
* \{ */
static int sequencer_swap_inputs_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
Sequence *seq, *last_seq = BKE_sequencer_active_get(scene);
if (last_seq->seq1 == NULL || last_seq->seq2 == NULL) {
BKE_report(op->reports, RPT_ERROR, "No valid inputs to swap");
return OPERATOR_CANCELLED;
}
seq = last_seq->seq1;
last_seq->seq1 = last_seq->seq2;
last_seq->seq2 = seq;
BKE_sequencer_update_changed_seq_and_deps(scene, last_seq, 1, 1);
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
return OPERATOR_FINISHED;
}
void SEQUENCER_OT_swap_inputs(struct wmOperatorType *ot)
{
/* Identifiers. */
ot->name = "Swap Inputs";
ot->idname = "SEQUENCER_OT_swap_inputs";
ot->description = "Swap the first two inputs for the effect strip";
/* Api callbacks. */
ot->exec = sequencer_swap_inputs_exec;
ot->poll = sequencer_effect_poll;
/* Flags. */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name Split Strips Operator
* \{ */
enum {
SEQ_SPLIT_SOFT,
SEQ_SPLIT_HARD,
};
static const EnumPropertyItem prop_split_types[] = {
{SEQ_SPLIT_SOFT, "SOFT", 0, "Soft", ""},
{SEQ_SPLIT_HARD, "HARD", 0, "Hard", ""},
{0, NULL, 0, NULL, NULL},
};
static int sequencer_split_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
Editing *ed = BKE_sequencer_editing_get(scene, false);
int split_side, split_hard, split_frame, split_channel;
bool changed, use_cursor_position, ignore_selection;
bool seq_selected = false;
split_frame = RNA_int_get(op->ptr, "frame");
split_channel = RNA_int_get(op->ptr, "channel");
use_cursor_position = RNA_boolean_get(op->ptr, "use_cursor_position");
split_hard = RNA_enum_get(op->ptr, "type");
split_side = RNA_enum_get(op->ptr, "side");
ignore_selection = RNA_boolean_get(op->ptr, "ignore_selection");
BKE_sequencer_prefetch_stop(scene);
if (split_hard == SEQ_SPLIT_HARD) {
changed = split_seq_list(bmain,
scene,
ed->seqbasep,
split_frame,
split_channel,
use_cursor_position,
split_seq_hard);
}
else {
changed = split_seq_list(bmain,
scene,
ed->seqbasep,
split_frame,
split_channel,
use_cursor_position,
split_seq_soft);
}
if (changed) { /* Got new strips? */
Sequence *seq;
if (ignore_selection) {
if (use_cursor_position) {
SEQP_BEGIN (ed, seq) {
if (seq->enddisp == split_frame && seq->machine == split_channel) {
seq_selected = seq->flag & SEQ_ALLSEL;
}
}
SEQ_END;
if (!seq_selected) {
SEQP_BEGIN (ed, seq) {
if (seq->startdisp == split_frame && seq->machine == split_channel) {
seq->flag &= ~SEQ_ALLSEL;
}
}
SEQ_END;
}
}
}
else {
if (split_side != SEQ_SIDE_BOTH) {
SEQP_BEGIN (ed, seq) {
if (split_side == SEQ_SIDE_LEFT) {
if (seq->startdisp >= split_frame) {
seq->flag &= ~SEQ_ALLSEL;
}
}
else {
if (seq->enddisp <= split_frame) {
seq->flag &= ~SEQ_ALLSEL;
}
}
}
SEQ_END;
}
}
SEQP_BEGIN (ed, seq) {
if (seq->seq1 || seq->seq2 || seq->seq3) {
BKE_sequence_calc(scene, seq);
}
}
SEQ_END;
BKE_sequencer_sort(scene);
}
if (changed) {
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
return OPERATOR_FINISHED;
}
/* Passthrough to selection if used as tool. */
return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH;
}
static int sequencer_split_invoke(bContext *