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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
|
/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
/*
Rosegarden
A MIDI and audio sequencer and musical notation editor.
This program is Copyright 2000-2008
Guillaume Laurent <glaurent@telegraph-road.org>,
Chris Cannam <cannam@all-day-breakfast.com>,
Richard Bown <richard.bown@ferventsoftware.com>
The moral rights of Guillaume Laurent, Chris Cannam, and Richard
Bown to claim authorship of this work have been asserted.
Other copyrights also apply to some parts of this work. Please
see the AUTHORS file and individual file headers for details.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version. See the file
COPYING included with this distribution for more information.
*/
#ifndef _RG_COMPOSITIONVIEW_H_
#define _RG_COMPOSITIONVIEW_H_
#include "base/Selection.h"
#include "CompositionModel.h"
#include "CompositionItem.h"
#include "gui/general/RosegardenScrollView.h"
#include <tqbrush.h>
#include <tqcolor.h>
#include <tqpen.h>
#include <tqpixmap.h>
#include <tqpoint.h>
#include <tqrect.h>
#include <tqstring.h>
#include "base/Event.h"
class TQWidget;
class TQWheelEvent;
class TQResizeEvent;
class TQPaintEvent;
class TQPainter;
class TQMouseEvent;
class TQEvent;
namespace Rosegarden
{
class SnapGrid;
class SegmentToolBox;
class SegmentTool;
class SegmentSelector;
class Segment;
class RosegardenGUIDoc;
class CompositionRect;
class CompositionView : public RosegardenScrollView
{
Q_OBJECT
TQ_OBJECT
public:
CompositionView(RosegardenGUIDoc*, CompositionModel*,
TQWidget * tqparent=0, const char* name=0, WFlags f=0);
void setPointerPos(int pos);
int getPointerPos() { return m_pointerPos; }
void setGuidesPos(int x, int y);
void setGuidesPos(const TQPoint& p);
void setDrawGuides(bool d);
TQRect getSelectionRect() const { return m_selectionRect; }
void setSelectionRectPos(const TQPoint& pos);
void setSelectionRectSize(int w, int h);
void setDrawSelectionRect(bool d);
SnapGrid& grid() { return m_model->grid(); }
CompositionItem getFirstItemAt(TQPoint pos);
SegmentToolBox* getToolBox() { return m_toolBox; }
CompositionModel* getModel() { return m_model; }
void setTmpRect(const TQRect& r);
void setTmpRect(const TQRect& r, const TQColor &c);
const TQRect& getTmpRect() const { return m_tmpRect; }
/**
* Set the snap resolution of the grid to something suitable.
*
* fineTool indicates whether the current tool is a fine-grain sort
* (such as the resize or move tools) or a coarse one (such as the
* segment creation pencil). If the user is requesting extra-fine
* resolution (through the setFineGrain method) that will also be
* taken into account.
*/
void setSnapGrain(bool fine);
/**
* Find out whether the user is requesting extra-fine resolution
* (e.g. by holding Shift key). This is seldom necessary -- most
* client code will only need to query the snap grid that is
* adjusted appropriately by the view when interactions take
* place.
*/
bool isFineGrain() const { return m_fineGrain; }
/**
* Find out whether the user is requesting to draw over an existing segment
* with the pencil, by holding the Ctrl key. This is used by the segment
* pencil to decide whether to abort or not if a user attempts to draw over
* an existing segment, and this is all necessary in order to avoid breaking
* the double-click-to-open behavior.
*/
bool pencilOverExisting() const { return m_pencilOverExisting; }
/**
* Set whether the segment items contain previews or not
*/
void setShowPreviews(bool previews) { m_showPreviews = previews; }
/**
* Return whether the segment items contain previews or not
*/
bool isShowingPreviews() { return m_showPreviews; }
/**
* clear all seg rect cache
*/
void clearSegmentRectsCache(bool clearPreviews = false);
/// Return the selected Segments if we're currently using a "Selector"
SegmentSelection getSelectedSegments();
bool haveSelection() const { return m_model->haveSelection(); }
void updateSelectionContents();
/**
* Set and hide a text float on this canvas - it can contain
* anything and can be left to timeout or you can hide it
* explicitly.
*
*/
void setTextFloat(int x, int y, const TQString &text);
void hideTextFloat() { m_drawTextFloat = false; }
void setShowSegmentLabels(bool b) { m_showSegmentLabels = b; }
void setBackgroundPixmap(const TQPixmap &m);
void endAudioPreviewGeneration();
public slots:
void scrollRight();
void scrollLeft();
void slotContentsMoving(int x, int y);
/// Set the current segment editing tool
void slotSetTool(const TQString& toolName);
// This method only operates if we're of the "Selector"
// tool type - it's called from the View to enable it
// to automatically set the selection of Segments (say
// by Track).
//
void slotSelectSegments(const SegmentSelection &segment);
// These are sent from the top level app when it gets key
// depresses relating to selection add (usually SHIFT) and
// selection copy (usually CONTROL)
//
void slotSetSelectAdd(bool value);
void slotSetSelectCopy(bool value);
void slotSetFineGrain(bool value);
void slotSetPencilOverExisting(bool value);
// Show and hige the splitting line on a Segment
//
void slotShowSplitLine(int x, int y);
void slotHideSplitLine();
void slotExternalWheelEvent(TQWheelEvent*);
// TextFloat timer
void slotTextFloatTimeout();
void slotUpdateSegmentsDrawBuffer();
void slotUpdateSegmentsDrawBuffer(const TQRect&);
void slotRefreshColourCache();
void slotNewMIDIRecordingSegment(Segment*);
void slotNewAudioRecordingSegment(Segment*);
// no longer used, see RosegardenGUIDoc::insertRecordedMidi
// void slotRecordMIDISegmentUpdated(Segment*, timeT updatedFrom);
void slotStoppedRecording();
void slotUpdateSize();
signals:
void editSegment(Segment*); // use default editor
void editSegmentNotation(Segment*);
void editSegmentMatrix(Segment*);
void editSegmentAudio(Segment*);
void editSegmentEventList(Segment*);
void audioSegmentAutoSplit(Segment*);
void editRepeat(Segment*, timeT);
void setPointerPosition(timeT);
void showContextHelp(const TQString &);
protected:
virtual bool event(TQEvent *);
virtual void contentsMousePressEvent(TQMouseEvent*);
virtual void contentsMouseReleaseEvent(TQMouseEvent*);
virtual void contentsMouseDoubleClickEvent(TQMouseEvent*);
virtual void contentsMouseMoveEvent(TQMouseEvent*);
virtual void viewportPaintEvent(TQPaintEvent*);
virtual void resizeEvent(TQResizeEvent*);
virtual void enterEvent(TQEvent *);
virtual void leaveEvent(TQEvent *);
virtual void viewportPaintRect(TQRect);
/**
* if something changed, returns true and sets rect accordingly
* sets 'scroll' if some scrolling occurred
*/
bool checkScrollAndRefreshDrawBuffer(TQRect &, bool& scroll);
void refreshSegmentsDrawBuffer(const TQRect&);
void refreshArtifactsDrawBuffer(const TQRect&);
void drawArea(TQPainter * p, const TQRect& rect);
void drawAreaAudioPreviews(TQPainter * p, const TQRect& rect);
void drawAreaArtifacts(TQPainter * p, const TQRect& rect);
void drawRect(const TQRect& rect, TQPainter * p, const TQRect& clipRect,
bool isSelected = false, int intersectLvl = 0, bool fill = true);
void drawCompRect(const CompositionRect& r, TQPainter *p, const TQRect& clipRect,
int intersectLvl = 0, bool fill = true);
void drawCompRectLabel(const CompositionRect& r, TQPainter *p, const TQRect& clipRect);
void drawIntersections(const CompositionModel::rectcontainer&, TQPainter * p, const TQRect& clipRect);
void drawPointer(TQPainter * p, const TQRect& clipRect);
void drawGuides(TQPainter * p, const TQRect& clipRect);
void drawTextFloat(TQPainter * p, const TQRect& clipRect);
void initStepSize();
void releaseCurrentItem();
static TQColor mixBrushes(TQBrush a, TQBrush b);
SegmentSelector* getSegmentSelectorTool();
protected slots:
void slotSegmentsDrawBufferNeedsRefresh() {
m_segmentsDrawBufferRefresh =
TQRect(contentsX(), contentsY(), visibleWidth(), visibleHeight());
}
void slotSegmentsDrawBufferNeedsRefresh(TQRect r) {
m_segmentsDrawBufferRefresh |=
(TQRect(contentsX(), contentsY(), visibleWidth(), visibleHeight())
& r);
}
void slotArtifactsDrawBufferNeedsRefresh() {
m_artifactsDrawBufferRefresh =
TQRect(contentsX(), contentsY(), visibleWidth(), visibleHeight());
updateContents();
}
void slotArtifactsDrawBufferNeedsRefresh(TQRect r) {
m_artifactsDrawBufferRefresh |=
(TQRect(contentsX(), contentsY(), visibleWidth(), visibleHeight())
& r);
updateContents(r);
}
void slotAllDrawBuffersNeedRefresh() {
slotSegmentsDrawBufferNeedsRefresh();
slotArtifactsDrawBufferNeedsRefresh();
}
void slotAllDrawBuffersNeedRefresh(TQRect r) {
slotSegmentsDrawBufferNeedsRefresh(r);
slotArtifactsDrawBufferNeedsRefresh(r);
}
void slotToolHelpChanged(const TQString &);
protected:
//--------------- Data members ---------------------------------
CompositionModel* m_model;
CompositionItem m_currentItem;
SegmentTool* m_tool;
SegmentToolBox* m_toolBox;
bool m_showPreviews;
bool m_showSegmentLabels;
bool m_fineGrain;
bool m_pencilOverExisting;
int m_minWidth;
int m_stepSize;
TQColor m_rectFill;
TQColor m_selectedRectFill;
int m_pointerPos;
TQColor m_pointerColor;
int m_pointerWidth;
TQPen m_pointerPen;
TQRect m_tmpRect;
TQColor m_tmpRectFill;
TQPoint m_splitLinePos;
TQColor m_trackDividerColor;
bool m_drawGuides;
TQColor m_guideColor;
int m_topGuidePos;
int m_foreGuidePos;
bool m_drawSelectionRect;
TQRect m_selectionRect;
bool m_drawTextFloat;
TQString m_textFloatText;
TQPoint m_textFloatPos;
TQPixmap m_segmentsDrawBuffer;
TQPixmap m_artifactsDrawBuffer;
TQRect m_segmentsDrawBufferRefresh;
TQRect m_artifactsDrawBufferRefresh;
int m_lastBufferRefreshX;
int m_lastBufferRefreshY;
int m_lastPointerRefreshX;
TQPixmap m_backgroundPixmap;
TQString m_toolContextHelp;
bool m_contextHelpShown;
mutable CompositionModel::AudioPreviewDrawData m_audioPreviewRects;
mutable CompositionModel::RectRanges m_notationPreviewRects;
};
}
#endif
|