LevelPanWidget.h
Go to the documentation of this file.
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2 
3 /*
4  Sonic Visualiser
5  An audio file viewer and annotation editor.
6  Centre for Digital Music, Queen Mary, University of London.
7 
8  This program is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License as
10  published by the Free Software Foundation; either version 2 of the
11  License, or (at your option) any later version. See the file
12  COPYING included with this distribution for more information.
13 */
14 
15 #ifndef LEVEL_PAN_WIDGET_H
16 #define LEVEL_PAN_WIDGET_H
17 
18 #include <QWidget>
19 
20 #include "WheelCounter.h"
21 
26 class LevelPanWidget : public QWidget
27 {
28  Q_OBJECT
29 
30 public:
31  LevelPanWidget(QWidget *parent = 0);
33 
36  float getLevel() const;
37 
39  float getPan() const;
40 
42  bool isEditable() const;
43 
45  bool includesMute() const;
46 
48  void renderTo(QPaintDevice *, QRectF, bool asIfEditable) const;
49 
50  QSize sizeHint() const override;
51 
52 public slots:
55  void setLevel(float);
56 
58  void setPan(float);
59 
61  void setMonitoringLevels(float, float);
62 
64  void setEditable(bool);
65 
67  void setIncludeMute(bool);
68 
70  void setToDefault();
71 
72  // public so it can be called from LevelPanToolButton (ew)
73  void wheelEvent(QWheelEvent *ev) override;
74 
75 signals:
76  void levelChanged(float); // range [0,1]
77  void panChanged(float); // range [-1,1]
78 
79  void mouseEntered();
80  void mouseLeft();
81 
82 protected:
83  void mousePressEvent(QMouseEvent *ev) override;
84  void mouseMoveEvent(QMouseEvent *ev) override;
85  void mouseReleaseEvent(QMouseEvent *ev) override;
86  void paintEvent(QPaintEvent *ev) override;
87  void enterEvent(QEvent *) override;
88  void leaveEvent(QEvent *) override;
89 
90  void emitLevelChanged();
91  void emitPanChanged();
92 
95  int m_notch;
96  int m_pan;
99  bool m_editable;
100  bool m_editing;
103 
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;
119 
120  QSizeF cellSize(QRectF) const;
121  QPointF cellCentre(QRectF, int row, int col) const;
122  QSizeF cellLightSize(QRectF) const;
123  QRectF cellLightRect(QRectF, int row, int col) const;
124  QRectF cellOutlineRect(QRectF, int row, int col) const;
125  double thinLineWidth(QRectF) const;
126  double cornerRadius(QRectF) const;
127 };
128 
129 #endif
int clampPan(int pan) const
int clampNotch(int notch) const
QRectF cellOutlineRect(QRectF, int row, int col) const
void setLevel(float)
Set level.
void setPan(float)
Set pan in the range [-1,1]. The value will be rounded.
QPointF cellCentre(QRectF, int row, int col) const
QSizeF cellSize(QRectF) const
int coordsToNotch(QRectF rect, QPointF pos) const
void enterEvent(QEvent *) override
QRectF cellLightRect(QRectF, int row, int col) const
void mouseMoveEvent(QMouseEvent *ev) override
float panToAudioPan(int pan) const
void levelChanged(float)
void setIncludeMute(bool)
Specify whether the level range should include muting or not.
void mousePressEvent(QMouseEvent *ev) override
int audioLevelToNotch(float audioLevel) const
void setEditable(bool)
Specify whether the widget is editable or read-only (default editable)
double thinLineWidth(QRectF) const
void renderTo(QPaintDevice *, QRectF, bool asIfEditable) const
Draw a suitably sized copy of the widget&#39;s contents to the given device.
void mouseReleaseEvent(QMouseEvent *ev) override
void leaveEvent(QEvent *) override
QSize sizeHint() const override
Manage the little bit of tedious book-keeping associated with translating vertical wheel events into ...
Definition: WheelCounter.h:24
void wheelEvent(QWheelEvent *ev) override
void setMonitoringLevels(float, float)
Set left and right peak monitoring levels in the range [0,1].
void panChanged(float)
float notchToAudioLevel(int notch) const
LevelPanWidget(QWidget *parent=0)
WheelCounter m_wheelCounter
void mouseEntered()
float getPan() const
Return pan as a value in the range [-1,1].
bool isEditable() const
Find out whether the widget is editable.
int coordsToPan(QRectF rect, QPointF pos) const
void paintEvent(QPaintEvent *ev) override
double cornerRadius(QRectF) const
A simple widget for coarse level and pan control.
bool includesMute() const
Discover whether the level range includes muting or not.
QColor cellToColour(int cell) const
void setToDefault()
Reset to default values.
float getLevel() const
Return level as a gain value.
QSizeF cellLightSize(QRectF) const
int audioPanToPan(float audioPan) const