add 1:1 convert, add es.po: thx sergio, cwdw zoom tweak, add done beep pots, bd forma...
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / pluginset.C
index e46fbd326f256011a2365a08151e61543f8fd4f9..86bb4b6687290e24f3904ec637b021481f466cfc 100644 (file)
@@ -44,13 +44,6 @@ PluginSet::~PluginSet()
 }
 
 
-PluginSet& PluginSet::operator=(PluginSet& plugins)
-{
-printf("PluginSet::operator= 1\n");
-       copy_from(&plugins);
-       return *this;
-}
-
 void PluginSet::copy_from(PluginSet *src)
 {
        while(last) delete last;
@@ -59,6 +52,8 @@ void PluginSet::copy_from(PluginSet *src)
                Plugin *new_plugin;
                append(new_plugin = (Plugin*)create_edit());
                new_plugin->copy_from(current);
+// update gui_id when copying edl
+               new_plugin->gui_id = current->gui_id;
        }
        this->record = src->record;
 }
@@ -138,24 +133,15 @@ void PluginSet::synchronize_params(PluginSet *plugin_set)
 }
 
 Plugin* PluginSet::insert_plugin(const char *title,
-       int64_t unit_position,
-       int64_t unit_length,
-       int plugin_type,
-       SharedLocation *shared_location,
-       KeyFrame *default_keyframe,
+       int64_t unit_position, int64_t unit_length, int plugin_type,
+       SharedLocation *shared_location, KeyFrame *default_keyframe,
        int do_optimize)
 {
        Plugin *plugin = (Plugin*)create_silence(unit_position, unit_position + unit_length);
-       if(title) strcpy(plugin->title, title);
-       if(shared_location) plugin->shared_location = *shared_location;
-       plugin->plugin_type = plugin_type;
-
-       if(default_keyframe)
-               *plugin->keyframes->default_auto = *default_keyframe;
-       plugin->keyframes->default_auto->position = unit_position;
-
+       plugin->init(title, unit_position, unit_length, plugin_type,
+                       shared_location, default_keyframe);
 // May delete the plugin we just added so not desirable while loading.
-       if(do_optimize) optimize();
+       if( do_optimize ) optimize();
        return plugin;
 }
 
@@ -352,6 +338,19 @@ void PluginSet::shift_effects(int64_t start, int64_t length, int edit_autos)
        }
 }
 
+void PluginSet::paste_silence(int64_t start, int64_t end, int edit_autos)
+{
+       Plugin *new_plugin = (Plugin *) insert_new_edit(start);
+       int64_t length = end - start;
+       new_plugin->length = length;
+       while( (new_plugin=(Plugin *)new_plugin->next) != 0 ) {
+               new_plugin->startproject += length;
+               if( !edit_autos ) continue;
+               new_plugin->keyframes->default_auto->position += length;
+               new_plugin->keyframes->paste_silence(start, end);
+       }
+}
+
 void PluginSet::copy(int64_t start, int64_t end, FileXML *file)
 {
        file->tag.set_title("PLUGINSET");
@@ -438,6 +437,13 @@ int PluginSet::optimize()
        int result = 1;
        Plugin *current_edit;
 
+// trim plugins before position 0
+       while( first && first->startproject+first->length < 0 )
+               delete first;
+       if( first && first->startproject < 0 ) {
+               first->length += first->startproject;
+               first->startproject = 0;
+       }
 
 // Delete keyframes out of range
        for(current_edit = (Plugin*)first;
@@ -517,7 +523,7 @@ int PluginSet::optimize()
                                        source;
                                        source = (KeyFrame*)source->next) {
                                        KeyFrame *dest = new KeyFrame(edl, current_edit->keyframes);
-                                       *dest = *source;
+                                       dest->copy_from(source);
                                        current_edit->keyframes->append(dest);
                                }
                                remove(next_edit);