Chris@58
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@0
|
2
|
Chris@0
|
3 /*
|
Chris@59
|
4 Sonic Visualiser
|
Chris@59
|
5 An audio file viewer and annotation editor.
|
Chris@59
|
6 Centre for Digital Music, Queen Mary, University of London.
|
Chris@0
|
7
|
Chris@59
|
8 This program is free software; you can redistribute it and/or
|
Chris@59
|
9 modify it under the terms of the GNU General Public License as
|
Chris@59
|
10 published by the Free Software Foundation; either version 2 of the
|
Chris@59
|
11 License, or (at your option) any later version. See the file
|
Chris@59
|
12 COPYING included with this distribution for more information.
|
Chris@0
|
13 */
|
Chris@0
|
14
|
Chris@0
|
15 #ifndef _AUDIO_DIAL_H_
|
Chris@0
|
16 #define _AUDIO_DIAL_H_
|
Chris@0
|
17
|
Chris@0
|
18 /**
|
Chris@0
|
19 * A rotary dial widget.
|
Chris@0
|
20 *
|
Chris@0
|
21 * Based on an original design by Thorsten Wilms.
|
Chris@0
|
22 *
|
Chris@0
|
23 * Implemented as a widget for the Rosegarden MIDI and audio sequencer
|
Chris@0
|
24 * and notation editor by Chris Cannam.
|
Chris@0
|
25 *
|
Chris@0
|
26 * Extracted into a standalone Qt3 widget by Pedro Lopez-Cabanillas
|
Chris@0
|
27 * and adapted for use in QSynth.
|
Chris@0
|
28 *
|
Chris@0
|
29 * Ported to Qt4 by Chris Cannam.
|
Chris@0
|
30 *
|
Chris@182
|
31 * This file copyright 2003-2006 Chris Cannam, copyright 2005 Pedro
|
Chris@182
|
32 * Lopez-Cabanillas, copyright 2006 Queen Mary, University of London.
|
Chris@0
|
33 *
|
Chris@0
|
34 * This program is free software; you can redistribute it and/or
|
Chris@0
|
35 * modify it under the terms of the GNU General Public License as
|
Chris@0
|
36 * published by the Free Software Foundation; either version 2 of the
|
Chris@0
|
37 * License, or (at your option) any later version. See the file
|
Chris@0
|
38 * COPYING included with this distribution for more information.
|
Chris@0
|
39 */
|
Chris@0
|
40
|
Chris@0
|
41 #include <QDial>
|
Chris@0
|
42 #include <map>
|
Chris@0
|
43
|
Chris@167
|
44 class RangeMapper;
|
Chris@167
|
45
|
Chris@0
|
46 /**
|
Chris@0
|
47 * AudioDial is a nicer-looking QDial that by default reacts to mouse
|
Chris@0
|
48 * movement on horizontal and vertical axes instead of in a radial
|
Chris@0
|
49 * motion. Move the mouse up or right to increment the value, down or
|
Chris@0
|
50 * left to decrement it. AudioDial also responds to the mouse wheel.
|
Chris@0
|
51 *
|
Chris@0
|
52 * The programming interface for this widget is compatible with QDial,
|
Chris@0
|
53 * with the addition of properties for the knob colour and meter
|
Chris@0
|
54 * colour and a boolean property mouseDial that determines whether to
|
Chris@0
|
55 * respond to radial mouse motion in the same way as QDial (the
|
Chris@0
|
56 * default is no).
|
Chris@0
|
57 */
|
Chris@0
|
58
|
Chris@0
|
59 class AudioDial : public QDial
|
Chris@0
|
60 {
|
Chris@0
|
61 Q_OBJECT
|
Chris@0
|
62 Q_PROPERTY( QColor knobColor READ getKnobColor WRITE setKnobColor )
|
Chris@0
|
63 Q_PROPERTY( QColor meterColor READ getMeterColor WRITE setMeterColor )
|
Chris@0
|
64 Q_PROPERTY( bool mouseDial READ getMouseDial WRITE setMouseDial )
|
Chris@0
|
65
|
Chris@0
|
66 public:
|
Chris@0
|
67 AudioDial(QWidget *parent = 0);
|
Chris@0
|
68 ~AudioDial();
|
Chris@0
|
69
|
Chris@0
|
70 const QColor& getKnobColor() const { return m_knobColor; }
|
Chris@0
|
71 const QColor& getMeterColor() const { return m_meterColor; }
|
Chris@0
|
72 bool getMouseDial() const { return m_mouseDial; }
|
Chris@0
|
73
|
Chris@167
|
74 void setRangeMapper(RangeMapper *mapper); // I take ownership, will delete
|
Chris@168
|
75 const RangeMapper *rangeMapper() const { return m_rangeMapper; }
|
Chris@168
|
76 float mappedValue() const;
|
Chris@167
|
77
|
Chris@168
|
78 void setShowToolTip(bool show);
|
Chris@167
|
79
|
Chris@189
|
80 signals:
|
Chris@189
|
81 void mouseEntered();
|
Chris@189
|
82 void mouseLeft();
|
Chris@189
|
83
|
Chris@0
|
84 public slots:
|
Chris@0
|
85 /**
|
Chris@0
|
86 * Set the colour of the knob. The default is to inherit the
|
Chris@0
|
87 * colour from the widget's palette.
|
Chris@0
|
88 */
|
Chris@0
|
89 void setKnobColor(const QColor &color);
|
Chris@0
|
90
|
Chris@0
|
91 /**
|
Chris@0
|
92 * Set the colour of the meter (the highlighted area around the
|
Chris@0
|
93 * knob that shows the current value). The default is to inherit
|
Chris@0
|
94 * the colour from the widget's palette.
|
Chris@0
|
95 */
|
Chris@0
|
96 void setMeterColor(const QColor &color);
|
Chris@0
|
97
|
Chris@0
|
98 /**
|
Chris@0
|
99 * Specify that the dial should respond to radial mouse movements
|
Chris@0
|
100 * in the same way as QDial.
|
Chris@0
|
101 */
|
Chris@0
|
102 void setMouseDial(bool mouseDial);
|
Chris@0
|
103
|
Chris@34
|
104 void setDefaultValue(int defaultValue);
|
Chris@34
|
105
|
Chris@177
|
106 void setMappedValue(float mappedValue);
|
Chris@177
|
107
|
Chris@0
|
108 protected:
|
Chris@0
|
109 void drawTick(QPainter &paint, float angle, int size, bool internal);
|
Chris@0
|
110 virtual void paintEvent(QPaintEvent *);
|
Chris@0
|
111
|
Chris@0
|
112 // Alternate mouse behavior event handlers.
|
Chris@0
|
113 virtual void mousePressEvent(QMouseEvent *pMouseEvent);
|
Chris@0
|
114 virtual void mouseMoveEvent(QMouseEvent *pMouseEvent);
|
Chris@0
|
115 virtual void mouseReleaseEvent(QMouseEvent *pMouseEvent);
|
Chris@34
|
116 virtual void mouseDoubleClickEvent(QMouseEvent *pMouseEvent);
|
Chris@189
|
117 virtual void enterEvent(QEvent *);
|
Chris@189
|
118 virtual void leaveEvent(QEvent *);
|
Chris@0
|
119
|
Chris@168
|
120 protected slots:
|
Chris@168
|
121 void updateMappedValue(int value);
|
Chris@168
|
122
|
Chris@0
|
123 private:
|
Chris@0
|
124 QColor m_knobColor;
|
Chris@0
|
125 QColor m_meterColor;
|
Chris@0
|
126
|
Chris@34
|
127 int m_defaultValue;
|
Chris@168
|
128 float m_mappedValue;
|
Chris@168
|
129 bool m_noMappedUpdate;
|
Chris@34
|
130
|
Chris@0
|
131 // Alternate mouse behavior tracking.
|
Chris@0
|
132 bool m_mouseDial;
|
Chris@0
|
133 bool m_mousePressed;
|
Chris@0
|
134 QPoint m_posMouse;
|
Chris@167
|
135
|
Chris@168
|
136 bool m_showTooltip;
|
Chris@168
|
137
|
Chris@167
|
138 RangeMapper *m_rangeMapper;
|
Chris@0
|
139 };
|
Chris@0
|
140
|
Chris@0
|
141
|
Chris@0
|
142 #endif // __AudioDial_h
|
Chris@0
|
143
|
Chris@0
|
144 // end of AudioDial.h
|