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
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
|
/* -*- 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 <[email protected]>,
Chris Cannam <[email protected]>,
Richard Bown <[email protected]>
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_EDITVIEW_H_
#define _RG_EDITVIEW_H_
#include "base/PropertyName.h"
#include "EditViewBase.h"
#include "gui/dialogs/TempoDialog.h"
#include <qsize.h>
#include <qstring.h>
#include <qwmatrix.h>
#include <vector>
#include "base/Event.h"
class QWidget;
class QVBoxLayout;
class QVBox;
class QPaintEvent;
class QMouseEvent;
class QCanvasItem;
class KTabWidget;
class Accidental;
namespace Rosegarden
{
class Staff;
class Segment;
class RulerScale;
class RosegardenGUIDoc;
class RosegardenCanvasView;
class PropertyControlRuler;
class Key;
class EventSelection;
class Device;
class ControlRuler;
class ControlParameter;
class ControllerEventsRuler;
class Clef;
class StandardRuler;
class ActiveItem;
class EditView : public EditViewBase
{
Q_OBJECT
public:
/**
* Create an EditView for the segments \a segments from document \a doc.
*
* \arg cols : number of columns, main column is always rightmost
*
*/
EditView(RosegardenGUIDoc *doc,
std::vector<Segment *> segments,
unsigned int cols,
QWidget *parent,
const char *name = 0);
virtual ~EditView();
/**
* "Clever" readjustment of the view size
* If the new size is larger, enlarge to that size plus a margin
* If it is smaller, only shrink if the reduction is significant
* (e.g. new size is less than 75% of the old one)
*
* @arg exact if true, then set to newSize exactly
*/
virtual void readjustViewSize(QSize newSize, bool exact = false);
/**
* Return the active item
*/
ActiveItem* activeItem() { return m_activeItem; }
/**
* Set the active item
*/
void setActiveItem(ActiveItem* i) { m_activeItem = i; }
/**
* Set the current event selection.
*
* If preview is true, sound the selection as well.
*
* If redrawNow is true, recolour the elements on the canvas;
* otherwise just line up a refresh for the next paint event.
*
* (If the selection has changed as part of a modification to a
* segment, redrawNow should be unnecessary and undesirable, as a
* paint event will occur in the next event loop following the
* command invocation anyway.)
*/
virtual void setCurrentSelection(EventSelection* s,
bool preview = false,
bool redrawNow = false) = 0;
EventSelection* getCurrentSelection()
{ return m_currentEventSelection; }
RosegardenCanvasView* getRawCanvasView() { return m_canvasView; }
virtual RosegardenCanvasView* getCanvasView();
signals:
void changeTempo(timeT, // tempo change time
tempoT, // tempo value
tempoT, // target value
TempoDialog::TempoDialogAction); // tempo action
public slots:
/**
* Called when a mouse press occurred on an active canvas item
*
* @see ActiveItem
* @see QCanvasItem#setActive
*/
virtual void slotActiveItemPressed(QMouseEvent*, QCanvasItem*);
virtual void slotSetInsertCursorPosition(timeT position) = 0;
void slotExtendSelectionBackward();
void slotExtendSelectionForward();
void slotExtendSelectionBackwardBar();
void slotExtendSelectionForwardBar();
void slotExtendSelectionBackward(bool bar);
void slotExtendSelectionForward(bool bar);
virtual void slotStepBackward(); // default is event-by-event
virtual void slotStepForward(); // default is event-by-event
void slotJumpBackward();
void slotJumpForward();
void slotJumpToStart();
void slotJumpToEnd();
void slotAddTempo();
void slotAddTimeSignature();
virtual void slotShowVelocityControlRuler();
virtual void slotShowControllerEventsRuler();
virtual void slotShowPropertyControlRuler();
// rescale
void slotHalveDurations();
void slotDoubleDurations();
void slotRescale();
// transpose
void slotTransposeUp();
void slotTransposeUpOctave();
void slotTransposeDown();
void slotTransposeDownOctave();
void slotTranspose();
void slotDiatonicTranspose();
// invert
void slotInvert();
void slotRetrograde();
void slotRetrogradeInvert();
// jog events
void slotJogLeft();
void slotJogRight();
// Control ruler actions
//
void slotInsertControlRulerItem();
void slotEraseControlRulerItem();
void slotClearControlRulerItem();
void slotStartControlLineItem();
void slotFlipForwards();
void slotFlipBackwards();
// Property ruler actions
//
void slotDrawPropertyLine();
void slotSelectAllProperties();
// add control ruler
void slotAddControlRuler(int);
void slotRemoveControlRuler(QWidget*);
protected:
virtual RulerScale* getHLayout() = 0;
QVBox* getBottomWidget() { return m_bottomBox; }
virtual void updateBottomWidgetGeometry();
virtual void paintEvent(QPaintEvent* e);
/**
* Locate the given widgets in the top bar-buttons position and
* connect up its scrolling signals.
*/
void setTopStandardRuler(StandardRuler*, QWidget *leftBox = NULL);
/**
* Locate the given widget in the bottom bar-buttons position and
* connect up its scrolling signals.
*/
void setBottomStandardRuler(StandardRuler*);
/**
* Set the 'Rewind' and 'Fast Forward' buttons in the transport
* toolbar to AutoRepeat
*/
void setRewFFwdToAutoRepeat();
/**
* Locate the given widget right above the top bar-buttons and
* connect up its scrolling signals.
* The widget has to have a slotScrollHoriz(int) slot
*/
void addRuler(QWidget*);
/**
* Add a ruler control box
*/
void addPropertyBox(QWidget*);
/**
* Make a control ruler for the given property,
*/
PropertyControlRuler* makePropertyControlRuler(PropertyName propertyName);
/**
* Make a ruler for controller events
*/
ControllerEventsRuler* makeControllerEventRuler(const ControlParameter *controller = 0);
/**
* Add control ruler
*/
void addControlRuler(ControlRuler* ruler);
/**
* Update all control rulers
*/
void updateControlRulers(bool updateHPos=false);
/**
* Set zoom factor of control rulers
*/
void setControlRulersZoom(QWMatrix);
/**
* Set current segment for control rulers
*/
void setControlRulersCurrentSegment();
/**
* Find the control ruler for the given property name
* if it's already been created, return 0 otherwise
*/
ControlRuler* findRuler(PropertyName propertyName, int &index);
/**
* Find the control ruler for the given controller
* if it's already been created, return 0 otherwise
*/
ControlRuler* findRuler(const ControlParameter& controller, int &index);
/**
* Show a control ruler for the given property
* If the ruler already exists, activate the tab it's in,
* otherwise create the ruler and add it to the control rulers tab
* widget
*/
void showPropertyControlRuler(PropertyName propertyName);
/**
* Return the control ruler currently displayed, or 0 if none exist
*/
ControlRuler* getCurrentControlRuler();
/**
* Set up those actions common to any EditView (e.g. note insertion,
* time signatures etc)
*/
void setupActions();
/**
* Set up the 'Add control ruler' sub-menu
*/
void setupAddControlRulerMenu();
/**
* Do this after any other segment setup in a subordinate view.
* Returns true if there were any tabs to set up.
*/
bool setupControllerTabs();
/**
* Create an action menu for inserting notes from the PC keyboard,
* and add it to the action collection. This is one of the methods
* called by setupActions().
*/
void createInsertPitchActionMenu();
/**
* Get a note pitch from an action name (where the action is one of
* those created by createInsertPitchActionMenu). Can throw an
* Exception to mean that the action is not an insert one. Also
* returns any specified accidental through the reference arg.
*/
int getPitchFromNoteInsertAction(QString actionName,
Accidental &acc,
const Clef &clef,
const ::Rosegarden::Key &key);
/**
* Abstract method to get the view size
* Typically implemented as canvas()->size().
*/
virtual QSize getViewSize() = 0;
/**
* Abstract method to set the view size
* Typically implemented as canvas()->resize().
*/
virtual void setViewSize(QSize) = 0;
/**
* Abstract method to get current insert-pointer time
*/
virtual timeT getInsertionTime() = 0;
/**
* Return the time at which the insert cursor may be found,
* and the time signature, clef and key at that time. Default
* implementation is okay but slow.
*/
virtual timeT getInsertionTime(Clef &clef, ::Rosegarden::Key &key);
/**
* Abstract method to get current staff (the returned staff will be
* that representing the segment of getCurrentSegment())
*/
virtual Staff *getCurrentStaff() = 0;
/**
* Return the device of the current segment, if any
*/
Device *getCurrentDevice();
virtual void setCanvasView(RosegardenCanvasView *cv);
//--------------- Data members ---------------------------------
/// The current selection of Events (for cut/copy/paste)
EventSelection* m_currentEventSelection;
ActiveItem* m_activeItem;
RosegardenCanvasView *m_canvasView;
QVBoxLayout *m_rulerBox;
QLabel *m_rulerBoxFiller;
QVBoxLayout *m_controlBox;
QVBox *m_bottomBox;
StandardRuler *m_topStandardRuler;
StandardRuler *m_bottomStandardRuler;
ControlRuler *m_controlRuler;
KTabWidget *m_controlRulers;
QWMatrix m_currentRulerZoomMatrix;
static const unsigned int RULERS_ROW;
static const unsigned int CONTROLS_ROW;
static const unsigned int TOPBARBUTTONS_ROW;
static const unsigned int CANVASVIEW_ROW;
static const unsigned int CONTROLRULER_ROW;
};
}
#endif
|