diff options
author | William Reynish <billrey@me.com> | 2020-02-16 23:39:12 +0300 |
---|---|---|
committer | William Reynish <billrey@me.com> | 2020-02-16 23:39:12 +0300 |
commit | 819af2094b21a78d57c7480a649f97502c09ec1f (patch) | |
tree | c1b3ebb3da3a5e3a812dace962ee6cc630ad4a58 /source/blender/editors/space_sequencer/sequencer_edit.c | |
parent | 31530d0da95cea17c4e30fd449b2ce6f01feda3b (diff) |
Rename Sequencer 'Cut' to 'Split'
This avoids the ambiguity with the Cut operator in the Sequencer, which could be confused with Cut/Copy/Paste.
Use 'Split' for the operator and 'Blade' for the active tool.
Patch by Nathan Lovato, with edits
Differential Revision: https://developer.blender.org/D5542
Diffstat (limited to 'source/blender/editors/space_sequencer/sequencer_edit.c')
-rw-r--r-- | source/blender/editors/space_sequencer/sequencer_edit.c | 231 |
1 files changed, 121 insertions, 110 deletions
diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 2f3f90dc1b1..169564aba80 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -730,15 +730,15 @@ static void recurs_del_seq_flag(Scene *scene, ListBase *lb, short flag, short de } } -static Sequence *cut_seq_hard( - Main *bmain, Scene *scene, Sequence *seq, ListBase *new_seq_list, int cutframe) +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-cut, it's important to use the same value for both strips. */ - const bool is_end_exact = ((seq->start + seq->len) == cutframe); + /* 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; @@ -758,37 +758,38 @@ static Sequence *cut_seq_hard( /* 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-cut to fail, see: T47862 */ + * This causes hard-split to fail, see: T47862 */ if (seq->type != SEQ_TYPE_META) { BKE_sequence_reload_new_file(bmain, scene, seq, true); BKE_sequence_calc(scene, seq); } - /* Important to offset the start when 'cutframe == seq->start' + /* 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) && (cutframe <= seq->start)) { + 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 - cutframe; + seq->startstill = seq->start - split_frame; } else { - seq->start = cutframe - 1; - seq->startstill = cutframe - seq->startdisp - 1; + 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) && - ((cutframe >= seq->start) && (cutframe <= (seq->start + seq->len)))) { + ((split_frame >= seq->start) && (split_frame <= (seq->start + seq->len)))) { seq->endofs = 0; seq->endstill = 0; - seq->anim_endofs += (seq->start + seq->len) - cutframe; + seq->anim_endofs += (seq->start + seq->len) - split_frame; } /* strips with extended stillframes after */ - else if ((is_end_exact == true) || (((seq->start + seq->len) < cutframe) && (seq->endstill))) { - seq->endstill -= seq->enddisp - cutframe; + 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; @@ -807,38 +808,38 @@ static Sequence *cut_seq_hard( if (seqn) { seqn->flag |= SELECT; - /* Important not to re-assign this (unlike soft-cut) */ + /* Important not to re-assign this (unlike soft-split) */ #if 0 - is_end_exact = ((seqn->start + seqn->len) == cutframe); + is_end_exact = ((seqn->start + seqn->len) == split_frame); #endif /* Second Strip! */ /* strips with extended stillframes before */ - if ((seqn->startstill) && (cutframe == seqn->start + 1)) { + if ((seqn->startstill) && (split_frame == seqn->start + 1)) { seqn->start = ts.start; - seqn->startstill = ts.start - cutframe; + seqn->startstill = ts.start - split_frame; seqn->anim_endofs = ts.anim_endofs; seqn->endstill = ts.endstill; } /* normal strip */ else if ((is_end_exact == false) && - ((cutframe >= seqn->start) && (cutframe <= (seqn->start + seqn->len)))) { - seqn->start = cutframe; + ((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 += cutframe - ts.start; + 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) < cutframe) && (seqn->endstill))) { - seqn->start = cutframe; + (((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 - cutframe - 1; + seqn->endstill = ts.enddisp - split_frame - 1; seqn->startstill = 0; } @@ -848,14 +849,14 @@ static Sequence *cut_seq_hard( return seqn; } -static Sequence *cut_seq_soft( - Main *UNUSED(bmain), Scene *scene, Sequence *seq, ListBase *new_seq_list, int cutframe) +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) == cutframe); + bool is_end_exact = ((seq->start + seq->len) == split_frame); /* backup values */ ts.start = seq->start; @@ -873,29 +874,30 @@ static Sequence *cut_seq_soft( /* First Strip! */ /* strips with extended stillfames before */ - /* Important to offset the start when 'cutframe == seq->start' + /* 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) && (cutframe <= seq->start)) { + 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 - cutframe; + seq->startstill = seq->start - split_frame; } else { - seq->start = cutframe - 1; - seq->startstill = cutframe - seq->startdisp - 1; + 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) && (cutframe >= seq->start) && - (cutframe <= (seq->start + seq->len))) { - seq->endofs = (seq->start + seq->len) - cutframe; + 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 after */ - else if ((is_end_exact == true) || (((seq->start + seq->len) < cutframe) && (seq->endstill))) { - seq->endstill -= seq->enddisp - cutframe; + 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; @@ -913,32 +915,32 @@ static Sequence *cut_seq_soft( if (seqn) { seqn->flag |= SELECT; - is_end_exact = ((seqn->start + seqn->len) == cutframe); + is_end_exact = ((seqn->start + seqn->len) == split_frame); /* Second Strip! */ /* strips with extended stillframes before */ - if ((seqn->startstill) && (cutframe == seqn->start + 1)) { + if ((seqn->startstill) && (split_frame == seqn->start + 1)) { seqn->start = ts.start; - seqn->startstill = ts.start - cutframe; + seqn->startstill = ts.start - split_frame; seqn->endofs = ts.endofs; seqn->endstill = ts.endstill; } /* normal strip */ - else if ((is_end_exact == false) && (cutframe >= seqn->start) && - (cutframe <= (seqn->start + seqn->len))) { + else if ((is_end_exact == false) && (split_frame >= seqn->start) && + (split_frame <= (seqn->start + seqn->len))) { seqn->startstill = 0; - seqn->startofs = cutframe - ts.start; + seqn->startofs = split_frame - ts.start; seqn->endofs = ts.endofs; seqn->endstill = ts.endstill; } /* strips with extended stillframes after */ else if ((is_end_exact == true) || - (((seqn->start + seqn->len) < cutframe) && (seqn->endstill))) { - seqn->start = cutframe - ts.len + 1; + (((seqn->start + seqn->len) < split_frame) && (seqn->endstill))) { + seqn->start = split_frame - ts.len + 1; seqn->startofs = ts.len - 1; - seqn->endstill = ts.enddisp - cutframe - 1; + seqn->endstill = ts.enddisp - split_frame - 1; seqn->startstill = 0; } @@ -947,21 +949,23 @@ static Sequence *cut_seq_soft( return seqn; } -/* like duplicate, but only duplicate and cut overlapping strips, - * strips to the left of the cutframe are ignored and strips to the right +/* 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 cut_seq_list(Main *bmain, - Scene *scene, - ListBase *slist, - int cutframe, - int channel, - bool use_cursor_position, - Sequence *(*cut_seq)(Main *bmain, Scene *, Sequence *, ListBase *, int)) +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; @@ -972,8 +976,8 @@ static bool cut_seq_list(Main *bmain, 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 < cutframe && seq->enddisp > cutframe) { - Sequence *seqn = cut_seq(bmain, scene, seq, slist, cutframe); + 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; @@ -983,18 +987,18 @@ static bool cut_seq_list(Main *bmain, } else { if (seq->flag & SELECT) { - if (cutframe > seq->startdisp && cutframe < seq->enddisp) { - Sequence *seqn = cut_seq(bmain, scene, seq, slist, cutframe); + 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 <= cutframe) { + else if (seq->enddisp <= split_frame) { /* do nothing */ } - else if (seq->startdisp >= cutframe) { + else if (seq->startdisp >= split_frame) { /* move to tail */ BLI_remlink(slist, seq); BLI_addtail(slist, seq); @@ -2157,52 +2161,60 @@ void SEQUENCER_OT_swap_inputs(struct wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -/* cut operator */ -static const EnumPropertyItem prop_cut_types[] = { - {SEQ_CUT_SOFT, "SOFT", 0, "Soft", ""}, - {SEQ_CUT_HARD, "HARD", 0, "Hard", ""}, +/* split operator */ +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_cut_exec(bContext *C, wmOperator *op) +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 cut_side, cut_hard, cut_frame, cut_channel; + int split_side, split_hard, split_frame, split_channel; bool changed, use_cursor_position, ignore_selection; bool seq_selected = false; - cut_frame = RNA_int_get(op->ptr, "frame"); - cut_channel = RNA_int_get(op->ptr, "channel"); + 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"); - cut_hard = RNA_enum_get(op->ptr, "type"); - cut_side = RNA_enum_get(op->ptr, "side"); + 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"); - if (cut_hard == SEQ_CUT_HARD) { - changed = cut_seq_list( - bmain, scene, ed->seqbasep, cut_frame, cut_channel, use_cursor_position, cut_seq_hard); + 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 = cut_seq_list( - bmain, scene, ed->seqbasep, cut_frame, cut_channel, use_cursor_position, cut_seq_soft); + 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 == cut_frame && seq->machine == cut_channel) { + 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 == cut_frame && seq->machine == cut_channel) { + if (seq->startdisp == split_frame && seq->machine == split_channel) { seq->flag &= ~SEQ_ALLSEL; } } @@ -2211,15 +2223,15 @@ static int sequencer_cut_exec(bContext *C, wmOperator *op) } } else { - if (cut_side != SEQ_SIDE_BOTH) { + if (split_side != SEQ_SIDE_BOTH) { SEQP_BEGIN (ed, seq) { - if (cut_side == SEQ_SIDE_LEFT) { - if (seq->startdisp >= cut_frame) { + if (split_side == SEQ_SIDE_LEFT) { + if (seq->startdisp >= split_frame) { seq->flag &= ~SEQ_ALLSEL; } } else { - if (seq->enddisp <= cut_frame) { + if (seq->enddisp <= split_frame) { seq->flag &= ~SEQ_ALLSEL; } } @@ -2233,11 +2245,9 @@ static int sequencer_cut_exec(bContext *C, wmOperator *op) } } SEQ_END; - /* as last: */ BKE_sequencer_sort(scene); } - if (changed) { WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); return OPERATOR_FINISHED; @@ -2248,48 +2258,47 @@ static int sequencer_cut_exec(bContext *C, wmOperator *op) } } -static int sequencer_cut_invoke(bContext *C, wmOperator *op, const wmEvent *event) +static int sequencer_split_invoke(bContext *C, wmOperator *op, const wmEvent *event) { Scene *scene = CTX_data_scene(C); View2D *v2d = UI_view2d_fromcontext(C); - int cut_side = RNA_enum_get(op->ptr, "side"); - int cut_frame = CFRA; + int split_side = RNA_enum_get(op->ptr, "side"); + int split_frame = CFRA; - if (cut_side == SEQ_SIDE_MOUSE) { + if (split_side == SEQ_SIDE_MOUSE) { if (ED_operator_sequencer_active(C) && v2d) { - cut_side = mouse_frame_side(v2d, event->mval[0], cut_frame); + split_side = mouse_frame_side(v2d, event->mval[0], split_frame); } else { - cut_side = SEQ_SIDE_BOTH; + split_side = SEQ_SIDE_BOTH; } } - float mouseloc[2]; UI_view2d_region_to_view(v2d, event->mval[0], event->mval[1], &mouseloc[0], &mouseloc[1]); - if (RNA_boolean_get(op->ptr, "use_cursor_position")) { RNA_int_set(op->ptr, "frame", mouseloc[0]); } else { - RNA_int_set(op->ptr, "frame", cut_frame); + RNA_int_set(op->ptr, "frame", split_frame); } RNA_int_set(op->ptr, "channel", mouseloc[1]); - RNA_enum_set(op->ptr, "side", cut_side); - /*RNA_enum_set(op->ptr, "type", cut_hard); */ /*This type is set from the key shortcut */ - return sequencer_cut_exec(C, op); + RNA_enum_set(op->ptr, "side", split_side); + /*RNA_enum_set(op->ptr, "type", split_hard); */ /*This type is set from the key + shortsplit */ + return sequencer_split_exec(C, op); } -void SEQUENCER_OT_cut(struct wmOperatorType *ot) +void SEQUENCER_OT_split(struct wmOperatorType *ot) { /* identifiers */ - ot->name = "Cut Strips"; - ot->idname = "SEQUENCER_OT_cut"; - ot->description = "Cut the selected strips"; + ot->name = "Split Strips"; + ot->idname = "SEQUENCER_OT_split"; + ot->description = "Split the selected strips in two"; /* api callbacks */ - ot->invoke = sequencer_cut_invoke; - ot->exec = sequencer_cut_exec; + ot->invoke = sequencer_split_invoke; + ot->exec = sequencer_split_exec; ot->poll = sequencer_edit_poll; /* flags */ @@ -2302,7 +2311,7 @@ void SEQUENCER_OT_cut(struct wmOperatorType *ot) INT_MIN, INT_MAX, "Frame", - "Frame where selected strips will be cut", + "Frame where selected strips will be split", INT_MIN, INT_MAX); RNA_def_int(ot->srna, @@ -2316,21 +2325,23 @@ void SEQUENCER_OT_cut(struct wmOperatorType *ot) INT_MAX); RNA_def_enum(ot->srna, "type", - prop_cut_types, - SEQ_CUT_SOFT, + prop_split_types, + SEQ_SPLIT_SOFT, "Type", - "The type of cut operation to perform on strips"); + "The type of split operation to perform on strips"); + RNA_def_boolean(ot->srna, "use_cursor_position", 0, "Use Cursor Position", - "Cut at position of the cursor instead of playhead"); + "Split at position of the cursor instead of playhead"); + prop = RNA_def_enum(ot->srna, "side", prop_side_types, SEQ_SIDE_MOUSE, "Side", - "The side that remains selected after cutting"); + "The side that remains selected after splitting"); RNA_def_property_flag(prop, PROP_SKIP_SAVE); |