add Autosave continuous backups by Andras Reuss and Andrew-R
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / autos.C
index 490094cd368837ca9610d29f864ada4c83b70231..a48afbb508531f1abc99c477dbf9a6a46f853df5 100644 (file)
@@ -265,22 +265,23 @@ int Autos::auto_exists_for_editing(double position)
 
 Auto* Autos::get_auto_at_position(double position)
 {
-       int64_t unit_position = track->to_units(position, 0);
 
-       for(Auto *current = first;
-               current;
-               current = NEXT)
-       {
-               if(edl->equivalent(current->position, unit_position))
-               {
+       for( Auto *current=first; current; current=NEXT ) {
+               double pos = track->from_units(current->position);
+               if( edl->equivalent(position, pos) )
                        return current;
-               }
        }
        return 0;
 }
 
+Auto* Autos::get_auto(int id)
+{
+       Auto *current = first;
+       while( current && current->orig_id != id ) current = NEXT;
+       return current;
+}
 
-Auto* Autos::get_auto_for_editing(double position)
+Auto* Autos::get_auto_for_editing(double position, int create)
 {
        if(position < 0) {
                position = edl->local_session->get_selectionstart(1);
@@ -288,8 +289,9 @@ Auto* Autos::get_auto_for_editing(double position)
 
        Auto *result = 0;
        get_prev_auto(track->to_units(position, 0), PLAY_FORWARD, result);
-       if( edl->session->auto_keyframes && (!result || result->is_default ||
-              !EQUIV(track->from_units(result->position), position)) ) {
+       if( create > 0 ) create = edl->session->auto_keyframes;
+       if( create && (!result || result->is_default ||
+           !EQUIV(track->from_units(result->position), position)) ) {
 //printf("Autos::get_auto_for_editing %p %p %p\n", default_auto, first, result);
                position = edl->align_to_frame(position, 0);
                result = insert_auto(track->to_units(position, 0));
@@ -382,10 +384,11 @@ Auto* Autos::insert_auto(int64_t position, Auto *templ)
 // Set curve mode
                if( !templ && result->is_floatauto() ) {
                        FloatAuto *floatauto = (FloatAuto *)result;
-                       floatauto->curve_mode =
+                       FloatAuto::t_mode new_mode =
                                edl->local_session->playback_start >= 0 &&
                                edl->local_session->playback_end < 0 ? FloatAuto::SMOOTH :
                                        (FloatAuto::t_mode) edl->local_session->floatauto_type;
+                       floatauto->change_curve_mode(new_mode, 0);
                }
        }
        else
@@ -396,17 +399,11 @@ Auto* Autos::insert_auto(int64_t position, Auto *templ)
        return result;
 }
 
-int Autos::clear_all()
+void Autos::clear_all()
 {
-       Auto *current_, *current;
-
-       for(current = first; current; current = current_)
-       {
-               current_ = NEXT;
-               remove(current);
-       }
-       append_auto();
-       return 0;
+       while( last ) delete last;
+       delete default_auto;
+       create_objects();
 }
 
 int Autos::insert(int64_t start, int64_t end)