Cleanup: refactor sequencer_edit.c file
Move RNA enums and utility functions closer to operator definition. No functional changes.
This commit is contained in:
@@ -72,46 +72,6 @@
|
||||
/** \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;
|
||||
@@ -124,263 +84,6 @@ typedef struct TransSeq {
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \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;
|
||||
}
|
||||
|
||||
SEQ_CURRENT_BEGIN (ed, seq) {
|
||||
seq->flag &= ~SEQ_ALLSEL;
|
||||
}
|
||||
SEQ_CURRENT_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
|
||||
* \{ */
|
||||
@@ -427,135 +130,59 @@ bool ED_space_sequencer_check_show_strip(SpaceSeq *sseq)
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Find Selected Strips as Inputs to an Effects Strip
|
||||
/** \name Shared Poll Functions
|
||||
* \{ */
|
||||
|
||||
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)
|
||||
/* Operator functions. */
|
||||
bool sequencer_edit_poll(bContext *C)
|
||||
{
|
||||
Editing *ed = BKE_sequencer_editing_get(scene, false);
|
||||
Sequence *seq1 = NULL, *seq2 = NULL, *seq3 = NULL, *seq;
|
||||
return (BKE_sequencer_editing_get(CTX_data_scene(C), false) != NULL);
|
||||
}
|
||||
|
||||
*r_error_str = 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
|
||||
|
||||
if (!activeseq) {
|
||||
seq2 = BKE_sequencer_active_get(scene);
|
||||
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;
|
||||
}
|
||||
|
||||
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 (!ELEM(seq, activeseq, 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
/* 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;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Delete Utilities
|
||||
/** \name Remove Gaps Operator
|
||||
* \{ */
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
static bool sequence_offset_after_frame(Scene *scene, const int delta, const int timeline_frame)
|
||||
{
|
||||
Sequence *seq;
|
||||
@@ -589,79 +216,43 @@ static bool sequence_offset_after_frame(Scene *scene, const int delta, const int
|
||||
return done;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void set_filter_seq(Scene *scene)
|
||||
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;
|
||||
}
|
||||
|
||||
if (okee("Set Deinterlace") == 0) {
|
||||
return;
|
||||
}
|
||||
min[0] = SFRA;
|
||||
max[0] = EFRA + 1;
|
||||
min[1] = 0.0;
|
||||
max[1] = 8.0;
|
||||
|
||||
SEQ_CURRENT_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 = ed->seqbasep->first;
|
||||
while (seq) {
|
||||
|
||||
if (min[0] > seq->startdisp - 1) {
|
||||
min[0] = seq->startdisp - 1;
|
||||
}
|
||||
}
|
||||
SEQ_CURRENT_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;
|
||||
}
|
||||
|
||||
SEQ_CURRENT_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);
|
||||
}
|
||||
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;
|
||||
}
|
||||
SEQ_CURRENT_END;
|
||||
|
||||
rect->xmin = min[0];
|
||||
rect->xmax = max[0];
|
||||
rect->ymin = min[1];
|
||||
rect->ymax = max[1];
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Remove Gaps Operator
|
||||
* \{ */
|
||||
|
||||
static int sequencer_gap_remove_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
@@ -778,72 +369,6 @@ void SEQUENCER_OT_gap_insert(struct wmOperatorType *ot)
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \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
|
||||
* \{ */
|
||||
@@ -1700,6 +1225,102 @@ void SEQUENCER_OT_refresh_all(struct wmOperatorType *ot)
|
||||
/** \name Reassign Inputs Operator
|
||||
* \{ */
|
||||
|
||||
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 (!ELEM(seq, activeseq, 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;
|
||||
}
|
||||
|
||||
static int sequencer_reassign_inputs_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
@@ -1813,12 +1434,35 @@ void SEQUENCER_OT_swap_inputs(struct wmOperatorType *ot)
|
||||
/** \name Split Strips Operator
|
||||
* \{ */
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
static const EnumPropertyItem prop_split_types[] = {
|
||||
{SEQ_SPLIT_SOFT, "SOFT", 0, "Soft", ""},
|
||||
{SEQ_SPLIT_HARD, "HARD", 0, "Hard", ""},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
};
|
||||
|
||||
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 int sequencer_split_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Main *bmain = CTX_data_main(C);
|
||||
@@ -2017,8 +1661,6 @@ void SEQUENCER_OT_split(struct wmOperatorType *ot)
|
||||
RNA_def_property_flag(prop, PROP_HIDDEN);
|
||||
}
|
||||
|
||||
#undef SEQ_SIDE_MOUSE
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
@@ -2310,6 +1952,31 @@ void SEQUENCER_OT_images_separate(wmOperatorType *ot)
|
||||
/** \name Toggle Meta Strip Operator
|
||||
* \{ */
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
static int sequencer_meta_toggle_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
@@ -2490,6 +2157,28 @@ static int seq_depends_on_meta(Sequence *seq, Sequence *seqm)
|
||||
return 0;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
static int sequencer_meta_separate_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
@@ -2635,6 +2324,12 @@ void SEQUENCER_OT_strip_jump(wmOperatorType *ot)
|
||||
/** \name Swap Strip Operator
|
||||
* \{ */
|
||||
|
||||
static const EnumPropertyItem prop_side_lr_types[] = {
|
||||
{SEQ_SIDE_LEFT, "LEFT", 0, "Left", ""},
|
||||
{SEQ_SIDE_RIGHT, "RIGHT", 0, "Right", ""},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
};
|
||||
|
||||
static void swap_sequence(Scene *scene, Sequence *seqa, Sequence *seqb)
|
||||
{
|
||||
int gap = seqb->startdisp - seqa->enddisp;
|
||||
@@ -2650,27 +2345,56 @@ static void swap_sequence(Scene *scene, Sequence *seqa, Sequence *seqb)
|
||||
BKE_sequence_calc(scene, seqa);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static Sequence *sequence_find_parent(Scene *scene, Sequence *child)
|
||||
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);
|
||||
Sequence *parent = NULL;
|
||||
Sequence *seq;
|
||||
|
||||
int dist, best_dist;
|
||||
best_dist = MAXFRAME * 2;
|
||||
|
||||
if (ed == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (seq = ed->seqbasep->first; seq; seq = seq->next) {
|
||||
if ((seq != child) && seq_is_parent(seq, child)) {
|
||||
parent = seq;
|
||||
break;
|
||||
}
|
||||
}
|
||||
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;
|
||||
|
||||
return parent;
|
||||
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. */
|
||||
}
|
||||
|
||||
static bool seq_is_parent(Sequence *par, Sequence *seq)
|
||||
{
|
||||
return ((par->seq1 == seq) || (par->seq2 == seq) || (par->seq3 == seq));
|
||||
}
|
||||
#endif
|
||||
|
||||
static int sequencer_swap_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
@@ -2895,6 +2619,21 @@ void SEQUENCER_OT_copy(wmOperatorType *ot)
|
||||
/** \name Paste Operator
|
||||
* \{ */
|
||||
|
||||
void ED_sequencer_deselect_all(Scene *scene)
|
||||
{
|
||||
Sequence *seq;
|
||||
Editing *ed = BKE_sequencer_editing_get(scene, false);
|
||||
|
||||
if (ed == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
SEQ_CURRENT_BEGIN (ed, seq) {
|
||||
seq->flag &= ~SEQ_ALLSEL;
|
||||
}
|
||||
SEQ_CURRENT_END;
|
||||
}
|
||||
|
||||
static int sequencer_paste_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
Main *bmain = CTX_data_main(C);
|
||||
@@ -3097,6 +2836,28 @@ void SEQUENCER_OT_change_effect_input(struct wmOperatorType *ot)
|
||||
/** \name Change Effect Type Operator
|
||||
* \{ */
|
||||
|
||||
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},
|
||||
};
|
||||
|
||||
static int sequencer_change_effect_type_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
@@ -3521,3 +3282,220 @@ void SEQUENCER_OT_set_range_to_strips(struct wmOperatorType *ot)
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Unused functions
|
||||
* \{ */
|
||||
|
||||
#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;
|
||||
}
|
||||
|
||||
SEQ_CURRENT_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_CURRENT_END;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
SEQ_CURRENT_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_CURRENT_END;
|
||||
}
|
||||
|
||||
static Sequence *sequence_find_parent(Scene *scene, Sequence *child)
|
||||
{
|
||||
Editing *ed = BKE_sequencer_editing_get(scene, false);
|
||||
Sequence *parent = NULL;
|
||||
Sequence *seq;
|
||||
|
||||
if (ed == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (seq = ed->seqbasep->first; seq; seq = seq->next) {
|
||||
if ((seq != child) && seq_is_parent(seq, child)) {
|
||||
parent = seq;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return parent;
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Unused in current file
|
||||
* \{ */
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
@@ -60,6 +60,7 @@ enum {
|
||||
|
||||
/* RNA enums, just to be more readable */
|
||||
enum {
|
||||
SEQ_SIDE_MOUSE = -1,
|
||||
SEQ_SIDE_NONE = 0,
|
||||
SEQ_SIDE_LEFT,
|
||||
SEQ_SIDE_RIGHT,
|
||||
|
||||
Reference in New Issue
Block a user