supernova: fixes for boost-1.49 and gcc-4.7
[supercollider.git] / SCClassLibrary / QtCollider / QMultiSliderView.sc
blobf394eb509d7e22e32582b3178d6c8b05599407fd
1 QMultiSliderView : QView {
2   var <editable=true;
3   var <elasticMode=false;
4   var <indexThumbSize=12, <valueThumbSize=12, <gap=1;
5   var <drawLines=false, <drawRects=true;
6   var <metaAction;
9   *qtClass { ^"QcMultiSlider" }
11   size { ^this.getProperty(\sliderCount) }
12   size_ { arg int; this.setProperty( \sliderCount, int ) }
14   indexIsHorizontal { ^this.getProperty(\orientation) == QOrientation(\vertical) }
16   indexIsHorizontal_ { arg bool;
17     this.setProperty( \orientation, QOrientation(if(bool){\vertical}{\horizontal}) );
18   }
20   editable_ { arg aBool;
21     editable = aBool;
22     this.setProperty( \editable, aBool );
23   }
25   readOnly {
26     ^editable.not;
27   }
29   readOnly_ { arg bool;
30     this.editable_( bool.not );
31   }
33   step { ^this.getProperty(\step) }
34   step_ { arg val; this.setProperty( \step, val ) }
36   value {
37     ^this.getProperty( \values );
38   }
40   value_ { arg array;
41     if( array.isKindOf(DoubleArray).not and: {array.isKindOf(FloatArray).not} )
42       { array = array.as(DoubleArray) };
43     this.setProperty( \values, array );
44   }
46   valueAction_ { arg val;
47     this.value_(val);
48     action.value(this);
49   }
51   currentvalue {
52     ^this.getProperty( \value );
53   }
55   currentvalue_ { arg aFloat;
56     this.setProperty( \value, aFloat );
57   }
59   index {
60     ^this.getProperty( \index );
61   }
63   index_ { arg anInt;
64     this.setProperty( \index, anInt );
65   }
67   selectionSize {
68     ^this.getProperty( \selectionSize );
69   }
71   selectionSize_ { arg anInt;
72     this.setProperty( \selectionSize, anInt );
73   }
75   reference { ^this.getProperty(\reference) }
77   reference_ { arg array;
78     if( array.isKindOf(DoubleArray).not and: {array.isKindOf(FloatArray).not} )
79       { array = array.as(DoubleArray) };
80     this.setProperty( \reference, array );
81   }
83   startIndex_ { arg anInt;
84     this.setProperty( \startIndex, anInt );
85   }
87   elasticMode_ { arg int;
88     elasticMode = int.booleanValue;
89     this.setProperty( \elastic, elasticMode);
90   }
92   thumbSize_ { arg float;
93     this.indexThumbSize_(float);
94     this.valueThumbSize_(float);
95   }
97   indexThumbSize_ { arg float;
98     indexThumbSize = float;
99     this.setProperty( \indexThumbSize, float );
100   }
102   valueThumbSize_ { arg float;
103     valueThumbSize = float;
104     this.setProperty( \valueThumbSize, float );
105   }
107   gap_ { arg anInt;
108     gap = anInt;
109     this.setProperty( \gap, anInt );
110   }
112   // alias for 'gap'
113   xOffset_ { arg int; this.gap_(int); }
114   xOffset { arg int; ^this.gap; }
116   drawLines_ { arg bool;
117     drawLines = bool;
118     this.setProperty( \drawLines, bool );
119   }
121   drawRects_ { arg bool;
122     drawRects = bool;
123     this.setProperty( \drawRects, bool );
124   }
126   showIndex_ { arg aBool;
127     this.setProperty( \highlight, aBool );
128   }
130   isFilled_ { arg aBool;
131     this.setProperty( \isFilled, aBool );
132   }
134   background {
135     ^this.palette.base;
136   }
138   background_ { arg color;
139     this.palette = this.palette.base_(color);
140   }
142   fillColor_ { arg aColor;
143     this.setProperty( \fillColor, aColor );
144   }
146   strokeColor_ { arg aColor;
147     this.setProperty( \strokeColor, aColor );
148   }
150   colors_ { arg colorStroke, colorFill;
151     this.strokeColor_( colorStroke );
152     this.fillColor_ ( colorFill );
153   }
155   metaAction_ { arg func;
156     this.manageMethodConnection( metaAction, func, 'metaAction()', \doMetaAction );
157     metaAction = func;
158   }
160   doMetaAction {
161     metaAction.value(this);
162   }
164   defaultKeyDownAction { arg char, mod, uni, key;
165     key.switch (
166       QKey.left, { this.index = this.index - 1 },
167       QKey.right, { this.index = this.index + 1 },
168       QKey.up, { this.currentvalue = this.currentvalue + this.step },
169       QKey.down, { this.currentvalue = this.currentvalue - this.step }
170     );
171   }
173   defaultGetDrag {
174     var val = this.value;
175     var c, i;
176     if( val.size < 1 ) {^nil};
177     c = this.selectionSize;
178     if( c > 1 ) {
179       i = this.index;
180       ^val[i..(i+c-1)];
181     }
182     ^this.value;
183   }
184   defaultCanReceiveDrag { ^true; }
185   defaultReceiveDrag {
186     arg data = QView.currentDrag;
187     if( data.size > 0 ) {
188       if( data[0].size > 0 ) {
189         this.value = data[0];
190         this.reference = data[1];
191       }{
192         this.value = data;
193       }
194     };
195   }