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
This commit is contained in:
parent
31530d0da9
commit
819af2094b
@ -2397,9 +2397,9 @@ def km_sequencer(params):
|
||||
|
||||
items.extend([
|
||||
*_template_items_select_actions(params, "sequencer.select_all"),
|
||||
("sequencer.cut", {"type": 'K', "value": 'PRESS'},
|
||||
("sequencer.split", {"type": 'K', "value": 'PRESS'},
|
||||
{"properties": [("type", 'SOFT')]}),
|
||||
("sequencer.cut", {"type": 'K', "value": 'PRESS', "shift": True},
|
||||
("sequencer.split", {"type": 'K', "value": 'PRESS', "shift": True},
|
||||
{"properties": [("type", 'HARD')]}),
|
||||
("sequencer.mute", {"type": 'H', "value": 'PRESS'},
|
||||
{"properties": [("unselected", False)]}),
|
||||
@ -2450,7 +2450,7 @@ def km_sequencer(params):
|
||||
("sequencer.snap", {"type": 'S', "value": 'PRESS', "shift": True}, None),
|
||||
("sequencer.swap_inputs", {"type": 'S', "value": 'PRESS', "alt": True}, None),
|
||||
*(
|
||||
(("sequencer.cut_multicam",
|
||||
(("sequencer.split_multicam",
|
||||
{"type": NUMBERS_1[i], "value": 'PRESS'},
|
||||
{"properties": [("camera", i + 1)]})
|
||||
for i in range(10)
|
||||
@ -6120,12 +6120,12 @@ def km_sequencer_editor_tool_select_box(params):
|
||||
)
|
||||
|
||||
|
||||
def km_sequencer_editor_tool_cut(_params):
|
||||
def km_sequencer_editor_tool_blade(_params):
|
||||
return (
|
||||
"Sequencer Tool: Cut",
|
||||
"Sequencer Tool: Blade",
|
||||
{"space_type": 'SEQUENCE_EDITOR', "region_type": 'WINDOW'},
|
||||
{"items":[
|
||||
("sequencer.cut", {"type": 'LEFTMOUSE', "value": 'PRESS'},
|
||||
{"items": [
|
||||
("sequencer.split", {"type": 'LEFTMOUSE', "value": 'PRESS'},
|
||||
{"properties": [("type", 'SOFT'), ("side", 'NO_CHANGE'), ("use_cursor_position", True), ("ignore_selection", True)]}),
|
||||
]},
|
||||
)
|
||||
@ -6346,7 +6346,7 @@ def generate_keymaps(params=None):
|
||||
km_3d_view_tool_sculpt_gpencil_select_lasso(params),
|
||||
km_sequencer_editor_tool_select(params),
|
||||
km_sequencer_editor_tool_select_box(params),
|
||||
km_sequencer_editor_tool_cut(params),
|
||||
km_sequencer_editor_tool_blade(params),
|
||||
]
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
|
@ -79,11 +79,11 @@ class SequencerCrossfadeSounds(Operator):
|
||||
return {'CANCELLED'}
|
||||
|
||||
|
||||
class SequencerCutMulticam(Operator):
|
||||
"""Cut multi-cam strip and select camera"""
|
||||
class SequencerSplitMulticam(Operator):
|
||||
"""Split multi-cam strip and select camera"""
|
||||
|
||||
bl_idname = "sequencer.cut_multicam"
|
||||
bl_label = "Cut multicam"
|
||||
bl_idname = "sequencer.split_multicam"
|
||||
bl_label = "Split multicam"
|
||||
bl_options = {'REGISTER', 'UNDO'}
|
||||
|
||||
camera: IntProperty(
|
||||
@ -112,7 +112,7 @@ class SequencerCutMulticam(Operator):
|
||||
s.select = True
|
||||
|
||||
cfra = context.scene.frame_current
|
||||
bpy.ops.sequencer.cut(frame=cfra, type='SOFT', side='RIGHT')
|
||||
bpy.ops.sequencer.split(frame=cfra, type='SOFT', side='RIGHT')
|
||||
for s in context.scene.sequence_editor.sequences_all:
|
||||
if s.select and s.type == 'MULTICAM' and s.frame_final_start <= cfra and cfra < s.frame_final_end:
|
||||
context.scene.sequence_editor.active_strip = s
|
||||
@ -369,7 +369,7 @@ def calculate_duration_frames(context, duration_seconds):
|
||||
|
||||
classes = (
|
||||
SequencerCrossfadeSounds,
|
||||
SequencerCutMulticam,
|
||||
SequencerSplitMulticam,
|
||||
SequencerDeinterlaceSelectedMovies,
|
||||
SequencerFadesClear,
|
||||
SequencerFadesAdd,
|
||||
|
@ -716,8 +716,8 @@ class SEQUENCER_MT_strip(Menu):
|
||||
layout.menu("SEQUENCER_MT_strip_transform")
|
||||
|
||||
layout.separator()
|
||||
layout.operator("sequencer.cut", text="Cut").type = 'SOFT'
|
||||
layout.operator("sequencer.cut", text="Hold Cut").type = 'HARD'
|
||||
layout.operator("sequencer.split", text="Split").type = 'SOFT'
|
||||
layout.operator("sequencer.split", text="Hold Split").type = 'HARD'
|
||||
|
||||
layout.separator()
|
||||
layout.operator("sequencer.copy", text="Copy")
|
||||
|
@ -1706,22 +1706,23 @@ class _defs_node_edit:
|
||||
keymap="Node Tool: Links Cut",
|
||||
)
|
||||
|
||||
|
||||
class _defs_sequencer_generic:
|
||||
|
||||
@ToolDef.from_fn
|
||||
def cut():
|
||||
def blade():
|
||||
def draw_settings(_context, layout, tool):
|
||||
props = tool.operator_properties("sequencer.cut")
|
||||
props = tool.operator_properties("sequencer.split")
|
||||
row = layout.row()
|
||||
row.use_property_split = False
|
||||
row.prop(props, "type", expand=True)
|
||||
return dict(
|
||||
idname="builtin.cut",
|
||||
label="Cut",
|
||||
idname="builtin.blade",
|
||||
label="Blade",
|
||||
icon="ops.sequencer.blade",
|
||||
cursor='CROSSHAIR',
|
||||
widget=None,
|
||||
keymap="Sequencer Tool: Cut",
|
||||
keymap="Sequencer Tool: Blade",
|
||||
draw_settings=draw_settings,
|
||||
)
|
||||
|
||||
@ -2255,15 +2256,16 @@ class SEQUENCER_PT_tools_active(ToolSelectPanelHelper, Panel):
|
||||
],
|
||||
'SEQUENCER': [
|
||||
*_tools_select,
|
||||
_defs_sequencer_generic.cut,
|
||||
_defs_sequencer_generic.blade,
|
||||
],
|
||||
'SEQUENCER_PREVIEW': [
|
||||
*_tools_select,
|
||||
*_tools_annotate,
|
||||
_defs_sequencer_generic.cut,
|
||||
_defs_sequencer_generic.blade,
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
classes = (
|
||||
IMAGE_PT_tools_active,
|
||||
NODE_PT_tools_active,
|
||||
|
@ -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);
|
||||
|
||||
|
@ -104,7 +104,7 @@ extern EnumPropertyItem prop_side_types[];
|
||||
struct wmKeyConfig;
|
||||
struct wmOperatorType;
|
||||
|
||||
void SEQUENCER_OT_cut(struct wmOperatorType *ot);
|
||||
void SEQUENCER_OT_split(struct wmOperatorType *ot);
|
||||
void SEQUENCER_OT_slip(struct wmOperatorType *ot);
|
||||
void SEQUENCER_OT_mute(struct wmOperatorType *ot);
|
||||
void SEQUENCER_OT_unmute(struct wmOperatorType *ot);
|
||||
@ -178,8 +178,8 @@ void SEQUENCER_OT_image_strip_add(struct wmOperatorType *ot);
|
||||
void SEQUENCER_OT_effect_strip_add(struct wmOperatorType *ot);
|
||||
|
||||
enum {
|
||||
SEQ_CUT_SOFT,
|
||||
SEQ_CUT_HARD,
|
||||
SEQ_SPLIT_SOFT,
|
||||
SEQ_SPLIT_HARD,
|
||||
};
|
||||
enum {
|
||||
SEQ_SELECTED,
|
||||
|
@ -43,7 +43,7 @@
|
||||
void sequencer_operatortypes(void)
|
||||
{
|
||||
/* sequencer_edit.c */
|
||||
WM_operatortype_append(SEQUENCER_OT_cut);
|
||||
WM_operatortype_append(SEQUENCER_OT_split);
|
||||
WM_operatortype_append(SEQUENCER_OT_slip);
|
||||
WM_operatortype_append(SEQUENCER_OT_mute);
|
||||
WM_operatortype_append(SEQUENCER_OT_unmute);
|
||||
|
Loading…
Reference in New Issue
Block a user