X-Git-Url: https://git.cinelerra-gg.org/git/?p=goodguy%2Fcinelerra.git;a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Fedits.C;h=9e3c2a5efcd63a0d52b3cf42df26935420d9fd72;hp=a79bb171d9ba2f4178f4d5a7b45b54506a4a9a44;hb=0c7b0aebb5e9f85f4eb7abb69b800d8d37b30b0f;hpb=7fd85fb66168f6b518c5f2d73e04036e87faa0e1 diff --git a/cinelerra-5.1/cinelerra/edits.C b/cinelerra-5.1/cinelerra/edits.C index a79bb171..9e3c2a5e 100644 --- a/cinelerra-5.1/cinelerra/edits.C +++ b/cinelerra-5.1/cinelerra/edits.C @@ -220,10 +220,12 @@ Edit* Edits::insert_new_edit(int64_t position) { //printf("Edits::insert_new_edit 1\n"); Edit *current = split_edit(position); - if(current) current = PREVIOUS; //printf("Edits::insert_new_edit 1\n"); Edit *new_edit = create_edit(); + if( current ) new_edit->hard_right = current->hard_left; + if( current ) current = PREVIOUS; + if( current ) new_edit->hard_left = current->hard_right; //printf("Edits::insert_new_edit 1\n"); insert_after(current, new_edit); new_edit->startproject = position; @@ -409,12 +411,14 @@ int Edits::optimize() int64_t current_start = current->startproject; int64_t next_end = next_edit->startproject + next_edit->length; current->length = next_end - current_start; + current->hard_right = next_edit->hard_right; remove(next_edit); result = 1; } } - if( last && last->silence() && !last->transition ) { + if( last && last->silence() && + !last->transition && !last->hard_left && !last->hard_right ) { delete last; result = 1; } @@ -642,8 +646,7 @@ void Edits::clear_recursive(int64_t start, int64_t end, { //printf("Edits::clear_recursive 1\n"); track->clear(start, end, - edit_edits, edit_labels, edit_plugins, edit_autos, 0, - trim_edits); + edit_edits, edit_labels, edit_plugins, edit_autos, trim_edits); } @@ -679,8 +682,7 @@ int Edits::clear_handle(double start, double end, // Lengthen effects if(edit_plugins) track->shift_effects(current_edit->next->startproject, - length, - edit_autos); + length, edit_autos, 0); for(current_edit = current_edit->next; current_edit; current_edit = current_edit->next) { @@ -700,47 +702,38 @@ int Edits::clear_handle(double start, double end, int Edits::modify_handles(double oldposition, double newposition, int currentend, int edit_mode, int edit_edits, int edit_labels, int edit_plugins, int edit_autos, - Edits *trim_edits) + Edits *trim_edits, int group_id) { int result = 0; Edit *current_edit; + Edit *left = 0, *right = 0; + if( group_id > 0 ) { + double start = DBL_MAX, end = DBL_MIN; + for( Edit *edit=first; edit; edit=edit->next ) { + if( edit->group_id != group_id ) continue; + double edit_start = edit->track->from_units(edit->startproject); + if( edit_start < start ) { start = edit_start; left = edit; } + double edit_end = edit->track->from_units(edit->startproject+edit->length); + if( edit_end > end ) { end = edit_end; right = edit; } + } + } //printf("Edits::modify_handles 1 %d %f %f\n", currentend, newposition, oldposition); if(currentend == 0) { // left handle for(current_edit = first; current_edit && !result;) { - if(edl->equivalent(track->from_units(current_edit->startproject), - oldposition)) { + if( group_id > 0 ? current_edit == left : + edl->equivalent(track->from_units(current_edit->startproject), + oldposition) ) { // edit matches selection //printf("Edits::modify_handles 3 %f %f\n", newposition, oldposition); + double delta = newposition - oldposition; oldposition = track->from_units(current_edit->startproject); + if( group_id > 0 ) newposition = oldposition + delta; + current_edit->shift_start(edit_mode, + track->to_units(newposition, 0), track->to_units(oldposition, 0), + edit_labels, edit_autos, edit_plugins, trim_edits); result = 1; - - if(newposition >= oldposition) { -//printf("Edits::modify_handle 1 %s %f %f\n", track->title, oldposition, newposition); -// shift start of edit in - current_edit->shift_start_in(edit_mode, - track->to_units(newposition, 0), - track->to_units(oldposition, 0), - edit_edits, - edit_labels, - edit_plugins, - edit_autos, - trim_edits); - } - else - { -//printf("Edits::modify_handle 2 %s\n", track->title); -// move start of edit out - current_edit->shift_start_out(edit_mode, - track->to_units(newposition, 0), - track->to_units(oldposition, 0), - edit_edits, - edit_labels, - edit_plugins, - edit_autos, - trim_edits); - } } if(!result) current_edit = current_edit->next; @@ -749,40 +742,18 @@ int Edits::modify_handles(double oldposition, double newposition, int currentend else { // right handle selected for(current_edit = first; current_edit && !result;) { - if(edl->equivalent(track->from_units(current_edit->startproject) + - track->from_units(current_edit->length), oldposition)) { - oldposition = track->from_units(current_edit->startproject) + + if( group_id > 0 ? current_edit == right : + edl->equivalent(track->from_units(current_edit->startproject) + + track->from_units(current_edit->length), oldposition) ) { + double delta = newposition - oldposition; + oldposition = track->from_units(current_edit->startproject) + track->from_units(current_edit->length); + if( group_id > 0 ) newposition = oldposition + delta; result = 1; -//printf("Edits::modify_handle 3\n"); - if(newposition <= oldposition) { -// shift end of edit in -//printf("Edits::modify_handle 4\n"); - current_edit->shift_end_in(edit_mode, - track->to_units(newposition, 0), - track->to_units(oldposition, 0), - edit_edits, - edit_labels, - edit_plugins, - edit_autos, - trim_edits); -//printf("Edits::modify_handle 5\n"); - } - else - { -// move end of edit out -//printf("Edits::modify_handle %d edit_mode=%d\n", __LINE__, edit_mode); - current_edit->shift_end_out(edit_mode, - track->to_units(newposition, 0), - track->to_units(oldposition, 0), - edit_edits, - edit_labels, - edit_plugins, - edit_autos, - trim_edits); -//printf("Edits::modify_handle 7\n"); - } + current_edit->shift_end(edit_mode, + track->to_units(newposition, 0), track->to_units(oldposition, 0), + edit_labels, edit_autos, edit_plugins, trim_edits); } if(!result) current_edit = current_edit->next; @@ -794,13 +765,12 @@ int Edits::modify_handles(double oldposition, double newposition, int currentend return 0; } - void Edits::paste_silence(int64_t start, int64_t end) { Edit *new_edit = editof(start, PLAY_FORWARD, 0); if (!new_edit) return; - if( !new_edit->silence() ) { + if( !new_edit->silence() || new_edit->hard_right ) { new_edit = insert_new_edit(start); new_edit->length = end - start; } @@ -844,6 +814,6 @@ void Edits::shift_keyframes_recursive(int64_t position, int64_t length) void Edits::shift_effects_recursive(int64_t position, int64_t length, int edit_autos) { - track->shift_effects(position, length, edit_autos); + track->shift_effects(position, length, edit_autos, 0); }