Mercurial > hg > svgui
comparison widgets/AudioDial.h @ 0:2a4f26e85b4c
initial import
author | Chris Cannam |
---|---|
date | Tue, 10 Jan 2006 16:33:16 +0000 |
parents | |
children | 37b110168acf |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:2a4f26e85b4c |
---|---|
1 /* -*- c-basic-offset: 4 -*- vi:set ts=8 sts=4 sw=4: */ | |
2 | |
3 /* | |
4 A waveform viewer and audio annotation editor. | |
5 Chris Cannam, Queen Mary University of London, 2005 | |
6 | |
7 This is experimental software. Not for distribution. | |
8 */ | |
9 | |
10 #ifndef _AUDIO_DIAL_H_ | |
11 #define _AUDIO_DIAL_H_ | |
12 | |
13 /** | |
14 * A rotary dial widget. | |
15 * | |
16 * Based on an original design by Thorsten Wilms. | |
17 * | |
18 * Implemented as a widget for the Rosegarden MIDI and audio sequencer | |
19 * and notation editor by Chris Cannam. | |
20 * | |
21 * Extracted into a standalone Qt3 widget by Pedro Lopez-Cabanillas | |
22 * and adapted for use in QSynth. | |
23 * | |
24 * Ported to Qt4 by Chris Cannam. | |
25 * | |
26 * This file copyright 2003-2005 Chris Cannam, copyright 2005 Pedro | |
27 * Lopez-Cabanillas. | |
28 * | |
29 * This program is free software; you can redistribute it and/or | |
30 * modify it under the terms of the GNU General Public License as | |
31 * published by the Free Software Foundation; either version 2 of the | |
32 * License, or (at your option) any later version. See the file | |
33 * COPYING included with this distribution for more information. | |
34 */ | |
35 | |
36 #include <QDial> | |
37 #include <map> | |
38 | |
39 /** | |
40 * AudioDial is a nicer-looking QDial that by default reacts to mouse | |
41 * movement on horizontal and vertical axes instead of in a radial | |
42 * motion. Move the mouse up or right to increment the value, down or | |
43 * left to decrement it. AudioDial also responds to the mouse wheel. | |
44 * | |
45 * The programming interface for this widget is compatible with QDial, | |
46 * with the addition of properties for the knob colour and meter | |
47 * colour and a boolean property mouseDial that determines whether to | |
48 * respond to radial mouse motion in the same way as QDial (the | |
49 * default is no). | |
50 */ | |
51 | |
52 class AudioDial : public QDial | |
53 { | |
54 Q_OBJECT | |
55 Q_PROPERTY( QColor knobColor READ getKnobColor WRITE setKnobColor ) | |
56 Q_PROPERTY( QColor meterColor READ getMeterColor WRITE setMeterColor ) | |
57 Q_PROPERTY( bool mouseDial READ getMouseDial WRITE setMouseDial ) | |
58 | |
59 public: | |
60 AudioDial(QWidget *parent = 0); | |
61 ~AudioDial(); | |
62 | |
63 const QColor& getKnobColor() const { return m_knobColor; } | |
64 const QColor& getMeterColor() const { return m_meterColor; } | |
65 bool getMouseDial() const { return m_mouseDial; } | |
66 | |
67 public slots: | |
68 /** | |
69 * Set the colour of the knob. The default is to inherit the | |
70 * colour from the widget's palette. | |
71 */ | |
72 void setKnobColor(const QColor &color); | |
73 | |
74 /** | |
75 * Set the colour of the meter (the highlighted area around the | |
76 * knob that shows the current value). The default is to inherit | |
77 * the colour from the widget's palette. | |
78 */ | |
79 void setMeterColor(const QColor &color); | |
80 | |
81 /** | |
82 * Specify that the dial should respond to radial mouse movements | |
83 * in the same way as QDial. | |
84 */ | |
85 void setMouseDial(bool mouseDial); | |
86 | |
87 protected: | |
88 void drawTick(QPainter &paint, float angle, int size, bool internal); | |
89 virtual void paintEvent(QPaintEvent *); | |
90 | |
91 // Alternate mouse behavior event handlers. | |
92 virtual void mousePressEvent(QMouseEvent *pMouseEvent); | |
93 virtual void mouseMoveEvent(QMouseEvent *pMouseEvent); | |
94 virtual void mouseReleaseEvent(QMouseEvent *pMouseEvent); | |
95 | |
96 private: | |
97 QColor m_knobColor; | |
98 QColor m_meterColor; | |
99 | |
100 // Alternate mouse behavior tracking. | |
101 bool m_mouseDial; | |
102 bool m_mousePressed; | |
103 QPoint m_posMouse; | |
104 }; | |
105 | |
106 | |
107 #endif // __AudioDial_h | |
108 | |
109 // end of AudioDial.h |