1 /************************************************************************
3 * Copyright 2010 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_MULTI_SLIDER
23 #define QC_MULTI_SLIDER
25 #include "../QcHelper.h"
26 #include "../style/style.hpp"
27 #include "../Common.h"
31 class QcMultiSlider
: public QWidget
, QcHelper
, QtCollider::Style::Client
33 // TODO setting selection with mouse
35 Q_PROPERTY( int sliderCount READ sliderCount WRITE setSliderCount
);
36 Q_PROPERTY( QVector
<double> values READ values WRITE setValues
);
37 Q_PROPERTY( QVector
<double> reference READ reference WRITE setReference
);
38 Q_PROPERTY( double value READ value WRITE setValue
);
39 Q_PROPERTY( double step READ step WRITE setStep
);
40 Q_PROPERTY( int index READ index WRITE setIndex
);
41 Q_PROPERTY( int selectionSize READ selectionSize WRITE setSelectionSize
);
42 Q_PROPERTY( Qt::Orientation orientation
43 READ orientation WRITE setOrientation
);
44 Q_PROPERTY( bool elastic READ dummyBool WRITE setElastic
);
45 Q_PROPERTY( int indexThumbSize READ dummyFloat WRITE setIndexThumbSize
);
46 Q_PROPERTY( float valueThumbSize READ dummyFloat WRITE setValueThumbSize
);
47 Q_PROPERTY( int gap READ dummyInt WRITE setGap
);
48 Q_PROPERTY( bool drawLines READ dummyBool WRITE setDrawLines
);
49 Q_PROPERTY( bool drawRects READ dummyBool WRITE setDrawRects
);
50 Q_PROPERTY( bool isFilled READ dummyBool WRITE setIsFilled
);
51 Q_PROPERTY( bool highlight READ dummyBool WRITE setHighlight
);
52 Q_PROPERTY( QColor fillColor READ dummyColor WRITE setFillColor
);
53 Q_PROPERTY( QColor strokeColor READ dummyColor WRITE setStrokeColor
);
54 Q_PROPERTY( bool editable READ dummyBool WRITE setEditable
);
55 Q_PROPERTY( int startIndex READ dummyInt WRITE setStartIndex
);
56 Q_PROPERTY( QColor focusColor READ focusColor WRITE setFocusColor
);
70 QVector
<double> values() const;
71 void setValues( const QVector
<double> & );
73 void setValue( double );
75 QVector
<double> reference() const;
76 void setReference( const QVector
<double> & );
78 double step() const { return roundStep
; }
79 void setStep( double );
81 QSize
sizeHint() const { return QSize( 500,300 ); }
82 QSize
minimumSizeHint() const { return QSize( 50, 50 ); }
85 virtual void mousePressEvent( QMouseEvent
* );
86 virtual void mouseMoveEvent( QMouseEvent
* );
87 virtual void paintEvent( QPaintEvent
* );
90 Qt::Orientation
orientation() const { return ort
; }
91 int index() const { return _currentIndex
; }
92 int selectionSize() const { return _selectionSize
; }
93 int sliderCount() const { return _values
.size(); }
94 void setSliderCount( int size
);
95 void setIndex( int i
);
96 void setSelectionSize( int i
);
97 void setOrientation( Qt::Orientation o
) { ort
= o
; update(); }
98 void setElastic( bool b
) { elastic
= b
; update(); }
99 void setIndexThumbSize( float f
) { thumbSize
.setWidth(f
); update(); }
100 void setValueThumbSize( float f
) { thumbSize
.setHeight(f
); update(); }
101 void setGap( int i
) { gap
= i
; update(); }
102 void setDrawLines( bool b
) { drawLines
= b
; update(); }
103 void setDrawRects( bool b
) { drawRects
= b
; update(); }
104 void setIsFilled( bool b
) { isFilled
= b
; update(); }
105 void setHighlight( bool b
) { highlight
= b
; update(); }
106 void setFillColor( const QColor
& c
) { _fillColor
= c
; update(); }
107 void setStrokeColor( const QColor
& c
) { _strokeColor
= c
; update(); }
108 void setEditable( bool b
) { editable
= b
; }
109 void setStartIndex( int i
) { startIndex
= qBound(0, i
, _values
.count()-1); update(); }
111 QRect
contentsRect();
112 QRect
valueRect( int count
, double & spacing
);
113 inline float valueFromPos( float pos
, float range
);
114 inline void setValue( int index
, double value
);
115 double rounded ( double value
);
118 QList
<double> _values
;
123 // functional properties