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( bool editable READ dummyBool WRITE setEditable
);
53 Q_PROPERTY( int startIndex READ dummyInt WRITE setStartIndex
);
54 Q_PROPERTY( QColor background READ background WRITE setBackground
);
55 Q_PROPERTY( QColor fillColor READ fillColor WRITE setFillColor
);
56 Q_PROPERTY( QColor strokeColor READ strokeColor WRITE setStrokeColor
);
57 Q_PROPERTY( QColor focusColor READ focusColor WRITE setFocusColor
);
71 QVector
<double> values() const;
72 void setValues( const QVector
<double> & );
74 void setValue( double );
76 QVector
<double> reference() const;
77 void setReference( const QVector
<double> & );
79 double step() const { return roundStep
; }
80 void setStep( double );
82 QSize
sizeHint() const { return QSize( 500,300 ); }
83 QSize
minimumSizeHint() const { return QSize( 50, 50 ); }
85 const QColor
& background() const
86 { return _bkgColor
.isValid() ? _bkgColor
: palette().color(QPalette::Base
); }
87 void setBackground( const QColor
& c
) { _bkgColor
= c
; update(); }
89 const QColor
& fillColor() const
90 { return _fillColor
.isValid() ? _fillColor
: palette().color(QPalette::Text
); }
91 void setFillColor( const QColor
& c
) { _fillColor
= c
; update(); }
93 const QColor
& strokeColor() const
94 { return _strokeColor
.isValid() ? _strokeColor
: palette().color(QPalette::Text
); }
95 void setStrokeColor( const QColor
& c
) { _strokeColor
= c
; update(); }
98 virtual void mousePressEvent( QMouseEvent
* );
99 virtual void mouseMoveEvent( QMouseEvent
* );
100 virtual void paintEvent( QPaintEvent
* );
103 Qt::Orientation
orientation() const { return ort
; }
104 int index() const { return _currentIndex
; }
105 int selectionSize() const { return _selectionSize
; }
106 int sliderCount() const { return _values
.size(); }
107 void setSliderCount( int size
);
108 void setIndex( int i
);
109 void setSelectionSize( int i
);
110 void setOrientation( Qt::Orientation o
) { ort
= o
; update(); }
111 void setElastic( bool b
) { elastic
= b
; update(); }
112 void setIndexThumbSize( float f
) { thumbSize
.setWidth(f
); update(); }
113 void setValueThumbSize( float f
) { thumbSize
.setHeight(f
); update(); }
114 void setGap( int i
) { gap
= i
; update(); }
115 void setDrawLines( bool b
) { drawLines
= b
; update(); }
116 void setDrawRects( bool b
) { drawRects
= b
; update(); }
117 void setIsFilled( bool b
) { isFilled
= b
; update(); }
118 void setHighlight( bool b
) { highlight
= b
; update(); }
119 void setEditable( bool b
) { editable
= b
; }
120 void setStartIndex( int i
) { startIndex
= qBound(0, i
, _values
.count()-1); update(); }
122 QRect
contentsRect();
123 QRect
valueRect( int count
, qreal
& spacing
);
124 inline float valueFromPos( float pos
, float range
);
125 inline void setValue( int index
, double value
);
126 double rounded ( double value
);
129 QList
<double> _values
;
134 // functional properties