fix segv for plugin render_gui when plugin moved up/dn, opencv build fixes, opts...
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / plugin.C
index 25023190bab85b6eb8dfcbb6e08a7189cc60e6a0..e37e930f9342802d3d678bacc63efdd0482cf5c6 100644 (file)
@@ -49,6 +49,7 @@ Plugin::Plugin(EDL *edl, Track *track, const char *title)
        out = 1;
        show = 0;
        on = 1;
+       gui_id = -1;
        keyframes = new KeyFrames(edl, track);
        keyframes->create_objects();
 }
@@ -66,6 +67,7 @@ Plugin::Plugin(EDL *edl, PluginSet *plugin_set, const char *title)
        out = 1;
        show = 0;
        on = 1;
+       gui_id = -1;
        keyframes = new KeyFrames(edl, track);
        keyframes->create_objects();
 }
@@ -100,10 +102,7 @@ int Plugin::operator==(Edit& that)
 
 int Plugin::silence()
 {
-       if(plugin_type != PLUGIN_NONE)
-               return 0;
-       else
-               return 1;
+       return plugin_type == PLUGIN_NONE ? 1 : 0;
 }
 
 void Plugin::clear_keyframes(int64_t start, int64_t end)
@@ -112,7 +111,21 @@ void Plugin::clear_keyframes(int64_t start, int64_t end)
 }
 
 
-void Plugin::copy_from(Edit *edit)
+void Plugin::init(const char *title,
+       int64_t unit_position, int64_t unit_length, int plugin_type,
+       SharedLocation *shared_location, KeyFrame *default_keyframe)
+{
+       if( title ) strcpy(this->title, title);
+       if( shared_location ) this->shared_location = *shared_location;
+       this->plugin_type = plugin_type;
+       if( default_keyframe )
+               *this->keyframes->default_auto = *default_keyframe;
+       this->keyframes->default_auto->position = unit_position;
+       this->startproject = unit_position;
+       this->length = unit_length;
+}
+
+void Plugin::copy_base(Edit *edit)
 {
        Plugin *plugin = (Plugin*)edit;
 
@@ -126,11 +139,16 @@ void Plugin::copy_from(Edit *edit)
        this->out = plugin->out;
        this->show = plugin->show;
        this->on = plugin->on;
+       this->gui_id = plugin->gui_id;
 // Should reconfigure this based on where the first track is now.
        this->shared_location = plugin->shared_location;
        strcpy(this->title, plugin->title);
+}
 
-       copy_keyframes(plugin);
+void Plugin::copy_from(Edit *edit)
+{
+       copy_base(edit);
+       copy_keyframes((Plugin*)edit);
 }
 
 void Plugin::copy_keyframes(Plugin *plugin)
@@ -280,19 +298,6 @@ int Plugin::identical(Plugin *that)
                        ((KeyFrame*)that->keyframes->default_auto)));
 }
 
-int Plugin::identical_location(Plugin *that)
-{
-       if(!plugin_set || !plugin_set->track) return 0;
-       if(!that->plugin_set || !that->plugin_set->track) return 0;
-
-       if(plugin_set->track->number_of() == that->plugin_set->track->number_of() &&
-               plugin_set->get_number() == that->plugin_set->get_number() &&
-               startproject == that->startproject) return 1;
-
-       return 0;
-
-}
-
 int Plugin::keyframe_exists(KeyFrame *ptr)
 {
        for(KeyFrame *current = (KeyFrame*)keyframes->first;
@@ -579,8 +584,8 @@ void Plugin::shift(int64_t difference)
 
 void Plugin::dump(FILE *fp)
 {
-       fprintf(fp,"    PLUGIN: type=%d title=\"%s\" on=%d track=%d plugin=%d\n",
-               plugin_type, title, on, shared_location.module, shared_location.plugin);
+       fprintf(fp,"    PLUGIN: type=%d title=\"%s\" on=%d track=%d plugin=%d gui_id=%d\n",
+               plugin_type, title, on, shared_location.module, shared_location.plugin, gui_id);
        fprintf(fp,"    startproject %jd length %jd\n", startproject, length);
 
        keyframes->dump(fp);