Chris@0: /* -*- c-basic-offset: 4 -*- vi:set ts=8 sts=4 sw=4: */ Chris@0: Chris@0: /* Chris@0: A waveform viewer and audio annotation editor. Chris@5: Chris Cannam, Queen Mary University of London, 2005-2006 Chris@0: Chris@0: This is experimental software. Not for distribution. Chris@0: */ Chris@0: Chris@0: #ifndef _AUDIO_DIAL_H_ Chris@0: #define _AUDIO_DIAL_H_ Chris@0: Chris@0: /** Chris@0: * A rotary dial widget. Chris@0: * Chris@0: * Based on an original design by Thorsten Wilms. Chris@0: * Chris@0: * Implemented as a widget for the Rosegarden MIDI and audio sequencer Chris@0: * and notation editor by Chris Cannam. Chris@0: * Chris@0: * Extracted into a standalone Qt3 widget by Pedro Lopez-Cabanillas Chris@0: * and adapted for use in QSynth. Chris@0: * Chris@0: * Ported to Qt4 by Chris Cannam. Chris@0: * Chris@0: * This file copyright 2003-2005 Chris Cannam, copyright 2005 Pedro Chris@0: * Lopez-Cabanillas. Chris@0: * Chris@0: * This program is free software; you can redistribute it and/or Chris@0: * modify it under the terms of the GNU General Public License as Chris@0: * published by the Free Software Foundation; either version 2 of the Chris@0: * License, or (at your option) any later version. See the file Chris@0: * COPYING included with this distribution for more information. Chris@0: */ Chris@0: Chris@0: #include Chris@0: #include Chris@0: Chris@0: /** Chris@0: * AudioDial is a nicer-looking QDial that by default reacts to mouse Chris@0: * movement on horizontal and vertical axes instead of in a radial Chris@0: * motion. Move the mouse up or right to increment the value, down or Chris@0: * left to decrement it. AudioDial also responds to the mouse wheel. Chris@0: * Chris@0: * The programming interface for this widget is compatible with QDial, Chris@0: * with the addition of properties for the knob colour and meter Chris@0: * colour and a boolean property mouseDial that determines whether to Chris@0: * respond to radial mouse motion in the same way as QDial (the Chris@0: * default is no). Chris@0: */ Chris@0: Chris@0: class AudioDial : public QDial Chris@0: { Chris@0: Q_OBJECT Chris@0: Q_PROPERTY( QColor knobColor READ getKnobColor WRITE setKnobColor ) Chris@0: Q_PROPERTY( QColor meterColor READ getMeterColor WRITE setMeterColor ) Chris@0: Q_PROPERTY( bool mouseDial READ getMouseDial WRITE setMouseDial ) Chris@0: Chris@0: public: Chris@0: AudioDial(QWidget *parent = 0); Chris@0: ~AudioDial(); Chris@0: Chris@0: const QColor& getKnobColor() const { return m_knobColor; } Chris@0: const QColor& getMeterColor() const { return m_meterColor; } Chris@0: bool getMouseDial() const { return m_mouseDial; } Chris@0: Chris@0: public slots: Chris@0: /** Chris@0: * Set the colour of the knob. The default is to inherit the Chris@0: * colour from the widget's palette. Chris@0: */ Chris@0: void setKnobColor(const QColor &color); Chris@0: Chris@0: /** Chris@0: * Set the colour of the meter (the highlighted area around the Chris@0: * knob that shows the current value). The default is to inherit Chris@0: * the colour from the widget's palette. Chris@0: */ Chris@0: void setMeterColor(const QColor &color); Chris@0: Chris@0: /** Chris@0: * Specify that the dial should respond to radial mouse movements Chris@0: * in the same way as QDial. Chris@0: */ Chris@0: void setMouseDial(bool mouseDial); Chris@0: Chris@34: void setDefaultValue(int defaultValue); Chris@34: Chris@0: protected: Chris@0: void drawTick(QPainter &paint, float angle, int size, bool internal); Chris@0: virtual void paintEvent(QPaintEvent *); Chris@0: Chris@0: // Alternate mouse behavior event handlers. Chris@0: virtual void mousePressEvent(QMouseEvent *pMouseEvent); Chris@0: virtual void mouseMoveEvent(QMouseEvent *pMouseEvent); Chris@0: virtual void mouseReleaseEvent(QMouseEvent *pMouseEvent); Chris@34: virtual void mouseDoubleClickEvent(QMouseEvent *pMouseEvent); Chris@0: Chris@0: private: Chris@0: QColor m_knobColor; Chris@0: QColor m_meterColor; Chris@0: Chris@34: int m_defaultValue; Chris@34: Chris@0: // Alternate mouse behavior tracking. Chris@0: bool m_mouseDial; Chris@0: bool m_mousePressed; Chris@0: QPoint m_posMouse; Chris@0: }; Chris@0: Chris@0: Chris@0: #endif // __AudioDial_h Chris@0: Chris@0: // end of AudioDial.h