Chris@923
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@923
|
2
|
Chris@923
|
3 /*
|
Chris@923
|
4 Sonic Visualiser
|
Chris@923
|
5 An audio file viewer and annotation editor.
|
Chris@923
|
6 Centre for Digital Music, Queen Mary, University of London.
|
Chris@923
|
7
|
Chris@923
|
8 This program is free software; you can redistribute it and/or
|
Chris@923
|
9 modify it under the terms of the GNU General Public License as
|
Chris@923
|
10 published by the Free Software Foundation; either version 2 of the
|
Chris@923
|
11 License, or (at your option) any later version. See the file
|
Chris@923
|
12 COPYING included with this distribution for more information.
|
Chris@923
|
13 */
|
Chris@923
|
14
|
Chris@923
|
15 #ifndef LEVEL_PAN_WIDGET_H
|
Chris@923
|
16 #define LEVEL_PAN_WIDGET_H
|
Chris@923
|
17
|
Chris@923
|
18 #include <QWidget>
|
Chris@923
|
19
|
Chris@1303
|
20 #include "WheelCounter.h"
|
Chris@1303
|
21
|
Chris@923
|
22 /**
|
Chris@923
|
23 * A simple widget for coarse level and pan control.
|
Chris@923
|
24 */
|
Chris@923
|
25
|
Chris@923
|
26 class LevelPanWidget : public QWidget
|
Chris@923
|
27 {
|
Chris@923
|
28 Q_OBJECT
|
Chris@923
|
29
|
Chris@923
|
30 public:
|
Chris@923
|
31 LevelPanWidget(QWidget *parent = 0);
|
Chris@923
|
32 ~LevelPanWidget();
|
Chris@923
|
33
|
Chris@1201
|
34 /// Return level as a gain value. The basic level range is [0,1] but the
|
Chris@1201
|
35 /// gain scale may go up to 4.0
|
Chris@923
|
36 float getLevel() const;
|
Chris@923
|
37
|
Chris@923
|
38 /// Return pan as a value in the range [-1,1]
|
Chris@923
|
39 float getPan() const;
|
Chris@923
|
40
|
Chris@923
|
41 /// Find out whether the widget is editable
|
Chris@923
|
42 bool isEditable() const;
|
Chris@923
|
43
|
Chris@940
|
44 /// Discover whether the level range includes muting or not
|
Chris@940
|
45 bool includesMute() const;
|
Chris@940
|
46
|
Chris@929
|
47 /// Draw a suitably sized copy of the widget's contents to the given device
|
Chris@929
|
48 void renderTo(QPaintDevice *, QRectF, bool asIfEditable) const;
|
Chris@929
|
49
|
Chris@929
|
50 QSize sizeHint() const;
|
Chris@929
|
51
|
Chris@923
|
52 public slots:
|
Chris@1201
|
53 /// Set level. The basic level range is [0,1] but the scale may go
|
Chris@1201
|
54 /// higher. The value will be rounded.
|
Chris@923
|
55 void setLevel(float);
|
Chris@923
|
56
|
Chris@1201
|
57 /// Set pan in the range [-1,1]. The value will be rounded
|
Chris@923
|
58 void setPan(float);
|
Chris@923
|
59
|
Chris@1177
|
60 /// Set left and right peak monitoring levels in the range [0,1]
|
Chris@1177
|
61 void setMonitoringLevels(float, float);
|
Chris@1177
|
62
|
Chris@923
|
63 /// Specify whether the widget is editable or read-only (default editable)
|
Chris@923
|
64 void setEditable(bool);
|
Chris@940
|
65
|
Chris@940
|
66 /// Specify whether the level range should include muting or not
|
Chris@940
|
67 void setIncludeMute(bool);
|
Chris@1249
|
68
|
Chris@1249
|
69 /// Reset to default values
|
Chris@1249
|
70 void setToDefault();
|
Chris@923
|
71
|
Chris@1200
|
72 // public so it can be called from LevelPanToolButton (ew)
|
Chris@1200
|
73 virtual void wheelEvent(QWheelEvent *ev);
|
Chris@1200
|
74
|
Chris@923
|
75 signals:
|
Chris@1177
|
76 void levelChanged(float); // range [0,1]
|
Chris@1177
|
77 void panChanged(float); // range [-1,1]
|
Chris@923
|
78
|
Chris@1180
|
79 void mouseEntered();
|
Chris@1180
|
80 void mouseLeft();
|
Chris@1180
|
81
|
Chris@923
|
82 protected:
|
Chris@923
|
83 virtual void mousePressEvent(QMouseEvent *ev);
|
Chris@923
|
84 virtual void mouseMoveEvent(QMouseEvent *ev);
|
Chris@923
|
85 virtual void mouseReleaseEvent(QMouseEvent *ev);
|
Chris@923
|
86 virtual void paintEvent(QPaintEvent *ev);
|
Chris@1180
|
87 virtual void enterEvent(QEvent *);
|
Chris@1180
|
88 virtual void leaveEvent(QEvent *);
|
Chris@923
|
89
|
Chris@923
|
90 void emitLevelChanged();
|
Chris@923
|
91 void emitPanChanged();
|
Chris@1301
|
92
|
Chris@1301
|
93 int m_minNotch;
|
Chris@1301
|
94 int m_maxNotch;
|
Chris@1301
|
95 int m_notch;
|
Chris@923
|
96 int m_pan;
|
Chris@1177
|
97 float m_monitorLeft;
|
Chris@1177
|
98 float m_monitorRight;
|
Chris@923
|
99 bool m_editable;
|
Chris@1249
|
100 bool m_editing;
|
Chris@940
|
101 bool m_includeMute;
|
Chris@1301
|
102 bool m_includeHalfSteps;
|
Chris@1303
|
103
|
Chris@1303
|
104 WheelCounter m_wheelCounter;
|
Chris@923
|
105
|
Chris@1301
|
106 int clampNotch(int notch) const;
|
Chris@1302
|
107 int clampPan(int pan) const;
|
Chris@1177
|
108
|
Chris@1301
|
109 int audioLevelToNotch(float audioLevel) const;
|
Chris@1301
|
110 float notchToAudioLevel(int notch) const;
|
Chris@1301
|
111
|
Chris@1301
|
112 int audioPanToPan(float audioPan) const;
|
Chris@1301
|
113 float panToAudioPan(int pan) const;
|
Chris@1301
|
114
|
Chris@1301
|
115 int coordsToNotch(QRectF rect, QPointF pos) const;
|
Chris@1301
|
116 int coordsToPan(QRectF rect, QPointF pos) const;
|
Chris@1301
|
117
|
Chris@1301
|
118 QColor notchToColour(int notch) const;
|
Chris@1177
|
119
|
Chris@929
|
120 QSizeF cellSize(QRectF) const;
|
Chris@1301
|
121 QPointF cellCentre(QRectF, int row, int col) const;
|
Chris@929
|
122 QSizeF cellLightSize(QRectF) const;
|
Chris@1301
|
123 QRectF cellLightRect(QRectF, int row, int col) const;
|
Chris@1301
|
124 QRectF cellOutlineRect(QRectF, int row, int col) const;
|
Chris@929
|
125 double thinLineWidth(QRectF) const;
|
Chris@1304
|
126 double cornerRadius(QRectF) const;
|
Chris@923
|
127 };
|
Chris@923
|
128
|
Chris@923
|
129 #endif
|