Chris@127
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@127
|
2
|
Chris@127
|
3 /*
|
Chris@127
|
4 Sonic Visualiser
|
Chris@127
|
5 An audio file viewer and annotation editor.
|
Chris@127
|
6 Centre for Digital Music, Queen Mary, University of London.
|
Chris@182
|
7 This file copyright 2006 Chris Cannam and QMUL.
|
Chris@127
|
8
|
Chris@127
|
9 This program is free software; you can redistribute it and/or
|
Chris@127
|
10 modify it under the terms of the GNU General Public License as
|
Chris@127
|
11 published by the Free Software Foundation; either version 2 of the
|
Chris@127
|
12 License, or (at your option) any later version. See the file
|
Chris@127
|
13 COPYING included with this distribution for more information.
|
Chris@127
|
14 */
|
Chris@127
|
15
|
Chris@127
|
16 #ifndef _PANE_H_
|
Chris@127
|
17 #define _PANE_H_
|
Chris@127
|
18
|
Chris@127
|
19 #include <QFrame>
|
Chris@127
|
20 #include <QPoint>
|
Chris@127
|
21
|
Chris@127
|
22 #include "base/ZoomConstraint.h"
|
Chris@128
|
23 #include "View.h"
|
Chris@127
|
24 #include "base/Selection.h"
|
Chris@127
|
25
|
Chris@127
|
26 class QWidget;
|
Chris@127
|
27 class QPaintEvent;
|
Chris@127
|
28 class Layer;
|
Chris@133
|
29 class Thumbwheel;
|
Chris@172
|
30 class Panner;
|
Chris@189
|
31 class NotifyingPushButton;
|
Chris@282
|
32 class KeyReference;
|
Chris@127
|
33
|
Chris@127
|
34 class Pane : public View
|
Chris@127
|
35 {
|
Chris@127
|
36 Q_OBJECT
|
Chris@127
|
37
|
Chris@127
|
38 public:
|
Chris@127
|
39 Pane(QWidget *parent = 0);
|
Chris@127
|
40 virtual QString getPropertyContainerIconName() const { return "pane"; }
|
Chris@127
|
41
|
Chris@127
|
42 virtual bool shouldIlluminateLocalFeatures(const Layer *layer,
|
Chris@127
|
43 QPoint &pos) const;
|
Chris@127
|
44 virtual bool shouldIlluminateLocalSelection(QPoint &pos,
|
Chris@127
|
45 bool &closeToLeft,
|
Chris@127
|
46 bool &closeToRight) const;
|
Chris@127
|
47
|
Chris@127
|
48 void setCentreLineVisible(bool visible);
|
Chris@127
|
49 bool getCentreLineVisible() const { return m_centreLineVisible; }
|
Chris@127
|
50
|
Chris@806
|
51 virtual int getFirstVisibleFrame() const;
|
Chris@222
|
52
|
Chris@806
|
53 virtual int getVerticalScaleWidth() const;
|
Chris@276
|
54
|
Chris@806
|
55 virtual QImage *toNewImage(int f0, int f1);
|
Chris@229
|
56 virtual QImage *toNewImage() { return View::toNewImage(); }
|
Chris@806
|
57 virtual QSize getImageSize(int f0, int f1);
|
Chris@229
|
58 virtual QSize getImageSize() { return View::getImageSize(); }
|
Chris@227
|
59
|
Chris@316
|
60 virtual void toXml(QTextStream &stream, QString indent = "",
|
Chris@316
|
61 QString extraAttributes = "") const;
|
Chris@127
|
62
|
Chris@282
|
63 static void registerShortcuts(KeyReference &kr);
|
Chris@282
|
64
|
Chris@127
|
65 signals:
|
Chris@127
|
66 void paneInteractedWith();
|
Chris@127
|
67 void rightButtonMenuRequested(QPoint position);
|
Chris@312
|
68 void dropAccepted(QStringList uriList);
|
Chris@312
|
69 void dropAccepted(QString text);
|
Chris@806
|
70 void doubleClickSelectInvoked(int frame);
|
Chris@730
|
71 void regionOutlined(QRect rect);
|
Chris@127
|
72
|
Chris@127
|
73 public slots:
|
Chris@127
|
74 virtual void toolModeChanged();
|
Chris@133
|
75 virtual void zoomWheelsEnabledChanged();
|
Chris@806
|
76 virtual void viewZoomLevelChanged(View *v, int z, bool locked);
|
Chris@320
|
77 virtual void modelAlignmentCompletionChanged();
|
Chris@127
|
78
|
Chris@132
|
79 virtual void horizontalThumbwheelMoved(int value);
|
Chris@132
|
80 virtual void verticalThumbwheelMoved(int value);
|
Chris@133
|
81 virtual void verticalZoomChanged();
|
Chris@174
|
82 virtual void verticalPannerMoved(float x, float y, float w, float h);
|
Chris@188
|
83 virtual void editVerticalPannerExtents();
|
Chris@133
|
84
|
Chris@437
|
85 virtual void layerParametersChanged();
|
Chris@437
|
86
|
Chris@133
|
87 virtual void propertyContainerSelected(View *, PropertyContainer *pc);
|
Chris@132
|
88
|
Chris@730
|
89 void zoomToRegion(QRect r);
|
Chris@730
|
90
|
Chris@189
|
91 void mouseEnteredWidget();
|
Chris@189
|
92 void mouseLeftWidget();
|
Chris@189
|
93
|
Chris@802
|
94 protected slots:
|
Chris@802
|
95 void playbackScheduleTimerElapsed();
|
Chris@802
|
96
|
Chris@127
|
97 protected:
|
Chris@127
|
98 virtual void paintEvent(QPaintEvent *e);
|
Chris@127
|
99 virtual void mousePressEvent(QMouseEvent *e);
|
Chris@127
|
100 virtual void mouseReleaseEvent(QMouseEvent *e);
|
Chris@127
|
101 virtual void mouseMoveEvent(QMouseEvent *e);
|
Chris@127
|
102 virtual void mouseDoubleClickEvent(QMouseEvent *e);
|
Chris@290
|
103 virtual void enterEvent(QEvent *e);
|
Chris@127
|
104 virtual void leaveEvent(QEvent *e);
|
Chris@127
|
105 virtual void wheelEvent(QWheelEvent *e);
|
Chris@133
|
106 virtual void resizeEvent(QResizeEvent *e);
|
Chris@312
|
107 virtual void dragEnterEvent(QDragEnterEvent *e);
|
Chris@312
|
108 virtual void dropEvent(QDropEvent *e);
|
Chris@127
|
109
|
Chris@261
|
110 void drawVerticalScale(QRect r, Layer *, QPainter &);
|
Chris@261
|
111 void drawFeatureDescription(Layer *, QPainter &);
|
Chris@277
|
112 void drawCentreLine(int, QPainter &, bool omitLine);
|
Chris@759
|
113 void drawModelTimeExtents(QRect, QPainter &, const Model *);
|
Chris@261
|
114 void drawDurationAndRate(QRect, const Model *, int, QPainter &);
|
Chris@326
|
115 void drawWorkTitle(QRect, QPainter &, const Model *);
|
Chris@261
|
116 void drawLayerNames(QRect, QPainter &);
|
Chris@261
|
117 void drawEditingSelection(QPainter &);
|
Chris@326
|
118 void drawAlignmentStatus(QRect, QPainter &, const Model *, bool down);
|
Chris@261
|
119
|
Chris@806
|
120 virtual bool render(QPainter &paint, int x0, int f0, int f1);
|
Chris@229
|
121
|
Chris@127
|
122 Selection getSelectionAt(int x, bool &closeToLeft, bool &closeToRight) const;
|
Chris@127
|
123
|
Chris@127
|
124 bool editSelectionStart(QMouseEvent *e);
|
Chris@127
|
125 bool editSelectionDrag(QMouseEvent *e);
|
Chris@127
|
126 bool editSelectionEnd(QMouseEvent *e);
|
Chris@127
|
127 bool selectionIsBeingEdited() const;
|
Chris@127
|
128
|
Chris@133
|
129 void updateHeadsUpDisplay();
|
Chris@174
|
130 void updateVerticalPanner();
|
Chris@174
|
131
|
Chris@174
|
132 bool canTopLayerMoveVertical();
|
Chris@174
|
133 bool getTopLayerDisplayExtents(float &valueMin, float &valueMax,
|
Chris@188
|
134 float &displayMin, float &displayMax,
|
Chris@188
|
135 QString *unit = 0);
|
Chris@174
|
136 bool setTopLayerDisplayExtents(float displayMin, float displayMax);
|
Chris@174
|
137
|
Chris@174
|
138 void dragTopLayer(QMouseEvent *e);
|
Chris@174
|
139 void dragExtendSelection(QMouseEvent *e);
|
Chris@189
|
140 void updateContextHelp(const QPoint *pos);
|
Chris@259
|
141 void edgeScrollMaybe(int x);
|
Chris@133
|
142
|
Chris@753
|
143 Layer *getTopFlexiNoteLayer();
|
Chris@753
|
144
|
Chris@802
|
145 void schedulePlaybackFrameMove(int frame);
|
Chris@802
|
146
|
Chris@127
|
147 bool m_identifyFeatures;
|
Chris@127
|
148 QPoint m_identifyPoint;
|
Chris@127
|
149 QPoint m_clickPos;
|
Chris@127
|
150 QPoint m_mousePos;
|
Chris@127
|
151 bool m_clickedInRange;
|
Chris@127
|
152 bool m_shiftPressed;
|
Chris@127
|
153 bool m_ctrlPressed;
|
Chris@510
|
154 bool m_altPressed;
|
Chris@266
|
155
|
Chris@127
|
156 bool m_navigating;
|
Chris@127
|
157 bool m_resizing;
|
Chris@343
|
158 bool m_editing;
|
Chris@343
|
159 bool m_releasing;
|
Chris@806
|
160 int m_dragCentreFrame;
|
Chris@136
|
161 float m_dragStartMinValue;
|
Chris@127
|
162 bool m_centreLineVisible;
|
Chris@806
|
163 int m_selectionStartFrame;
|
Chris@127
|
164 Selection m_editingSelection;
|
Chris@127
|
165 int m_editingSelectionEdge;
|
Chris@222
|
166 mutable int m_scaleWidth;
|
Chris@133
|
167
|
Chris@150
|
168 enum DragMode {
|
Chris@150
|
169 UnresolvedDrag,
|
Chris@150
|
170 VerticalDrag,
|
Chris@150
|
171 HorizontalDrag,
|
Chris@150
|
172 FreeDrag
|
Chris@150
|
173 };
|
Chris@150
|
174 DragMode m_dragMode;
|
Chris@150
|
175
|
Chris@343
|
176 DragMode updateDragMode(DragMode currentMode,
|
Chris@343
|
177 QPoint origin,
|
Chris@343
|
178 QPoint currentPoint,
|
Chris@343
|
179 bool canMoveHorizontal,
|
Chris@343
|
180 bool canMoveVertical,
|
Chris@343
|
181 bool resistHorizontal,
|
Chris@343
|
182 bool resistVertical);
|
Chris@343
|
183
|
Chris@133
|
184 QWidget *m_headsUpDisplay;
|
Chris@172
|
185 Panner *m_vpan;
|
Chris@133
|
186 Thumbwheel *m_hthumb;
|
Chris@133
|
187 Thumbwheel *m_vthumb;
|
Chris@189
|
188 NotifyingPushButton *m_reset;
|
Chris@262
|
189
|
Chris@290
|
190 bool m_mouseInWidget;
|
Chris@290
|
191
|
Chris@802
|
192 bool m_playbackFrameMoveScheduled;
|
Chris@802
|
193 int m_playbackFrameMoveTo;
|
Chris@802
|
194
|
Chris@267
|
195 static QCursor *m_measureCursor1;
|
Chris@267
|
196 static QCursor *m_measureCursor2;
|
Chris@127
|
197 };
|
Chris@127
|
198
|
Chris@127
|
199 #endif
|
Chris@127
|
200
|