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
|
//=============================================================================
// 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 __ECANVAS_H__
#define __ECANVAS_H__
#include "al/pos.h"
#include "awl/tcanvas.h"
#include "widgets/noteinfo.h"
#include "citem.h"
#include "ctrl/ctrledit.h"
#include "widgets/tb1.h"
class MidiTrack;
class MidiEditor;
class MidiEvent;
class Part;
class Event;
class CtrlEdit;
//---------------------------------------------------------
// EventCanvas
//---------------------------------------------------------
class EventCanvas : public TimeCanvas {
Q_OBJECT
int startPitch; // on start dragging events
int deltaPitch;
int keyDown; // pressed key on piano keypad (or drum instrument list)
int playedPitch;
void noteOn(int pitch, int velocity, bool shift);
void noteOff(int pitch);
virtual void layout();
virtual void magChanged();
protected:
enum DragMode {
DRAG_OFF, DRAG_NEW,
DRAG_MOVE_START, DRAG_MOVE,
DRAG_COPY_START, DRAG_COPY,
DRAGX_MOVE, DRAGY_MOVE,
DRAGX_COPY, DRAGY_COPY,
DRAG_DELETE,
DRAG_RESIZE, DRAG_LASSO_START, DRAG_LASSO,
};
enum DragType {
MOVE_MOVE, MOVE_COPY
};
CtrlEditList ctrlEditList;
MidiEditor* editor;
CItemList items;
CItemList moving;
CItem* curItem;
Part* curPart;
int canvasTools;
int curSplitter; // -1 mouse not in splitter
bool dragSplitter;
int splitterY;
DragMode drag;
QRect lasso;
QPoint start;
QMenu* itemPopupMenu;
QMenu* canvasPopupMenu;
unsigned startTick, endTick;
int curVelo;
virtual void mousePress(QMouseEvent*);
virtual void mouseDoubleClick(QMouseEvent*);
virtual void mouseMove(QPoint);
virtual void enterB();
virtual void leaveB();
virtual void mouseRelease(QMouseEvent*);
void layoutPanelB(CtrlEdit* c);
void updateSelection();
virtual CItem* searchItem(const QPoint& p) const = 0;
virtual void addItem(Part*, const Event&) = 0;
virtual void moveItem(CItem*, DragType) = 0;
virtual CItem* newItem(const QPoint&, int state) = 0;
virtual void newItem(CItem*, bool noSnap=false) = 0;
virtual bool deleteItem(CItem*) = 0;
virtual void resizeItem(CItem*, bool noSnap=false) = 0;
virtual void startDrag(CItem*, bool) {}
virtual QMenu* genItemPopup(CItem*) { return 0; }
virtual void itemPopup(CItem*, int, const QPoint&) {}
virtual void itemReleased() {}
virtual void itemPressed(const CItem*) {}
virtual void itemMoved(const CItem*) {}
virtual void addController();
void endMoveItems(DragType);
virtual void selectItem(CItem* e, bool);
virtual void deselectAll();
QMenu* genCanvasPopup();
void canvasPopup(int);
virtual void startUndo(DragType);
virtual void endUndo(DragType);
virtual void selectLasso(bool) {}
void setCursor();
virtual void deleteItem(const QPoint&);
void moveItems(const QPoint& pos, int dir);
void mousePressCanvasA(QPoint pos);
void mousePressCanvasA(QMouseEvent*);
void mouseMoveCanvasA(QPoint pos);
void mouseReleaseCanvasA(QMouseEvent*);
virtual void paintControllerCanvas(QPainter&, QRect);
virtual void paintControllerPanel(QPainter&, QRect);
void pasteAt(const QString& pt, unsigned pos);
void updatePartControllerList();
private slots:
void removeController(QAction*);
void midiNote(const MidiEvent&);
public slots:
void setQuant(int) { update(); }
void songChanged(int);
signals:
void selectionChanged(int, Event&, Part*);
void enterCanvas();
void yChanged(int); // emitted from mouseMove in controller canvas
public:
EventCanvas(MidiEditor*, TimeCanvasType);
MidiTrack* track() const;
Part* part() const { return curPart; }
QString getCaption() const;
void range(AL::Pos& s, AL::Pos& e) const;
void selectFirst();
virtual void modifySelected(NoteInfo::ValType, int) {}
virtual void keyPress(QKeyEvent*);
int selectionSize() const;
void setCurPart(Part*);
QMimeData* getTextDrag();
CItemList* getItems() { return &items; }
CtrlEditList* getCtrlEditors() { return &ctrlEditList; }
const CtrlEditList* getCtrlEditors() const { return &ctrlEditList; }
void addController(int id, int h);
void layout1();
};
extern void paintVLine(QPainter& p, int y1, int y2, int x);
#endif
|