undo nested clip bug, wheel zoom redraw fix, uninited vars, shortcuts doc
[goodguy/history.git] / cinelerra-5.1 / cinelerra / edl.C
index 13c032635ed577041b765879425189b91e8d2708..3c3de37f9aa31b93be26a2eec2dc0dee6ea37bfb 100644 (file)
@@ -298,7 +298,7 @@ int EDL::read_xml(FileXML *file, uint32_t load_flags)
                                nested_edl->create_objects();
                                nested_edl->read_xml(file, LOAD_ALL);
                                if( (load_flags & LOAD_ALL) == LOAD_ALL )
-                                       nested_edls.add_clip(nested_edl);
+                                       nested_edls.get_nested(nested_edl);
                                nested_edl->remove_user();
                        }
                        else
@@ -339,7 +339,7 @@ int EDL::read_xml(FileXML *file, uint32_t load_flags)
 // The string is not terminated in this call.
 int EDL::save_xml(FileXML *file, const char *output_path)
 {
-       copy(0, tracks->total_length(), 1, file, output_path, 0);
+       copy(1, file, output_path, 0);
        return 0;
 }
 
@@ -472,6 +472,10 @@ int EDL::copy(double start, double end, int all,
        return copy(start, end, all,
                "/EDL", file, output_path, rewind_it);
 }
+int EDL::copy(int all, FileXML *file, const char *output_path, int rewind_it)
+{
+       return copy(0, tracks->total_length(), all, file, output_path, rewind_it);
+}
 
 int EDL::copy_clip(double start, double end, int all,
        FileXML *file, const char *output_path, int rewind_it)
@@ -480,6 +484,11 @@ int EDL::copy_clip(double start, double end, int all,
        return copy(start, end, all,
                "/CLIP_EDL", file, output_path, rewind_it);
 }
+int EDL::copy_clip(int all, FileXML *file, const char *output_path, int rewind_it)
+{
+       return copy_clip(0, tracks->total_length(), all, file, output_path, rewind_it);
+}
+
 int EDL::copy_nested_edl(double start, double end, int all,
        FileXML *file, const char *output_path, int rewind_it)
 {
@@ -488,6 +497,11 @@ int EDL::copy_nested_edl(double start, double end, int all,
        return copy(start, end, all,
                "/NESTED_EDL", file, output_path, rewind_it);
 }
+int EDL::copy_nested_edl(int all, FileXML *file, const char *output_path, int rewind_it)
+{
+       return copy_nested_edl(0, tracks->total_length(), all, file, output_path, rewind_it);
+}
+
 int EDL::copy_vwindow_edl(double start, double end, int all,
        FileXML *file, const char *output_path, int rewind_it)
 {
@@ -495,6 +509,11 @@ int EDL::copy_vwindow_edl(double start, double end, int all,
        return copy(start, end, all,
                "/VWINDOW_EDL", file, output_path, rewind_it);
 }
+int EDL::copy_vwindow_edl(int all, FileXML *file, const char *output_path, int rewind_it)
+{
+       return copy_vwindow_edl(0, tracks->total_length(), all, file, output_path, rewind_it);
+}
+
 
 int EDL::copy(double start, double end, int all,
        const char *closer, FileXML *file,
@@ -538,7 +557,8 @@ int EDL::copy(double start, double end, int all,
                        file->append_newline();
                }
 
-               copy_assets(start, end, file, all, output_path);
+               if( !parent_edl )
+                       copy_assets(start, end, file, all, output_path);
 
                for( int i=0; i<nested_edls.size(); ++i )
                        nested_edls[i]->copy_nested_edl(0, tracks->total_length(), 1,
@@ -548,12 +568,10 @@ int EDL::copy(double start, double end, int all,
 // Don't want this if using clipboard
                if( all ) {
                        for( int i=0; i<total_vwindow_edls(); ++i )
-                               get_vwindow_edl(i)->copy_vwindow_edl(0, tracks->total_length(), 1,
-                                       file, output_path, 0);
+                               get_vwindow_edl(i)->copy_vwindow_edl(1, file, output_path, 0);
 
                        for( int i=0; i<clips.size(); ++i )
-                               clips[i]->copy_clip(0, tracks->total_length(), 1,
-                                       file, output_path, 0);
+                               clips[i]->copy_clip(1, file, output_path, 0);
 
                        mixers.save(file);
                }
@@ -579,21 +597,49 @@ int EDL::copy(double start, double end, int all,
        return 0;
 }
 
-int EDL::to_nested(EDL *nested_edl)
+void EDL::copy_indexables(EDL *edl)
 {
-// Keep frame rate, sample rate, and output size unchanged.
-// These parameters would revert the project if VWindow displayed an asset
-// of different size than the project.
+       for( Track *track=edl->tracks->first; track; track=track->next ) {
+               for( Edit *edit=track->edits->first; edit; edit=edit->next ) {
+                       if( edit->asset )
+                               assets->update(edit->asset);
+                       if( edit->nested_edl )
+                               nested_edls.get_nested(edit->nested_edl);
+               }
+       }
+}
+
+EDL *EDL::new_nested(EDL *edl, const char *path)
+{
+       EDL *nested = new EDL;  // no parent for nested edl
+       nested->create_objects();
+       nested->copy_session(edl);
+       nested->set_path(path);
+       nested->update_index(edl);
+       nested->copy_indexables(edl);
+       nested->tracks->copy_from(edl->tracks);
+       nested_edls.append(nested);
+       return nested;
+}
+
+EDL *EDL::create_nested_clip(EDL *nested)
+{
+       EDL *new_edl = new EDL(this);  // parent for clip edl
+       new_edl->create_objects();
+       new_edl->create_nested(nested);
+       return new_edl;
+}
 
+void EDL::create_nested(EDL *nested)
+{
+// Keep frame rate, sample rate, and output size unchanged.
 // Nest all video & audio outputs
        session->video_tracks = 1;
-       session->audio_tracks = nested_edl->session->audio_channels;
+       session->audio_tracks = nested->session->audio_channels;
        create_default_tracks();
-       insert_asset(0, nested_edl, 0, 0, 0);
-       return 0;
+       insert_asset(0, nested, 0, 0, 0);
 }
 
-
 void EDL::retrack()
 {
        int min_w = session->output_w, min_h = session->output_h;
@@ -1013,7 +1059,7 @@ void EDL::insert_asset(Asset *asset,
        EDL *new_nested_edl = 0;
 
        if( asset ) new_asset = assets->update(asset);
-       if( nested_edl ) new_nested_edl = nested_edls.get_copy(nested_edl);
+       if( nested_edl ) new_nested_edl = nested_edls.get_nested(nested_edl);
 
 // Paste video
        int vtrack = 0;