Mercurial > hg > svgui
comparison widgets/LevelPanWidget.h @ 946:36cddc3de023 alignment_view
Merge from default branch
author | Chris Cannam |
---|---|
date | Mon, 20 Apr 2015 09:19:52 +0100 |
parents | 77110abca8a1 |
children | 916b62baf7ac |
comparison
equal
deleted
inserted
replaced
897:499b637f2a26 | 946:36cddc3de023 |
---|---|
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 | |
24 class LevelPanWidget : public QWidget | |
25 { | |
26 Q_OBJECT | |
27 | |
28 public: | |
29 LevelPanWidget(QWidget *parent = 0); | |
30 ~LevelPanWidget(); | |
31 | |
32 /// Return level as a gain value in the range [0,1] | |
33 float getLevel() const; | |
34 | |
35 /// Return pan as a value in the range [-1,1] | |
36 float getPan() const; | |
37 | |
38 /// Find out whether the widget is editable | |
39 bool isEditable() const; | |
40 | |
41 /// Discover whether the level range includes muting or not | |
42 bool includesMute() const; | |
43 | |
44 /// Draw a suitably sized copy of the widget's contents to the given device | |
45 void renderTo(QPaintDevice *, QRectF, bool asIfEditable) const; | |
46 | |
47 QSize sizeHint() const; | |
48 | |
49 public slots: | |
50 /// Set level in the range [0,1] -- will be rounded | |
51 void setLevel(float); | |
52 | |
53 /// Set pan in the range [-1,1] -- will be rounded | |
54 void setPan(float); | |
55 | |
56 /// Specify whether the widget is editable or read-only (default editable) | |
57 void setEditable(bool); | |
58 | |
59 /// Specify whether the level range should include muting or not | |
60 void setIncludeMute(bool); | |
61 | |
62 signals: | |
63 void levelChanged(float); | |
64 void panChanged(float); | |
65 | |
66 protected: | |
67 virtual void mousePressEvent(QMouseEvent *ev); | |
68 virtual void mouseMoveEvent(QMouseEvent *ev); | |
69 virtual void mouseReleaseEvent(QMouseEvent *ev); | |
70 virtual void wheelEvent(QWheelEvent *ev); | |
71 virtual void paintEvent(QPaintEvent *ev); | |
72 | |
73 void emitLevelChanged(); | |
74 void emitPanChanged(); | |
75 | |
76 int m_level; | |
77 int m_pan; | |
78 bool m_editable; | |
79 bool m_includeMute; | |
80 | |
81 QSizeF cellSize(QRectF) const; | |
82 QPointF cellCentre(QRectF, int level, int pan) const; | |
83 QSizeF cellLightSize(QRectF) const; | |
84 QRectF cellLightRect(QRectF, int level, int pan) const; | |
85 double thinLineWidth(QRectF) const; | |
86 void toCell(QRectF, QPointF loc, int &level, int &pan) const; | |
87 }; | |
88 | |
89 #endif |