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