scide: implement selectionLength for openDocument
[supercollider.git] / QtCollider / widgets / QcKnob.hpp
blob7e82557f4fae3f794f4ef41b4a2ca615c229ec02
1 /************************************************************************
3 * Copyright 2011-2012 Jakob Leben (jakob.leben@gmail.com)
5 * This file is part of SuperCollider Qt GUI.
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 ************************************************************************/
22 #ifndef QC_KNOB_HPP
23 #define QC_KNOB_HPP
25 #include <QWidget>
26 #include "QcAbstractStepValue.h"
27 #include "../style/style.hpp"
29 class QcKnob : public QWidget, QcAbstractStepValue, QtCollider::Style::Client
31 Q_OBJECT
32 Q_PROPERTY( double shiftScale READ shiftScale WRITE setShiftScale );
33 Q_PROPERTY( double ctrlScale READ ctrlScale WRITE setCtrlScale );
34 Q_PROPERTY( double altScale READ altScale WRITE setAltScale );
36 Q_PROPERTY( double value READ value WRITE setValue )
37 Q_PROPERTY( int mode READ mode WRITE setMode )
38 Q_PROPERTY( double step READ step WRITE setStep )
39 Q_PROPERTY( bool centered READ centered WRITE setCentered )
40 Q_PROPERTY( QColor focusColor READ focusColor WRITE setFocusColor );
42 Q_SIGNALS:
43 void action();
45 public:
46 QcKnob();
47 void setValue( double );
48 double value() const { return _value; }
49 void setMode( int i ) { _mode = i; }
50 int mode() const { return _mode; }
51 void setStep( float step ) { _step = step; }
52 float step() const { return _step; }
53 void setCentered( bool b ) { _centered = b; update(); }
54 bool centered() const { return _centered; }
56 virtual QSize sizeHint() const { return QSize(40,40); }
57 virtual QSize minimumSizeHint() const { return QSize(15,15); }
59 protected:
60 virtual void mousePressEvent( QMouseEvent * );
61 virtual void mouseMoveEvent( QMouseEvent * );
62 virtual void paintEvent( QPaintEvent * );
64 private:
65 double value( const QPoint & );
67 double _value;
68 double _step;
69 int _mode;
70 QPoint _prevPos;
71 bool _centered;
74 #endif // QC_KNOB_HPP