scide: implement selectionLength for openDocument
[supercollider.git] / QtCollider / widgets / QcSlider.h
blobc2da777f1ada7b54f2635e2548bc7f75bb039f6d
1 /************************************************************************
3 * Copyright 2010-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_SLIDER
23 #define QC_SLIDER
25 #include "QcAbstractStepValue.h"
26 #include "../QcHelper.h"
27 #include "../style/style.hpp"
29 #include <QWidget>
31 class QcSlider : public QWidget, QcHelper, QcAbstractStepValue, QtCollider::Style::Client
33 Q_OBJECT
34 Q_PROPERTY( double shiftScale READ dummyFloat WRITE setShiftScale );
35 Q_PROPERTY( double ctrlScale READ dummyFloat WRITE setCtrlScale );
36 Q_PROPERTY( double altScale READ dummyFloat WRITE setAltScale );
37 Q_PROPERTY( double step READ step WRITE setStep )
38 Q_PROPERTY( double pixelStep READ pixelStep )
39 Q_PROPERTY( double value READ value WRITE setValue );
40 Q_PROPERTY( int orientation READ orientation WRITE setOrientation );
41 Q_PROPERTY( int handleLength READ handleLength WRITE setHandleLength );
42 Q_PROPERTY( QColor grooveColor READ grooveColor WRITE setGrooveColor );
43 Q_PROPERTY( QColor focusColor READ focusColor WRITE setFocusColor );
44 Q_PROPERTY( QColor knobColor READ knobColor WRITE setKnobColor );
46 public Q_SLOTS:
47 void increment( double factor );
48 void decrement( double factor );
50 Q_SIGNALS:
51 void action();
52 void preAction( double );
54 public:
55 QcSlider();
56 double value() { return _value; }
57 void setValue( double val );
59 double step() { return _step; }
60 void setStep( double d ) { _step = d; }
61 double pixelStep();
63 Qt::Orientation orientation() const { return _ort; }
64 void setOrientation( int );
66 int handleLength() const { return _hndLen; }
67 void setHandleLength( int i ) { _hndLen = i; updateGeometry(); update(); }
69 const QColor & knobColor() const
70 { return _knobColor.isValid() ? _knobColor : palette().color(QPalette::ButtonText); }
71 void setKnobColor(const QColor &c) { _knobColor = c; update(); }
73 virtual QSize sizeHint() const;
74 virtual QSize minimumSizeHint() const;
76 protected:
77 virtual void mousePressEvent ( QMouseEvent * );
78 virtual void mouseMoveEvent ( QMouseEvent * );
79 virtual void wheelEvent ( QWheelEvent * );
80 virtual void paintEvent ( QPaintEvent * );
82 private:
83 QRect thumbRect ();
84 double valueAt( const QPoint &pos );
86 Qt::Orientation _ort;
87 double _value;
88 double _step;
89 int _hndLen;
91 QColor _knobColor;
94 #endif