Mercurial > hg > svgui
comparison widgets/LevelPanWidget.h @ 1324:13d9b422f7fe zoom
Merge from default branch
author | Chris Cannam |
---|---|
date | Mon, 17 Sep 2018 13:51:31 +0100 |
parents | 5db672d6de4f |
children | a18e78b9c78b |
comparison
equal
deleted
inserted
replaced
1183:57d192e26331 | 1324:13d9b422f7fe |
---|---|
15 #ifndef LEVEL_PAN_WIDGET_H | 15 #ifndef LEVEL_PAN_WIDGET_H |
16 #define LEVEL_PAN_WIDGET_H | 16 #define LEVEL_PAN_WIDGET_H |
17 | 17 |
18 #include <QWidget> | 18 #include <QWidget> |
19 | 19 |
20 #include "WheelCounter.h" | |
21 | |
20 /** | 22 /** |
21 * A simple widget for coarse level and pan control. | 23 * A simple widget for coarse level and pan control. |
22 */ | 24 */ |
23 | 25 |
24 class LevelPanWidget : public QWidget | 26 class LevelPanWidget : public QWidget |
27 | 29 |
28 public: | 30 public: |
29 LevelPanWidget(QWidget *parent = 0); | 31 LevelPanWidget(QWidget *parent = 0); |
30 ~LevelPanWidget(); | 32 ~LevelPanWidget(); |
31 | 33 |
32 /// Return level as a gain value in the range [0,1] | 34 /// Return level as a gain value. The basic level range is [0,1] but the |
35 /// gain scale may go up to 4.0 | |
33 float getLevel() const; | 36 float getLevel() const; |
34 | 37 |
35 /// Return pan as a value in the range [-1,1] | 38 /// Return pan as a value in the range [-1,1] |
36 float getPan() const; | 39 float getPan() const; |
37 | 40 |
45 void renderTo(QPaintDevice *, QRectF, bool asIfEditable) const; | 48 void renderTo(QPaintDevice *, QRectF, bool asIfEditable) const; |
46 | 49 |
47 QSize sizeHint() const; | 50 QSize sizeHint() const; |
48 | 51 |
49 public slots: | 52 public slots: |
50 /// Set level in the range [0,1] -- will be rounded | 53 /// Set level. The basic level range is [0,1] but the scale may go |
54 /// higher. The value will be rounded. | |
51 void setLevel(float); | 55 void setLevel(float); |
52 | 56 |
53 /// Set pan in the range [-1,1] -- will be rounded | 57 /// Set pan in the range [-1,1]. The value will be rounded |
54 void setPan(float); | 58 void setPan(float); |
55 | 59 |
60 /// Set left and right peak monitoring levels in the range [0,1] | |
61 void setMonitoringLevels(float, float); | |
62 | |
56 /// Specify whether the widget is editable or read-only (default editable) | 63 /// Specify whether the widget is editable or read-only (default editable) |
57 void setEditable(bool); | 64 void setEditable(bool); |
58 | 65 |
59 /// Specify whether the level range should include muting or not | 66 /// Specify whether the level range should include muting or not |
60 void setIncludeMute(bool); | 67 void setIncludeMute(bool); |
68 | |
69 /// Reset to default values | |
70 void setToDefault(); | |
71 | |
72 // public so it can be called from LevelPanToolButton (ew) | |
73 virtual void wheelEvent(QWheelEvent *ev); | |
61 | 74 |
62 signals: | 75 signals: |
63 void levelChanged(float); | 76 void levelChanged(float); // range [0,1] |
64 void panChanged(float); | 77 void panChanged(float); // range [-1,1] |
65 | 78 |
79 void mouseEntered(); | |
80 void mouseLeft(); | |
81 | |
66 protected: | 82 protected: |
67 virtual void mousePressEvent(QMouseEvent *ev); | 83 virtual void mousePressEvent(QMouseEvent *ev); |
68 virtual void mouseMoveEvent(QMouseEvent *ev); | 84 virtual void mouseMoveEvent(QMouseEvent *ev); |
69 virtual void mouseReleaseEvent(QMouseEvent *ev); | 85 virtual void mouseReleaseEvent(QMouseEvent *ev); |
70 virtual void wheelEvent(QWheelEvent *ev); | |
71 virtual void paintEvent(QPaintEvent *ev); | 86 virtual void paintEvent(QPaintEvent *ev); |
87 virtual void enterEvent(QEvent *); | |
88 virtual void leaveEvent(QEvent *); | |
72 | 89 |
73 void emitLevelChanged(); | 90 void emitLevelChanged(); |
74 void emitPanChanged(); | 91 void emitPanChanged(); |
92 | |
93 int m_minNotch; | |
94 int m_maxNotch; | |
95 int m_notch; | |
96 int m_pan; | |
97 float m_monitorLeft; | |
98 float m_monitorRight; | |
99 bool m_editable; | |
100 bool m_editing; | |
101 bool m_includeMute; | |
102 bool m_includeHalfSteps; | |
103 | |
104 WheelCounter m_wheelCounter; | |
105 | |
106 int clampNotch(int notch) const; | |
107 int clampPan(int pan) const; | |
108 | |
109 int audioLevelToNotch(float audioLevel) const; | |
110 float notchToAudioLevel(int notch) const; | |
111 | |
112 int audioPanToPan(float audioPan) const; | |
113 float panToAudioPan(int pan) const; | |
114 | |
115 int coordsToNotch(QRectF rect, QPointF pos) const; | |
116 int coordsToPan(QRectF rect, QPointF pos) const; | |
117 | |
118 QColor cellToColour(int cell) const; | |
75 | 119 |
76 int m_level; | |
77 int m_pan; | |
78 bool m_editable; | |
79 bool m_includeMute; | |
80 | |
81 QSizeF cellSize(QRectF) const; | 120 QSizeF cellSize(QRectF) const; |
82 QPointF cellCentre(QRectF, int level, int pan) const; | 121 QPointF cellCentre(QRectF, int row, int col) const; |
83 QSizeF cellLightSize(QRectF) const; | 122 QSizeF cellLightSize(QRectF) const; |
84 QRectF cellLightRect(QRectF, int level, int pan) const; | 123 QRectF cellLightRect(QRectF, int row, int col) const; |
124 QRectF cellOutlineRect(QRectF, int row, int col) const; | |
85 double thinLineWidth(QRectF) const; | 125 double thinLineWidth(QRectF) const; |
86 void toCell(QRectF, QPointF loc, int &level, int &pan) const; | 126 double cornerRadius(QRectF) const; |
87 }; | 127 }; |
88 | 128 |
89 #endif | 129 #endif |