1 //=========================================================
2 //  MusE
3 //  Linux Music Editor
4 //    $Id: midieditor.h,v 1.3.2.2 2009/02/02 21:38:00 terminator356 Exp $
5 //  (C) Copyright 1999 Werner Schweer (ws@seh.de)
6 //
7 //  This program is free software; you can redistribute it and/or
8 //  modify it under the terms of the GNU General Public License
9 //  as published by the Free Software Foundation; version 2 of
10 //  the License, or (at your option) any later version.
11 //
12 //  This program is distributed in the hope that it will be useful,
13 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
14 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 //  GNU General Public License for more details.
16 //
17 //  You should have received a copy of the GNU General Public License
18 //  along with this program; if not, write to the Free Software
19 //  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20 //
21 //=========================================================
22 
23 #ifndef __MIDIEDITOR_H__
24 #define __MIDIEDITOR_H__
25 
26 #include "type_defs.h"
27 #include "cobject.h"
28 #include "ctrl/ctrledit.h"
29 #include "event_tag_list.h"
30 
31 #include <set>
32 
33 class QGridLayout;
34 class QWidget;
35 class QPoint;
36 
37 namespace MusECore {
38 class Track;
39 class Part;
40 class PartList;
41 class WavePart;
42 class Xml;
43 }
44 
45 namespace MusEGui {
46 class EventCanvas;
47 class MTScale;
48 class ScrollScale;
49 class TrackInfoWidget;
50 class RasterizerModel;
51 
52 //---------------------------------------------------------
53 //   MidiEditor
54 //---------------------------------------------------------
55 
56 class MidiEditor : public TopWin  {
57       Q_OBJECT
58 
59       MusECore::PartList* _pl;
60       std::set<int> _parts;
61       int _curDrumInstrument;  // currently selected instrument if drum
62                                // editor
63 
64    protected:
65       MusEGui::ScrollScale* hscroll;
66       MusEGui::ScrollScale* vscroll;
67       MusEGui::MTScale* time;
68       EventCanvas* canvas;
69 
70       TrackInfoWidget* trackInfoWidget;
71       MusECore::Track* selected;
72 
73       CtrlEditList ctrlEditList;
74       int _raster;
75       RasterizerModel *_rasterizerModel;
76       // The X origin that is applied to any canvases.
77       int _canvasXOrigin;
78       // The X mag minimum that is applied to any ScrollScale controls.
79       // Note that global midi division will also be taken into account.
80       int _minXMag;
81       // The X mag maximum that is applied to any ScrollScale controls.
82       int _maxXMag;
83 
84       QGridLayout* mainGrid;
85       QWidget* mainw;
86       virtual void readStatus(MusECore::Xml&);
87       virtual void writeStatus(int, MusECore::Xml&) const;
88       void writePartList(int, MusECore::Xml&) const;
89       void genPartlist();
90       void movePlayPointerToSelectedEvent();
91 
92       void genTrackInfo(TrackInfoWidget* trackInfo);
93       void switchInfo(int);
94       void trackInfoSongChange(MusECore::SongChangedStruct_t flags);
95       // Checks if track info track is valid and deletes the strip if the track is not found.
96       void checkTrackInfoTrack();
97 
98    protected slots:
99       void updateTrackInfo();
100 
101    private slots:
102       void addNewParts(const std::map< const MusECore::Part*, std::set<const MusECore::Part*> >&);
103 
104    public slots:
105       void songChanged(MusECore::SongChangedStruct_t type);
106       void setCurDrumInstrument(int instr);
107 
updateHScrollRange()108       virtual void updateHScrollRange() { };
109    signals:
110       void curDrumInstrumentChanged(int);
111 
112    public:
113       MidiEditor(ToplevelType t, int, MusECore::PartList*,
114          QWidget* parent = 0, const char* name = 0);
115       virtual ~MidiEditor();
116 
117       int rasterStep(unsigned tick) const;
118       unsigned rasterVal(unsigned v)  const;
119       unsigned rasterVal1(unsigned v) const;
120       unsigned rasterVal2(unsigned v) const;
raster()121       int raster() const           { return _raster; }
setRaster(int val)122       virtual void setRaster(int val)      { _raster = val; }
parts()123       MusECore::PartList* parts()            { return _pl;  }
parts()124       const MusECore::PartList* parts() const { return _pl;  }
curDrumInstrument()125       int curDrumInstrument() const  { return _curDrumInstrument; }
126       MusECore::Part* curCanvasPart();
127       void setCurCanvasPart(MusECore::Part*);
128       void addPart(MusECore::Part*);
129       bool itemsAreSelected() const;
130       // Appends given tag list with item objects according to options. Avoids duplicate events or clone events.
131       // Special: We 'abuse' a controller event's length, normally 0, to indicate visual item length.
132       void tagItems(MusECore::TagEventList* tag_list, const MusECore::EventTagOptionsStruct& options) const;
133       void setHScrollOffset(const int);
134 };
135 
136 } // namespace MusEGui
137 
138 #endif
139 
140