class library: PriorityQueue - implement removeValue, hide array
[supercollider.git] / QtCollider / widgets / QcMultiSlider.h
blob9e419664750c3244bd8ca3e29206e512f53ab745
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"
27 #include <QWidget>
29 class QcMultiSlider : public QWidget, QcHelper
31 // TODO setting selection with mouse
32 Q_OBJECT
33 Q_PROPERTY( VariantList values READ values WRITE setValues );
34 Q_PROPERTY( VariantList reference READ dummyVariantList WRITE setReference );
35 Q_PROPERTY( float value READ value WRITE setValue );
36 Q_PROPERTY( int sliderCount READ sliderCount WRITE setSliderCount);
37 Q_PROPERTY( float stepSize READ dummyFloat WRITE setStepSize );
38 Q_PROPERTY( int index READ index WRITE setIndex );
39 Q_PROPERTY( int selectionSize READ selectionSize WRITE setSelectionSize );
40 Q_PROPERTY( Qt::Orientation orientation
41 READ orientation WRITE setOrientation );
42 Q_PROPERTY( bool elastic READ dummyBool WRITE setElastic );
43 Q_PROPERTY( int indexThumbSize READ dummyFloat WRITE setIndexThumbSize );
44 Q_PROPERTY( float valueThumbSize READ dummyFloat WRITE setValueThumbSize );
45 Q_PROPERTY( int gap READ dummyInt WRITE setGap );
46 Q_PROPERTY( bool drawLines READ dummyBool WRITE setDrawLines );
47 Q_PROPERTY( bool drawRects READ dummyBool WRITE setDrawRects );
48 Q_PROPERTY( bool isFilled READ dummyBool WRITE setIsFilled );
49 Q_PROPERTY( bool highlight READ dummyBool WRITE setHighlight );
50 Q_PROPERTY( QColor fillColor READ dummyColor WRITE setFillColor );
51 Q_PROPERTY( QColor strokeColor READ dummyColor WRITE setStrokeColor );
52 Q_PROPERTY( bool editable READ dummyBool WRITE setEditable );
53 Q_PROPERTY( int startIndex READ dummyInt WRITE setStartIndex );
55 public:
56 QcMultiSlider();
57 QSize sizeHint() const { return QSize( 500,300 ); }
58 QSize minimumSizeHint() const { return QSize( 50, 50 ); }
59 Q_SIGNALS:
60 void modified();
61 void interacted();
62 void action();
63 void metaAction();
64 public Q_SLOTS:
65 void doAction();
66 private:
67 Qt::Orientation orientation() const { return ort; }
68 VariantList values() const;
69 float value() const;
70 int index() const { return _currentIndex; }
71 int selectionSize() const { return _selectionSize; }
73 int sliderCount() const { return _values.size(); }
74 void setSliderCount( int size );
75 void setValues( const VariantList & );
76 void setReference( const VariantList & );
77 void setValue( float f );
78 void setStepSize( float f );
79 void setIndex( int i );
80 void setSelectionSize( int i );
81 void setOrientation( Qt::Orientation o ) { ort = o; update(); }
82 void setElastic( bool b ) { elastic = b; update(); }
83 void setIndexThumbSize( float f ) { thumbSize.setWidth(f); update(); }
84 void setValueThumbSize( float f ) { thumbSize.setHeight(f); update(); }
85 void setGap( int i ) { gap = i; update(); }
86 void setDrawLines( bool b ) { drawLines = b; update(); }
87 void setDrawRects( bool b ) { drawRects = b; update(); }
88 void setIsFilled( bool b ) { isFilled = b; update(); }
89 void setHighlight( bool b ) { highlight = b; update(); }
90 void setFillColor( const QColor& c ) { _fillColor = c; update(); }
91 void setStrokeColor( const QColor& c ) { _strokeColor = c; update(); }
92 void setEditable( bool b ) { editable = b; }
93 void setStartIndex( int i ) { startIndex = i; update(); }
95 inline float valueFromPos( float pos, float range );
96 inline void setValue( int index, float value );
97 void mousePressEvent( QMouseEvent * );
98 void mouseMoveEvent( QMouseEvent * );
99 void paintEvent( QPaintEvent * );
101 // values
102 QList<float> _values;
103 QList<float> _ref;
104 int _currentIndex;
105 int _selectionSize;
107 // functional properties
108 float roundStep;
109 bool editable;
111 // visual properties
112 Qt::Orientation ort;
113 bool elastic;
114 QSizeF thumbSize;
115 int gap;
116 bool drawRects;
117 bool drawLines;
118 bool isFilled;
119 bool highlight;
120 QColor _fillColor;
121 QColor _strokeColor;
122 int startIndex;
124 // temporary
125 QPoint moveOrigin;
128 #endif