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"
30 class QcMultiSlider
: public QWidget
, QcHelper
, QtCollider::Style::Client
32 // TODO setting selection with mouse
34 Q_PROPERTY( VariantList values READ values WRITE setValues
);
35 Q_PROPERTY( VariantList reference READ dummyVariantList WRITE setReference
);
36 Q_PROPERTY( float value READ value WRITE setValue
);
37 Q_PROPERTY( int sliderCount READ sliderCount WRITE setSliderCount
);
38 Q_PROPERTY( float stepSize READ dummyFloat WRITE setStepSize
);
39 Q_PROPERTY( int index READ index WRITE setIndex
);
40 Q_PROPERTY( int selectionSize READ selectionSize WRITE setSelectionSize
);
41 Q_PROPERTY( Qt::Orientation orientation
42 READ orientation WRITE setOrientation
);
43 Q_PROPERTY( bool elastic READ dummyBool WRITE setElastic
);
44 Q_PROPERTY( int indexThumbSize READ dummyFloat WRITE setIndexThumbSize
);
45 Q_PROPERTY( float valueThumbSize READ dummyFloat WRITE setValueThumbSize
);
46 Q_PROPERTY( int gap READ dummyInt WRITE setGap
);
47 Q_PROPERTY( bool drawLines READ dummyBool WRITE setDrawLines
);
48 Q_PROPERTY( bool drawRects READ dummyBool WRITE setDrawRects
);
49 Q_PROPERTY( bool isFilled READ dummyBool WRITE setIsFilled
);
50 Q_PROPERTY( bool highlight READ dummyBool WRITE setHighlight
);
51 Q_PROPERTY( QColor fillColor READ dummyColor WRITE setFillColor
);
52 Q_PROPERTY( QColor strokeColor READ dummyColor WRITE setStrokeColor
);
53 Q_PROPERTY( bool editable READ dummyBool WRITE setEditable
);
54 Q_PROPERTY( int startIndex READ dummyInt WRITE setStartIndex
);
55 Q_PROPERTY( QColor focusColor READ focusColor WRITE setFocusColor
);
68 QSize
sizeHint() const { return QSize( 500,300 ); }
69 QSize
minimumSizeHint() const { return QSize( 50, 50 ); }
72 virtual void mousePressEvent( QMouseEvent
* );
73 virtual void mouseMoveEvent( QMouseEvent
* );
74 virtual void paintEvent( QPaintEvent
* );
77 Qt::Orientation
orientation() const { return ort
; }
78 VariantList
values() const;
80 int index() const { return _currentIndex
; }
81 int selectionSize() const { return _selectionSize
; }
83 int sliderCount() const { return _values
.size(); }
84 void setSliderCount( int size
);
85 void setValues( const VariantList
& );
86 void setReference( const VariantList
& );
87 void setValue( float f
);
88 void setStepSize( float f
);
89 void setIndex( int i
);
90 void setSelectionSize( int i
);
91 void setOrientation( Qt::Orientation o
) { ort
= o
; update(); }
92 void setElastic( bool b
) { elastic
= b
; update(); }
93 void setIndexThumbSize( float f
) { thumbSize
.setWidth(f
); update(); }
94 void setValueThumbSize( float f
) { thumbSize
.setHeight(f
); update(); }
95 void setGap( int i
) { gap
= i
; update(); }
96 void setDrawLines( bool b
) { drawLines
= b
; update(); }
97 void setDrawRects( bool b
) { drawRects
= b
; update(); }
98 void setIsFilled( bool b
) { isFilled
= b
; update(); }
99 void setHighlight( bool b
) { highlight
= b
; update(); }
100 void setFillColor( const QColor
& c
) { _fillColor
= c
; update(); }
101 void setStrokeColor( const QColor
& c
) { _strokeColor
= c
; update(); }
102 void setEditable( bool b
) { editable
= b
; }
103 void setStartIndex( int i
) { startIndex
= qBound(0, i
, _values
.count()-1); update(); }
105 QRect
contentsRect();
106 QRect
valueRect( int count
, double & spacing
);
107 inline float valueFromPos( float pos
, float range
);
108 inline void setValue( int index
, float value
);
111 QList
<float> _values
;
116 // functional properties