00001 #include "clip.h" 00002 #include "labels.h" 00003 #include "recordlabel.h" 00004 00005 00006 RecordLabel::RecordLabel(double position) 00007 : ListItem<RecordLabel>() 00008 { 00009 this->position = position; 00010 } 00011 00012 RecordLabel::~RecordLabel() 00013 { 00014 } 00015 00016 00017 RecordLabels::RecordLabels() 00018 : List<RecordLabel>() 00019 { 00020 } 00021 00022 RecordLabels::~RecordLabels() 00023 { 00024 } 00025 00026 int RecordLabels::delete_new_labels() 00027 { 00028 RecordLabel *current, *next_; 00029 for(current = first; current; current = next_) 00030 { 00031 next_ = NEXT; 00032 remove(current); 00033 } 00034 return 0; 00035 } 00036 00037 int RecordLabels::toggle_label(double position) 00038 { 00039 RecordLabel *current; 00040 // find label the position is after 00041 for(current = first; 00042 current && current->position < position; 00043 current = NEXT) 00044 { 00045 ; 00046 } 00047 00048 if(current) 00049 { 00050 //printf("position %ld current->position %ld current->original %d\n", position, current->position, current->original); 00051 if(EQUIV(current->position, position)) 00052 { 00053 // remove it 00054 remove(current); 00055 } 00056 else 00057 { 00058 // insert before it 00059 insert_before(current); 00060 current->position = position; 00061 } 00062 } 00063 else 00064 { // insert after last 00065 //printf("position %ld\n", position); 00066 append(new RecordLabel(position)); 00067 } 00068 return 0; 00069 } 00070 00071 double RecordLabels::get_prev_label(double position) 00072 { 00073 RecordLabel *current; 00074 00075 for(current = last; 00076 current && current->position > position; 00077 current = PREVIOUS) 00078 { 00079 ; 00080 } 00081 //printf("%ld\n", current->position); 00082 if(current && current->position <= position) 00083 return current->position; 00084 else 00085 return -1; 00086 return 0; 00087 } 00088 00089 double RecordLabels::get_next_label(double position) 00090 { 00091 RecordLabel *current; 00092 00093 for(current = first; 00094 current && current->position <= position; 00095 current = NEXT) 00096 { 00097 ; 00098 } 00099 if(current && current->position >= position) return current->position; else return -1; 00100 return 0; 00101 } 00102 00103 double RecordLabels::goto_prev_label(double position) 00104 { 00105 RecordLabel *current; 00106 00107 for(current = last; 00108 current && current->position >= position; 00109 current = PREVIOUS) 00110 { 00111 ; 00112 } 00113 //printf("%ld\n", current->position); 00114 if(current && current->position <= position) return current->position; else return -1; 00115 return 0; 00116 } 00117 00118 double RecordLabels::goto_next_label(double position) 00119 { 00120 RecordLabel *current; 00121 00122 for(current = first; 00123 current && current->position <= position; 00124 current = NEXT) 00125 { 00126 ; 00127 } 00128 if(current && current->position >= position) return current->position; else return -1; 00129 return 0; 00130 } 00131
1.5.5