drag edit contraints relaxed for ripples, cwdw gui/tool deadlock fix, vpatchgui fader...
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / edit.C
index 5321209acd68b7233a3b23d2ac1bb4da9edcadfe..e9e9f1b467e1e337ebd6f8b8535c10d17558f636 100644 (file)
@@ -443,20 +443,28 @@ int Edit::shift_start(int edit_mode, int64_t newposition, int64_t oldposition,
        int edit_labels, int edit_autos, int edit_plugins, Edits *trim_edits)
 {
        int64_t cut_length = newposition - oldposition;
-       if( !cut_length ) return 0;
+       int rest_moved = edit_mode == MOVE_RIPPLE || edit_mode == MOVE_EDGE ? 1 : 0;
+       if( cut_length > length )
+               cut_length = length;
+       else if( cut_length < -length )
+               cut_length = -length;
+
        int64_t start = startproject, end = start + length;
        Edit *prev = this->previous, *next = this->next;
-       int edits_moved = 0, rest_moved = 0;
+       int edits_moved = 0;
 
        switch( edit_mode ) {
        case MOVE_RIPPLE:
-               edits_moved = rest_moved = 1;
+               edits_moved = 1;
                startsource += cut_length;
-               length -= cut_length;
+               cut_length = -cut_length;
+               length += cut_length;
                for( Edit *edit=next; edit; edit=edit->next )
-                       edit->startproject -= cut_length;
+                       edit->startproject += cut_length;
                break;
        case MOVE_ROLL:
+               if( prev && prev->length + cut_length < 0 )
+                       cut_length = -prev->length;
                if( prev ) prev->trim(cut_length);
                startproject += cut_length;
                startsource += cut_length;
@@ -468,6 +476,10 @@ int Edit::shift_start(int edit_mode, int64_t newposition, int64_t oldposition,
                break;
        case MOVE_SLIDE:
                edits_moved = 1;
+               if( prev && prev->length + cut_length < 0 )
+                       cut_length = -prev->length;
+               if( next && next->length - cut_length < 0 )
+                       cut_length = next->length;
                if( prev ) prev->trim(cut_length);
                startproject += cut_length;
                if( next ) {
@@ -477,7 +489,7 @@ int Edit::shift_start(int edit_mode, int64_t newposition, int64_t oldposition,
                }
                break;
        case MOVE_EDGE:
-               edits_moved = rest_moved = 1;
+               edits_moved = 1;
                startsource -= cut_length;
                length += cut_length;
                for( Edit *edit=next; edit; edit=edit->next )
@@ -485,7 +497,6 @@ int Edit::shift_start(int edit_mode, int64_t newposition, int64_t oldposition,
                break;
        }
        trim(0);
-
        return follow_edits(start, end, cut_length, edits_moved, rest_moved,
                edit_labels, edit_autos, edit_plugins, trim_edits);
 }
@@ -494,20 +505,26 @@ int Edit::shift_end(int edit_mode, int64_t newposition, int64_t oldposition,
        int edit_labels, int edit_autos, int edit_plugins, Edits *trim_edits)
 {
        int64_t cut_length = newposition - oldposition;
-       if( !cut_length ) return 0;
+       int rest_moved = edit_mode == MOVE_RIPPLE || edit_mode == MOVE_EDGE ? 1 : 0;
+       if( cut_length > length ) {
+                if( !rest_moved ) cut_length = length;
+       }
+       else if( cut_length < -length )
+               cut_length = -length;
        int64_t start = startproject, end = start + length;
        Edit *prev = this->previous, *next = this->next;
-       int edits_moved = 0, rest_moved = 0;
+       int edits_moved = 0;
 
        switch( edit_mode ) {
        case MOVE_RIPPLE:
        case MOVE_EDGE:
-               rest_moved = 1;
                length += cut_length;
                for( Edit *edit=next; edit; edit=edit->next )
                        edit->startproject += cut_length;
                break;
        case MOVE_ROLL:
+               if( next && next->length - cut_length < 0 )
+                       cut_length = next->length;
                length += cut_length;
                if( next ) {
                        next->startproject += cut_length;
@@ -521,6 +538,10 @@ int Edit::shift_end(int edit_mode, int64_t newposition, int64_t oldposition,
                break;
        case MOVE_SLIDE:
                edits_moved = 1;
+               if( prev && prev->length + cut_length < 0 )
+                       cut_length = -prev->length;
+               if( next && next->length - cut_length < 0 )
+                       cut_length = next->length;
                if( prev ) prev->trim(cut_length);
                startproject += cut_length;
                if( next ) {
@@ -531,7 +552,6 @@ int Edit::shift_end(int edit_mode, int64_t newposition, int64_t oldposition,
                break;
        }
        trim(0);
-
        return follow_edits(start, end, cut_length, edits_moved, rest_moved,
                edit_labels, edit_autos, edit_plugins, trim_edits);
 }
@@ -579,11 +599,11 @@ int Edit::follow_edits(int64_t start, int64_t end, int64_t cut_length,
                }
                if( edit_plugins ) {
                        if( cut_length > 0 ) {
-                               track->clear(end, end+cut_length, 0, 0, 1, 0, 0);
+                               track->clear(end, end+cut_length, 0, 0, -1, 0, 0);
                                track->shift_effects(start, cut_length, 1, 0);
                        }
                        else if( cut_length < 0 ) {
-                               track->clear(start+cut_length, start, 0, 0, 1, 0, 0);
+                               track->clear(start+cut_length, start, 0, 0, -1, 0, 0);
                                track->shift_effects(end+cut_length, -cut_length, 1, 0);
                        }
                }