fix String:wrapExtend to fill out to the actual requested size
[supercollider.git] / QtCollider / widgets / QcMultiSlider.h
blob40b6b0a19d357d9f8b21227c0a17e8fac7e40e93
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"
28 #include <QWidget>
30 class QcMultiSlider : public QWidget, QcHelper, QtCollider::Style::Client
32 // TODO setting selection with mouse
33 Q_OBJECT
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 );
57 Q_SIGNALS:
58 void modified();
59 void interacted();
60 void action();
61 void metaAction();
63 public Q_SLOTS:
64 void doAction();
66 public:
67 QcMultiSlider();
68 QSize sizeHint() const { return QSize( 500,300 ); }
69 QSize minimumSizeHint() const { return QSize( 50, 50 ); }
71 protected:
72 virtual void mousePressEvent( QMouseEvent * );
73 virtual void mouseMoveEvent( QMouseEvent * );
74 virtual void paintEvent( QPaintEvent * );
76 private:
77 Qt::Orientation orientation() const { return ort; }
78 VariantList values() const;
79 float value() 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 );
110 // values
111 QList<float> _values;
112 QList<float> _ref;
113 int _currentIndex;
114 int _selectionSize;
116 // functional properties
117 float roundStep;
118 bool editable;
120 // visual properties
121 Qt::Orientation ort;
122 bool elastic;
123 QSizeF thumbSize;
124 int gap;
125 bool drawRects;
126 bool drawLines;
127 bool isFilled;
128 bool highlight;
129 QColor _fillColor;
130 QColor _strokeColor;
131 QColor _focusColor;
132 int startIndex;
134 // temporary
135 QPoint moveOrigin;
138 #endif