Fixed initialisation of tf in file_open(). Without setting the memory to 0,
[cinelerra_cv/mob.git] / cinelerra / recordlabel.C
blobbbae8d172c9447b4839ecabf5e6535344a5b54b2
1 #include "clip.h"
2 #include "labels.h"
3 #include "recordlabel.h"
6 RecordLabel::RecordLabel(double position)
7  : ListItem<RecordLabel>()
8
9         this->position = position; 
12 RecordLabel::~RecordLabel()
17 RecordLabels::RecordLabels()
18  : List<RecordLabel>()
22 RecordLabels::~RecordLabels()
26 int RecordLabels::delete_new_labels()
28         RecordLabel *current, *next_;
29         for(current = first; current; current = next_)
30         {
31                 next_ = NEXT;
32                 remove(current);
33         } 
34         return 0;
37 int RecordLabels::toggle_label(double position)
39         RecordLabel *current;
40 // find label the position is after
41         for(current = first; 
42                 current && current->position < position; 
43                 current = NEXT)
44         {
45                 ;
46         }
48         if(current)
49         {
50 //printf("position %ld current->position %ld current->original %d\n", position, current->position,  current->original);
51                 if(EQUIV(current->position, position))
52                 {
53 // remove it
54                         remove(current);
55                 }
56                 else
57                 {
58 // insert before it
59                         insert_before(current);
60                         current->position = position;
61                 }
62         }
63         else
64         {           // insert after last
65 //printf("position %ld\n", position);
66                 append(new RecordLabel(position));
67         }
68         return 0;
71 double RecordLabels::get_prev_label(double position)
73         RecordLabel *current;
74         
75         for(current = last; 
76                 current && current->position > position; 
77                 current = PREVIOUS)
78         {
79                 ;
80         }
81 //printf("%ld\n", current->position);
82         if(current && current->position <= position)
83                 return current->position;
84         else
85                 return -1;
86         return 0;
89 double RecordLabels::get_next_label(double position)
91         RecordLabel *current;
93         for(current = first; 
94                 current && current->position <= position; 
95                 current = NEXT)
96         {
97                 ;
98         }
99         if(current && current->position >= position) return current->position; else return -1;
100         return 0;
103 double RecordLabels::goto_prev_label(double position)
105         RecordLabel *current;
106         
107         for(current = last; 
108                 current && current->position >= position; 
109                 current = PREVIOUS)
110         {
111                 ;
112         }
113 //printf("%ld\n", current->position);
114         if(current && current->position <= position) return current->position; else return -1;
115         return 0;
118 double RecordLabels::goto_next_label(double position)
120         RecordLabel *current;
122         for(current = first; 
123                 current && current->position <= position; 
124                 current = NEXT)
125         {
126                 ;
127         }
128         if(current && current->position >= position) return current->position; else return -1;
129         return 0;