Credit Andrew - fix vorbis audio which was scratchy and ensure aging plugin does...
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / labels.C
index 1435a985c8d88abc115a12d245387c1ec55f29cc..56105ed1d1e759c4dcda2a3a231a781174a7e57f 100644 (file)
@@ -2,6 +2,7 @@
 /*
  * CINELERRA
  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
+ * Copyright (C) 2003-2016 Cinelerra CV contributors
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -272,7 +273,9 @@ void Labels::copy_from(Labels *labels)
 
        for(Label *current = labels->first; current; current = NEXT)
        {
-               append(new Label(edl, this, current->position, current->textstr));
+               Label *new_label = new Label(edl, this, current->position, current->textstr);
+               new_label->orig_id = current->orig_id;
+               append(new_label);
        }
 }
 
@@ -460,6 +463,13 @@ Label* Labels::next_label(double position)
        return current;
 }
 
+Label* Labels::get_label(int id)
+{
+       Label *current = first;
+       while( current && current->orig_id != id ) current = NEXT;
+       return current;
+}
+
 int Labels::insert(double start, double length)
 {      // shift every label including the first one back
        Label *current;
@@ -478,22 +488,19 @@ int Labels::paste_silence(double start, double end)
        return 0;
 }
 
-int Labels::modify_handles(double oldposition, double newposition,
-               int currentend, int handle_mode, int edit_labels)
+int Labels::modify_handles(double oldposition, double newposition, int currentend)
 {
-       if( edit_labels && handle_mode == MOVE_EDGE ) {
-               if( !currentend ) {     // left handle
-                       if( newposition < oldposition )
-                               insert(oldposition, oldposition - newposition);    // shift all labels right
-                       else
-                               clear(oldposition, newposition);   // clear selection
-               }
-               else {                  // right handle
-                       if( newposition < oldposition )
-                               clear(newposition, oldposition);
-                       else
-                               insert(oldposition, newposition - oldposition);
-               }
+       if( !currentend ) {     // left handle
+               if( newposition < oldposition )
+                       insert(oldposition, oldposition - newposition);    // shift all labels right
+               else
+                       clear(oldposition, newposition);   // clear selection
+       }
+       else {                  // right handle
+               if( newposition < oldposition )
+                       clear(newposition, oldposition);
+               else
+                       insert(oldposition, newposition - oldposition);
        }
        return 0;
 }
@@ -544,6 +551,8 @@ Label* Labels::label_of(double position)
 Label::Label()
  : ListItem<Label>()
 {
+       id = EDL::next_id();
+       orig_id = id;
 }
 
 Label::Label(EDL *edl, Labels *labels, double position, const char *textstr)
@@ -553,6 +562,8 @@ Label::Label(EDL *edl, Labels *labels, double position, const char *textstr)
        this->labels = labels;
        this->position = position;
        strcpy(this->textstr, textstr ? textstr : "");
+       id = EDL::next_id();
+       orig_id = id;
 }