Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_sequencer/sequencer_edit.c
| Show First 20 Lines • Show All 1,580 Lines • ▼ Show 20 Lines | for (int i = data->num_seq - 1; i >= 0; i--) { | ||||
| } | } | ||||
| } | } | ||||
| if (changed) { | if (changed) { | ||||
| BKE_sequencer_free_imbuf(scene, &ed->seqbase, false); | BKE_sequencer_free_imbuf(scene, &ed->seqbase, false); | ||||
| } | } | ||||
| return changed; | return changed; | ||||
| } | } | ||||
| /* Make sure, that each strip contains at least 1 frame of content */ | |||||
| static void sequencer_slip_apply_limits(SlipData *data, float *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) | static int sequencer_slip_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| SlipData *data; | SlipData *data; | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| Editing *ed = BKE_sequencer_editing_get(scene, false); | Editing *ed = BKE_sequencer_editing_get(scene, false); | ||||
| int num_seq, i; | int num_seq, i; | ||||
| int offset = RNA_int_get(op->ptr, "offset"); | int offset = RNA_int_get(op->ptr, "offset"); | ||||
| bool success = false; | bool success = false; | ||||
| Show All 12 Lines | static int sequencer_slip_exec(bContext *C, wmOperator *op) | ||||
| data->num_seq = num_seq; | data->num_seq = num_seq; | ||||
| slip_add_sequences_rec(ed->seqbasep, data->seq_array, data->trim, 0, true); | slip_add_sequences_rec(ed->seqbasep, data->seq_array, data->trim, 0, true); | ||||
| for (i = 0; i < num_seq; i++) { | for (i = 0; i < num_seq; i++) { | ||||
| transseq_backup(data->ts + i, data->seq_array[i]); | transseq_backup(data->ts + i, data->seq_array[i]); | ||||
| } | } | ||||
| sequencer_slip_apply_limits(data, &offset); | |||||
| success = sequencer_slip_recursively(scene, data, offset); | success = sequencer_slip_recursively(scene, data, offset); | ||||
| MEM_freeN(data->seq_array); | MEM_freeN(data->seq_array); | ||||
| MEM_freeN(data->trim); | MEM_freeN(data->trim); | ||||
| MEM_freeN(data->ts); | MEM_freeN(data->ts); | ||||
| MEM_freeN(data); | MEM_freeN(data); | ||||
| if (success) { | if (success) { | ||||
| Show All 33 Lines | static int sequencer_slip_modal(bContext *C, wmOperator *op, const wmEvent *event) | ||||
| const bool has_numInput = hasNumInput(&data->num_input); | const bool has_numInput = hasNumInput(&data->num_input); | ||||
| bool handled = true; | bool handled = true; | ||||
| /* Modal numinput active, try to handle numeric inputs first... */ | /* Modal numinput active, try to handle numeric inputs first... */ | ||||
| if (event->val == KM_PRESS && has_numInput && handleNumInput(C, &data->num_input, event)) { | if (event->val == KM_PRESS && has_numInput && handleNumInput(C, &data->num_input, event)) { | ||||
| float offset; | float offset; | ||||
| applyNumInput(&data->num_input, &offset); | applyNumInput(&data->num_input, &offset); | ||||
| sequencer_slip_apply_limits(data, &offset); | |||||
| sequencer_slip_update_header(scene, sa, data, (int)offset); | sequencer_slip_update_header(scene, sa, data, (int)offset); | ||||
| RNA_int_set(op->ptr, "offset", offset); | RNA_int_set(op->ptr, "offset", offset); | ||||
| if (sequencer_slip_recursively(scene, data, offset)) { | if (sequencer_slip_recursively(scene, data, offset)) { | ||||
| WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); | WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); | ||||
| } | } | ||||
| return OPERATOR_RUNNING_MODAL; | return OPERATOR_RUNNING_MODAL; | ||||
| } | } | ||||
| switch (event->type) { | switch (event->type) { | ||||
| case MOUSEMOVE: { | case MOUSEMOVE: { | ||||
| if (!has_numInput) { | if (!has_numInput) { | ||||
| float mouseloc[2]; | float mouseloc[2]; | ||||
| int offset; | float offset; | ||||
| int mouse_x; | int mouse_x; | ||||
| View2D *v2d = UI_view2d_fromcontext(C); | View2D *v2d = UI_view2d_fromcontext(C); | ||||
| if (data->slow) { | if (data->slow) { | ||||
| mouse_x = event->mval[0] - data->slow_offset; | mouse_x = event->mval[0] - data->slow_offset; | ||||
| mouse_x *= 0.1f; | mouse_x *= 0.1f; | ||||
| mouse_x += data->slow_offset; | mouse_x += data->slow_offset; | ||||
| } | } | ||||
| else { | else { | ||||
| mouse_x = event->mval[0]; | mouse_x = event->mval[0]; | ||||
| } | } | ||||
| /* choose the side based on which side of the playhead the mouse is on */ | /* choose the side based on which side of the playhead the mouse is on */ | ||||
| UI_view2d_region_to_view(v2d, mouse_x, 0, &mouseloc[0], &mouseloc[1]); | UI_view2d_region_to_view(v2d, mouse_x, 0, &mouseloc[0], &mouseloc[1]); | ||||
| offset = mouseloc[0] - data->init_mouseloc[0]; | offset = mouseloc[0] - data->init_mouseloc[0]; | ||||
| sequencer_slip_update_header(scene, sa, data, offset); | sequencer_slip_apply_limits(data, &offset); | ||||
| sequencer_slip_update_header(scene, sa, data, (int)offset); | |||||
| RNA_int_set(op->ptr, "offset", offset); | RNA_int_set(op->ptr, "offset", offset); | ||||
| if (sequencer_slip_recursively(scene, data, offset)) { | if (sequencer_slip_recursively(scene, data, offset)) { | ||||
| WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); | WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); | ||||
| } | } | ||||
| } | } | ||||
| break; | break; | ||||
| ▲ Show 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | default: | ||||
| break; | break; | ||||
| } | } | ||||
| /* Modal numinput inactive, try to handle numeric inputs last... */ | /* Modal numinput inactive, try to handle numeric inputs last... */ | ||||
| if (!handled && event->val == KM_PRESS && handleNumInput(C, &data->num_input, event)) { | if (!handled && event->val == KM_PRESS && handleNumInput(C, &data->num_input, event)) { | ||||
| float offset; | float offset; | ||||
| applyNumInput(&data->num_input, &offset); | applyNumInput(&data->num_input, &offset); | ||||
| sequencer_slip_apply_limits(data, &offset); | |||||
| sequencer_slip_update_header(scene, sa, data, (int)offset); | sequencer_slip_update_header(scene, sa, data, (int)offset); | ||||
| RNA_int_set(op->ptr, "offset", offset); | RNA_int_set(op->ptr, "offset", offset); | ||||
| if (sequencer_slip_recursively(scene, data, offset)) { | if (sequencer_slip_recursively(scene, data, offset)) { | ||||
| WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); | WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 2,546 Lines • Show Last 20 Lines | |||||