old quark gui: openOS is not osx only
[supercollider.git] / SCClassLibrary / QtCollider / QMultiSliderView.sc
blob2bc5c08889034e49d96db8afd3f2bfe5b7585eba
1 QMultiSliderView : QView {
2   var <editable=true, <step=0;
3   var <reference;
4   var <indexIsHorizontal=true, <elasticMode=false;
5   var <indexThumbSize=12, <valueThumbSize=12, <gap=1;
6   var <drawLines=false, <drawRects=true;
7   var <metaAction;
10   *qtClass { ^"QcMultiSlider" }
12   background {
13     ^this.palette.baseColor;
14   }
16   background_ { arg color;
17     this.setProperty( \palette, this.palette.baseColor_(color) );
18   }
20   size { ^this.getProperty(\sliderCount) }
21   size_ { arg int; this.setProperty( \sliderCount, int ) }
23   indexIsHorizontal_ { arg bool;
24     indexIsHorizontal = bool;
25     if( bool ) {
26       this.setProperty( \orientation, QOrientation(\horizontal) );
27     } {
28       this.setProperty( \orientation, QOrientation(\vertical) );
29     };
30   }
32   editable_ { arg aBool;
33     editable = aBool;
34     this.setProperty( \editable, aBool );
35   }
37   readOnly {
38     ^editable.not;
39   }
41   readOnly_ { arg bool;
42     this.editable_( bool.not );
43   }
45   step_ { arg aFloat;
46     step = aFloat;
47     this.setProperty( \stepSize, aFloat );
48   }
50   value {
51     ^this.getProperty( \values );
52   }
54   value_ { arg floatArray;
55     this.setProperty( \values, floatArray );
56   }
58   valueAction_ { arg val;
59     this.value_(val);
60     action.value(this);
61   }
63   currentvalue {
64     ^this.getProperty( \value );
65   }
67   currentvalue_ { arg aFloat;
68     this.setProperty( \value, aFloat );
69   }
71   index {
72     ^this.getProperty( \index );
73   }
75   index_ { arg anInt;
76     this.setProperty( \index, anInt );
77   }
79   selectionSize {
80     ^this.getProperty( \selectionSize );
81   }
83   selectionSize_ { arg anInt;
84     this.setProperty( \selectionSize, anInt );
85   }
87   reference_ { arg aFloatArray;
88     reference = aFloatArray;
89     this.setProperty( \reference, aFloatArray );
90   }
92   startIndex_ { arg anInt;
93     this.setProperty( \startIndex, anInt );
94   }
96   elasticMode_ { arg int;
97     elasticMode = int.booleanValue;
98     this.setProperty( \elastic, elasticMode);
99   }
101   thumbSize_ { arg float;
102     this.indexThumbSize_(float);
103     this.valueThumbSize_(float);
104   }
106   indexThumbSize_ { arg float;
107     indexThumbSize = float;
108     this.setProperty( \indexThumbSize, float );
109   }
111   valueThumbSize_ { arg float;
112     valueThumbSize = float;
113     this.setProperty( \valueThumbSize, float );
114   }
116   gap_ { arg anInt;
117     gap = anInt;
118     this.setProperty( \gap, anInt );
119   }
121   // alias for 'gap'
122   xOffset_ { arg int; this.gap_(int); }
123   xOffset { arg int; ^this.gap; }
125   drawLines_ { arg bool;
126     drawLines = bool;
127     this.setProperty( \drawLines, bool );
128   }
130   drawRects_ { arg bool;
131     drawRects = bool;
132     this.setProperty( \drawRects, bool );
133   }
135   showIndex_ { arg aBool;
136     this.setProperty( \highlight, aBool );
137   }
139   isFilled_ { arg aBool;
140     this.setProperty( \isFilled, aBool );
141   }
143   fillColor_ { arg aColor;
144     this.setProperty( \fillColor, aColor );
145   }
147   strokeColor_ { arg aColor;
148     this.setProperty( \strokeColor, aColor );
149   }
151   colors_ { arg colorStroke, colorFill;
152     this.strokeColor_( colorStroke );
153     this.fillColor_ ( colorFill );
154   }
156   metaAction_ { arg func;
157     this.manageMethodConnection( metaAction, func, 'metaAction()', \doMetaAction );
158     metaAction = func;
159   }
161   doMetaAction {
162     metaAction.value(this);
163   }
165   defaultKeyDownAction { arg char, mod, uni, key;
166     key.switch (
167       QKey.left, { this.index = this.index - 1 },
168       QKey.right, { this.index = this.index + 1 },
169       QKey.up, { this.currentvalue = this.currentvalue + this.step },
170       QKey.down, { this.currentvalue = this.currentvalue - this.step }
171     );
172   }
174   defaultGetDrag {
175     var val = this.value;
176     var c, i;
177     if( val.size < 1 ) {^nil};
178     c = this.selectionSize;
179     if( c > 1 ) {
180       i = this.index;
181       ^val[i..(i+c-1)];
182     }
183     ^this.value;
184   }
185   defaultCanReceiveDrag { ^true; }
186   defaultReceiveDrag {
187     arg data = QView.currentDrag;
188     if( data.size > 0 ) {
189       if( data[0].size > 0 ) {
190         this.value = data[0];
191         this.reference = data[1];
192       }{
193         this.value = data;
194       }
195     };
196   }