1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
|
/**********************************************************************
Audacity: A Digital Audio Editor
Track.h
Dominic Mazzoni
**********************************************************************/
#ifndef __AUDACITY_TRACK__
#define __AUDACITY_TRACK__
class wxString;
class wxTextFile;
class DirManager;
class VTrack {
public:
int collapsedHeight;
int expandedHeight;
wxString name;
bool selected;
bool linked;
bool mute;
bool solo;
int channel;
double tOffset;
int dirty;
DirManager *dirManager;
enum {
LeftChannel,
RightChannel,
MonoChannel
};
enum {
None,
Wave,
Note,
Label
} TrackKindEnum;
VTrack(DirManager * projDirManager);
virtual ~ VTrack() {
} virtual VTrack *Duplicate();
virtual void Cut(double t0, double t1, VTrack ** dest) {
dest = 0;
}
virtual void Copy(double t0, double t1, VTrack ** dest) {
dest = 0;
}
virtual void Paste(double t, VTrack * src) {}
virtual void Clear(double t0, double t1) {}
virtual void Silence(double t0, double t1) {}
virtual void InsertSilence(double t, double len) {}
virtual void SetHeight(int h);
virtual void Collapse();
virtual void Expand();
virtual void Toggle();
virtual bool IsCollapsed();
virtual void Offset(double t) {
tOffset += t;
}
virtual int GetKind() {
return None;
}
virtual int GetChannel() {
return MonoChannel;
}
virtual bool Load(wxTextFile * in, DirManager * dirManager);
virtual bool Save(wxTextFile * out, bool overwrite);
virtual int GetHeight() {
return (collapsed ? collapsedHeight : expandedHeight);
}
virtual double GetMaxLen() {
return 0.0;
}
private:
bool collapsed;
};
/*
TrackList is a flat linked list of tracks supporting Add,
Remove, Clear, and Contains, plus serialization of the
list of tracks.
*/
struct TrackListNode {
VTrack *t;
TrackListNode *next;
TrackListNode *prev;
};
class TrackList;
class TrackListIterator {
public:
TrackListIterator(TrackList * l);
// Iterate functions
VTrack *First();
VTrack *Next();
VTrack *RemoveCurrent(); // returns next
private:
TrackList * l;
TrackListNode *cur;
};
class TrackList {
public:
// Create an empty TrackList
TrackList();
// Copy constructor
TrackList(TrackList * t);
// Destructor
~TrackList();
friend class TrackListIterator;
// Add a this Track or all children of this TrackGroup
void Add(VTrack * t);
// Remove this Track or all children of this TrackGroup
void Remove(VTrack * t);
// Make the list empty
void Clear(bool deleteTracks = false);
// Select a track, and if it is linked to another track,
// select it, too.
void Select(VTrack * t, bool selected = true);
// If this track is linked to another track (the track
// immediately before or after it), return its partner.
// Otherwise return null.
VTrack *GetLink(VTrack * t);
VTrack *GetPrev(VTrack * t);
VTrack *GetNext(VTrack * t);
bool CanMoveUp(VTrack * t);
bool CanMoveDown(VTrack * t);
bool MoveUp(VTrack * t);
bool MoveDown(VTrack * t);
// Test
bool Contains(VTrack * t);
bool IsEmpty();
double GetMaxLen();
double GetMinOffset();
int GetHeight();
// File I/O
virtual bool Load(wxTextFile * in, DirManager * dirManager);
virtual bool Save(wxTextFile * out, bool overwrite);
private:
void Swap(TrackListNode * s1, TrackListNode * s2);
TrackListNode *head;
TrackListNode *tail;
};
#endif
|