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
|
//=========================================================
// MusE
// Linux Music Editor
// $Id: pcanvas.h,v 1.11.2.4 2009/05/24 21:43:44 terminator356 Exp $
// (C) Copyright 1999 Werner Schweer (ws@seh.de)
//=========================================================
#ifndef __PCANVAS_H__
#define __PCANVAS_H__
#include "song.h"
#include "canvas.h"
#include "trackautomationview.h"
class QDragMoveEvent;
class QDropEvent;
class QDragLeaveEvent;
class QMouseEvent;
class QKeyEvent;
class QEvent;
class QDragEnterEvent;
#define beats 4
//---------------------------------------------------------
// NPart
// ''visual'' Part
// wraps Parts with additional information needed
// for displaying
//---------------------------------------------------------
class NPart : public CItem {
public:
NPart(Part* e);
const QString name() const { return part()->name(); }
void setName(const QString& s) { part()->setName(s); }
Track* track() const { return part()->track(); }
};
enum ControllerVals { doNothing, movingController, addNewController };
struct AutomationObject {
CtrlVal *currentCtrl;
CtrlList *currentCtrlList;
Track *currentTrack;
bool moveController;
ControllerVals controllerState;
};
class QLineEdit;
class MidiEditor;
class QMenu;
class Xml;
class CtrlVal;
//---------------------------------------------------------
// PartCanvas
//---------------------------------------------------------
class PartCanvas : public Canvas {
Q_OBJECT
int* _raster;
TrackList* tracks;
Part* resizePart;
QLineEdit* lineEditor;
NPart* editPart;
int curColorIndex;
bool editMode;
AutomationObject automation;
//std::vector<TrackAutomationView*> automationViews;
virtual void keyPress(QKeyEvent*);
virtual void mousePress(QMouseEvent*);
virtual void mouseMove(QMouseEvent* event);
virtual void mouseRelease(const QPoint&);
virtual void viewMouseDoubleClickEvent(QMouseEvent*);
virtual void leaveEvent(QEvent*e);
virtual void drawItem(QPainter&, const CItem*, const QRect&);
virtual void drawMoving(QPainter&, const CItem*, const QRect&);
virtual void updateSelection();
virtual QPoint raster(const QPoint&) const;
virtual int y2pitch(int y) const;
virtual int pitch2y(int p) const;
virtual CItem* newItem(const QPoint&, int);
virtual void resizeItem(CItem*,bool);
virtual void newItem(CItem*,bool);
virtual bool deleteItem(CItem*);
virtual void moveCanvasItems(CItemList&, int, int, DragType, int*);
virtual bool moveItem(CItem*, const QPoint&, DragType);
virtual void updateSong(DragType, int);
virtual void startDrag(CItem*, DragType);
virtual void dragEnterEvent(QDragEnterEvent*);
virtual void dragMoveEvent(QDragMoveEvent*);
virtual void dragLeaveEvent(QDragLeaveEvent*);
virtual void viewDropEvent(QDropEvent*);
virtual QMenu* genItemPopup(CItem*);
virtual void itemPopup(CItem*, int, const QPoint&);
void glueItem(CItem* item);
void splitItem(CItem* item, const QPoint&);
void copy(PartList*);
void paste(bool clone = false, bool toTrack = true, bool doInsert=false);
int pasteAt(const QString&, Track*, unsigned int, bool clone = false, bool toTrack = true);
void movePartsTotheRight(unsigned int startTick, int length);
//Part* readClone(Xml&, Track*, bool toTrack = true);
void drawWavePart(QPainter&, const QRect&, WavePart*, const QRect&);
//void drawMidiPart(QPainter&, const QRect& rect, EventList* events, MidiTrack*mt, const QRect& r, int pTick, int from, int to);
void drawMidiPart(QPainter&, const QRect& rect, EventList* events, MidiTrack*mt, MidiPart*pt, const QRect& r, int pTick, int from, int to);
Track* y2Track(int) const;
void drawAudioTrack(QPainter& p, const QRect& r, AudioTrack* track);
void drawAutomation(QPainter& p, const QRect& r, AudioTrack* track);
void drawTopItem(QPainter& p, const QRect& rect);
void checkAutomation(Track * t, const QPoint& pointer, bool addNewCtrl);
void processAutomationMovements(QPoint pos, bool addPoint);
double dbToVal(double inDb);
double valToDb(double inV);
protected:
virtual void drawCanvas(QPainter&, const QRect&);
virtual void endMoveItems(const QPoint&, DragType, int dir);
signals:
void timeChanged(unsigned);
void tracklistChanged();
void dclickPart(Track*);
void selectionChanged();
void dropSongFile(const QString&);
void dropMidiFile(const QString&);
void setUsedTool(int);
void trackChanged(Track*);
void selectTrackAbove();
void selectTrackBelow();
void startEditor(PartList*, int);
private slots:
void returnPressed();
public:
enum { CMD_CUT_PART, CMD_COPY_PART, CMD_PASTE_PART, CMD_PASTE_CLONE_PART, CMD_PASTE_PART_TO_TRACK, CMD_PASTE_CLONE_PART_TO_TRACK,
CMD_INSERT_PART, CMD_INSERT_EMPTYMEAS };
PartCanvas(int* raster, QWidget* parent, int, int);
void partsChanged();
void cmd(int);
void controllerChanged(Track *t);
public slots:
void redirKeypress(QKeyEvent* e) { keyPress(e); }
};
#endif
|