add x10tv ati remote rework, android remote rework, wintv remote tweaks
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / edits.C
index 26f49890d70cb22fbc1ea7351ab80f7a15edbba1..8c8901bf4df3b85d391e0027d5acd356365779f9 100644 (file)
@@ -223,9 +223,7 @@ Edit* Edits::insert_new_edit(int64_t position)
 
 //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;
@@ -247,6 +245,14 @@ Edit* Edits::split_edit(int64_t position)
        new_edit->copy_from(edit);
        new_edit->length = new_edit->startproject + new_edit->length - position;
        edit->length = position - edit->startproject;
+       if( !new_edit->length || edit->silence() )
+               new_edit->hard_left = new_edit->hard_right = 0;
+       else if( !edit->length )
+               edit->hard_left = edit->hard_right = 0;
+       else {
+               new_edit->hard_right = edit->hard_right;
+               new_edit->hard_left = edit->hard_right = 0;
+       }
        new_edit->startproject = position;
        new_edit->startsource += edit->length;
 
@@ -326,6 +332,14 @@ int Edits::optimize()
                }
        }
 
+// trim edits before position 0
+       while( first && first->startproject+first->length < 0 )
+               delete first;
+       if( first && first->startproject < 0 ) {
+               first->length += first->startproject;
+               first->startproject = 0;
+       }
+
 // Insert silence between edits which aren't consecutive
        for(current = last; current; current = current->previous)
        {
@@ -359,13 +373,19 @@ int Edits::optimize()
 
 // delete 0 length edits
                for( current = first; !result && current; ) {
-                       Edit* next = current->next;
+                       Edit* prev = current->previous, *next = current->next;
                        if( current->length == 0 ) {
                                if( next && current->transition && !next->transition) {
                                        next->transition = current->transition;
                                        next->transition->edit = next;
                                        current->transition = 0;
                                }
+                               if( !current->silence() ) {
+                                       if( current->hard_left && next && !next->silence() )
+                                               next->hard_left = 1;
+                                       if( current->hard_right && prev && !prev->silence())
+                                               prev->hard_right = 1;
+                               }
                                delete current;
                                result = 1;
                                break;
@@ -386,7 +406,8 @@ int Edits::optimize()
                        Edit *next_edit = 0;
                        for( ; current && (next_edit=current->next); current=NEXT ) {
 // both edges are not hard edges
-                               if( current->hard_right || next_edit->hard_left ) continue;
+                               if( current->hard_right || next_edit->hard_left )
+                                       continue;
 // next edit is a glitch
                                if( is_glitch(next_edit) )
                                        break;
@@ -730,17 +751,10 @@ int Edits::modify_handles(double oldposition, double newposition, int currentend
                                double delta = newposition - oldposition;
                                oldposition = track->from_units(current_edit->startproject);
                                if( group_id > 0 ) newposition = oldposition + delta;
-                               result = 1;
-// dont move stuff if media playback does not shift in time
-                               if( edit_mode != MOVE_MEDIA && edit_mode != MOVE_EDGE_MEDIA ) {
-                                       edit_labels = 0;
-                                       edit_plugins = 0;
-                                       edit_autos = 0;
-                               }
                                current_edit->shift_start(edit_mode,
                                        track->to_units(newposition, 0), track->to_units(oldposition, 0),
-                                       0, edit_labels, edit_plugins, edit_autos,
-                                       trim_edits);
+                                       edit_labels, edit_autos, edit_plugins, trim_edits);
+                               result = 1;
                        }
 
                        if(!result) current_edit = current_edit->next;
@@ -760,7 +774,7 @@ int Edits::modify_handles(double oldposition, double newposition, int currentend
 
                                current_edit->shift_end(edit_mode,
                                        track->to_units(newposition, 0), track->to_units(oldposition, 0),
-                                       edit_edits, edit_labels, edit_plugins, edit_autos, trim_edits);
+                                       edit_labels, edit_autos, edit_plugins, trim_edits);
                        }
 
                        if(!result) current_edit = current_edit->next;