summaryrefslogtreecommitdiff
path: root/muse_qt4_evolution/muse/part.h
blob: fd5fdd52503545bbc141e8771cf323de422ddbd7 (plain)
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
//=============================================================================
//  MusE
//  Linux Music Editor
//  $Id:$
//
//  Copyright (C) 2002-2006 by Werner Schweer and others
//
//  This program is free software; you can redistribute it and/or modify
//  it under the terms of the GNU General Public License version 2.
//
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
//
//  You should have received a copy of the GNU General Public License
//  along with this program; if not, write to the Free Software
//  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================

#ifndef __PART_H__
#define __PART_H__

#include "event.h"

class Track;
class MidiTrack;
class WaveTrack;

namespace AL {
      class Xml;
      };

using AL::Xml;

//---------------------------------------------------------
//   ClonePart
//---------------------------------------------------------

struct ClonePart {
      EventList* el;
      int id;
      ClonePart(EventList* e, int i) : el(e), id(i) {}
      };

typedef std::list<ClonePart> CloneList;
typedef CloneList::iterator iClone;
extern CloneList cloneList;

//---------------------------------------------------------
//   CtrlCanvas
//---------------------------------------------------------

struct CtrlCanvas {
	int ctrlId;
	int height;
      };

typedef std::list<CtrlCanvas> CtrlCanvasList;
typedef CtrlCanvasList::iterator iCtrlCanvas;
typedef CtrlCanvasList::const_iterator ciCtrlCanvas;

//---------------------------------------------------------
//   Part
//---------------------------------------------------------

class Part : public AL::PosLen {
      QString _name;
      bool _selected;
      bool _mute;
      int _colorIndex;

      // editor presets:
      int _raster, _quant;
      double _xmag;
      CtrlCanvasList ctrlCanvasList;

      // auto fill:
      int _fillLen;	// = 0 if no auto fill

   protected:
      Track* _track;
      EventList* _events;

   public:
      Part(Track*);

      CtrlCanvasList* getCtrlCanvasList() { return &ctrlCanvasList; }

      const QString& name() const      { return _name; }
      void setName(const QString& s)   { _name = s; }

      bool selected() const            { return _selected; }
      void setSelected(bool f)         { _selected = f; }

      bool mute() const                { return _mute; }
      void setMute(bool b)             { _mute = b; }

      Track* track() const             { return _track; }
      void setTrack(Track*t)           { _track = t; }

      int colorIndex() const           { return _colorIndex; }
      void setColorIndex(int idx)      { _colorIndex = idx; }

      int raster() const               { return _raster; }
      void setRaster(int val)          { _raster = val;  }

      int quant() const                { return _quant;  }
      void setQuant(int val)           { _quant = val;   }

      double xmag() const              { return _xmag;   }
      void setXmag(double val)         { _xmag = val;    }

      EventList* events() const        { return _events; }

      void clone(EventList* e);
      iEvent addEvent(Event& p);
      iEvent addEvent(Event& p, unsigned);

      int fillLen() const              { return _fillLen; }
      void setFillLen(int val)         { _fillLen = val;  }

      void read(QDomNode, bool isMidiPart);
      void write(Xml&);
      void dump(int n = 0) const;

      bool isClone() const;
      void deref();
      void ref();
      };

//---------------------------------------------------------
//   PartList
//---------------------------------------------------------

typedef std::multimap<unsigned, Part*, std::less<unsigned> > PL;
typedef PL::iterator iPart;
typedef PL::const_iterator ciPart;

class PartList : public PL {
   public:
      Part* findPart(unsigned tick);
      iPart add(Part*);
      void remove(Part* part);
      int index(Part*);
      Part* find(int idx);
      };

extern const char* partColorNames[];
#endif