merged hv7 mod
[goodguy/history.git] / cinelerra-5.1 / cinelerra / mwindowedit.C
index 0e4121b121ae18e17b414cedc264912507ac5cc0..4e1c5c7415d76314da93fb85d398683a9327046f 100644 (file)
@@ -301,7 +301,7 @@ void MWindow::asset_to_rate()
 void MWindow::clear_entry()
 {
        undo->update_undo_before();
-       clear(1);
+       clear(1, 1);
 
        edl->optimize();
        save_backup();
@@ -315,7 +315,7 @@ void MWindow::clear_entry()
                send_command(CURRENT_FRAME, CHANGE_EDL, edl, 1);
 }
 
-void MWindow::clear(int clear_handle)
+void MWindow::clear(int clear_handle, int deglitch)
 {
        double start = edl->local_session->get_selectionstart();
        double end = edl->local_session->get_selectionend();
@@ -326,6 +326,12 @@ void MWindow::clear(int clear_handle)
                        edl->session->plugins_follow_edits,
                        edl->session->autos_follow_edits);
        }
+       
+// always needed by paste operations
+       if(deglitch)
+       {
+               edl->deglitch(start);
+       }
 }
 
 void MWindow::set_automation_mode(int mode)
@@ -525,6 +531,7 @@ void MWindow::cut(double start, double end, double new_position)
                edl->session->labels_follow_edits,
                edl->session->plugins_follow_edits,
                edl->session->autos_follow_edits);
+       edl->deglitch(start);
 
 
        edl->optimize();
@@ -862,15 +869,20 @@ void MWindow::finish_modify_handles()
 
        if( (session->drag_handle == 1 && edit_mode != MOVE_NO_EDITS) ||
                (session->drag_handle == 0 && edit_mode == MOVE_ONE_EDIT) ) {
+//printf("MWindow::finish_modify_handles %d\n", __LINE__);
                edl->local_session->set_selectionstart(session->drag_position);
                edl->local_session->set_selectionend(session->drag_position);
+               edl->deglitch(session->drag_position);
        }
        else
        if( edit_mode != MOVE_NO_EDITS ) {
+//printf("MWindow::finish_modify_handles %d\n", __LINE__);
                edl->local_session->set_selectionstart(session->drag_start);
                edl->local_session->set_selectionend(session->drag_start);
+               edl->deglitch(session->drag_start);
        }
 
+// clamp the selection to 0
        if( edl->local_session->get_selectionstart(1) < 0 ) {
                edl->local_session->set_selectionstart(0);
                edl->local_session->set_selectionend(0);
@@ -1047,6 +1059,10 @@ void MWindow::mute_selection()
                edl->paste_silence(start, end, 0,
                        edl->session->plugins_follow_edits,
                        edl->session->autos_follow_edits);
+               edl->deglitch(start);
+               edl->deglitch(end);
+
+               
                save_backup();
                undo->update_undo_after(_("mute"), LOAD_EDITS);
 
@@ -1108,7 +1124,7 @@ int MWindow::paste(double start,
        int edit_plugins,
        int edit_autos)
 {
-       clear(0);
+       clear(0, 1);
 
 // Want to insert with assets shared with the master EDL.
        insert(start, file,
@@ -1131,7 +1147,7 @@ void MWindow::paste()
                gui->from_clipboard(string, len, BC_PRIMARY_SELECTION);
                FileXML file;
                file.read_from_string(string);
-               clear(0);
+               clear(0, 1);
 
                insert(start, &file,
                        edl->session->labels_follow_edits,
@@ -1609,6 +1625,8 @@ void MWindow::paste_silence()
                edl->session->labels_follow_edits,
                edl->session->plugins_follow_edits,
                edl->session->autos_follow_edits);
+       edl->deglitch(start);
+       edl->deglitch(end);
        edl->optimize();
        save_backup();
        undo->update_undo_after(_("silence"), LOAD_EDITS | LOAD_TIMEBAR);
@@ -2145,6 +2163,10 @@ void MWindow::trim_selection()
                edl->session->labels_follow_edits,
                edl->session->plugins_follow_edits,
                edl->session->autos_follow_edits);
+       edl->deglitch(0);
+       edl->deglitch(edl->local_session->get_selectionend() -
+               edl->local_session->get_selectionstart());
+       
 
        save_backup();
        undo->update_undo_after(_("trim selection"), LOAD_EDITS | LOAD_TIMEBAR);