comparison widgets/LevelPanWidget.h @ 923:2a9f1eb6e0ed tonioni

Try adding a combined simple level/pan widget
author Chris Cannam
date Tue, 24 Mar 2015 14:40:31 +0000
parents
children 20698aa6a517
comparison
equal deleted inserted replaced
922:26da827e8fb5 923:2a9f1eb6e0ed
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 /**
21 * A simple widget for coarse level and pan control.
22 *
23 * For this initial implementation at least, pan is in five steps only
24 * (hard left, mid-left, centre, mid-right, hard right) and level is
25 * in five plus mute.
26 */
27
28 class LevelPanWidget : public QWidget
29 {
30 Q_OBJECT
31
32 public:
33 LevelPanWidget(QWidget *parent = 0);
34 ~LevelPanWidget();
35
36 /// Return level as a gain value in the range [0,1]
37 float getLevel() const;
38
39 /// Return pan as a value in the range [-1,1]
40 float getPan() const;
41
42 /// Find out whether the widget is editable
43 bool isEditable() const;
44
45 public slots:
46 /// Set level in the range [0,1] -- will be rounded
47 void setLevel(float);
48
49 /// Set pan in the range [-1,1] -- will be rounded
50 void setPan(float);
51
52 /// Specify whether the widget is editable or read-only (default editable)
53 void setEditable(bool);
54
55 signals:
56 void levelChanged(float);
57 void panChanged(float);
58
59 protected:
60 virtual void mousePressEvent(QMouseEvent *ev);
61 virtual void mouseMoveEvent(QMouseEvent *ev);
62 virtual void mouseReleaseEvent(QMouseEvent *ev);
63 virtual void wheelEvent(QWheelEvent *ev);
64 virtual void paintEvent(QPaintEvent *ev);
65
66 void emitLevelChanged();
67 void emitPanChanged();
68
69 int m_level;
70 int m_pan;
71 bool m_editable;
72
73 QSizeF cellSize() const;
74 QPointF cellCentre(int level, int pan) const;
75 QSizeF cellLightSize() const;
76 QRectF cellLightRect(int level, int pan) const;
77 double thinLineWidth() const;
78 void toCell(QPointF loc, int &level, int &pan) const;
79 };
80
81 #endif