/usr/share/SuperCollider/HelpSource/Classes/RangeSlider.schelp is in supercollider-common 1:3.8.0~repack-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 | CLASS:: RangeSlider
summary:: A view consisting of a sliding extendable handle
categories:: GUI>Views
DESCRIPTION::
A view that allows setting two numerical values between 0 and 1, represented by the two ends of a movable and extendable handle. It can have horizontal or vertical orientation, meaning the direction in which the handle moves and extends.
Dragging the mouse pointer on either end of the range moves the end by itself. Dragging in the middle of the range moves the whole range without changing its size.
CLASSMETHODS::
PRIVATE:: key
METHOD:: new
When a new RangeSlider is created, its link::#-orientation:: is determined by the initial size: if it is wider than high, the orientation will be horizontal, otherwise it will be vertical.
INSTANCEMETHODS::
SUBSECTION:: Data
METHOD:: lo
The low end of the range.
If you attempt to set it higher then the current link::#-hi::, -hi will be set instead, and -lo will become the old -hi.
When setting -lo the value will always be clipped to the range between 0 and 1.
argument::
A Float between 0 and 1.
METHOD:: hi
The high end of the range. If you attempt to set it lower then the current link::#-lo::, -lo will be set instead, and -hi will become the old -lo.
When setting -hi the value will always be clipped to the range between 0 and 1.
argument::
A Float between 0 and 1.
METHOD:: activeLo
Sets link::#-lo:: to the argument and triggers link::#-action::.
METHOD:: activeHi
Sets link::#-hi:: to the argument and triggers link::#-action::.
METHOD:: range
The difference between link::#-hi:: and link::#-lo::. Setting -range will set -hi to -lo + -range.
METHOD:: activeRange
Sets link::#-range:: to the argument and triggers link::#-action::.
METHOD:: setSpan
Sets link::#-lo:: and link::#-hi:: to each of the arguments, respectively.
METHOD:: setSpanActive
Calls link::#-setSpan::, forwarding the arguments, and triggers link::#-action::.
METHOD:: setDeviation
Sets link::#-lo:: and link::#-hi:: according to their deviation and their average instead of their absolute values.
argument:: deviation
A Float determining the absolute deviation of -lo and -hi from their average.
argument:: average
A Float determining the average of -lo and -hi.
METHOD:: increment
Increments both link::#-lo:: and link::#-hi:: by link::#-step:: multiplied by 'factor'.
argument:: factor
A Float.
METHOD:: decrement
Decrements both link::#-lo:: and link::#-hi:: by link::#-step:: multiplied by 'factor'.
argument:: factor
A Float.
SUBSECTION:: Appearance
METHOD:: orientation
The orientation of the RangeSlider - the direction in which the handle moves and is extendable. The default value depends on the size of the view when created.
argument::
One of the two Symbols: \horizontal or \vertical.
METHOD:: knobColor
The color of the handle.
argument::
A Color.
SUBSECTION:: Interaction
METHOD:: step
The amount by which the range will change when link::#-increment:: or link::#-decrement:: is called, or when related keys are pressed.
argument::
A Float.
METHOD:: pixelStep
The absolute amount by which the range would change if the handle moved by one pixel.
returns::
A Float.
METHOD:: shift_scale
The factor by which link::#-step:: is multiplied when incrementing or decrementing the range by keyboard while the Shift key is pressed.
argument::
A Float.
METHOD:: ctrl_scale
The factor by which link::#-step:: is multiplied when incrementing or decrementing the range by keyboard while the Ctrl key is pressed.
argument::
A Float.
METHOD:: alt_scale
The factor by which link::#-step:: is multiplied when incrementing or decrementing the range by keyboard while the Alt key is pressed.
argument::
A Float.
SUBSECTION:: Actions
METHOD:: action
The action object evaluated whenever the user changes the position or size of the handle.
METHOD:: defaultKeyDownAction
Implements the default effects of key presses as follows:
table::
## strong::Key:: || strong::Effect::
## a || lo_(0), hi_(1), and triggers action
## n || lo_(0), hi_(0), and triggers action
## x || lo_(1), hi_(1), and triggers action
## c || lo_(0.5), hi_(0.5), and triggers action
## up arrow || increment
## down arrow || decrement
## right arrow || increment
## left arrow || decrement
::
SUBSECTION:: Drag and drop
METHOD:: defaultGetDrag
returns::
A Point of which the x and y coordinates are set to link::#-lo:: and link::#-hi::, respectively.
METHOD:: defaultCanReceiveDrag
returns::
True if the current drag data is a Point.
METHOD:: defaultReceiveDrag
Sets link::#-lo:: and link::#-hi:: to the two coordinates of the Point stored as the current drag data, respectively, and triggers the link::#-action::.
EXAMPLES::
subsection:: Basic examples
code::
(
w = Window.new.front;
a = RangeSlider(w, Rect(20, 80, 120, 30))
.lo_(0.2)
.range_(0.4)
.action_({ |slider|
[\sliderLOW, slider.lo, \sliderHI, slider.hi].postln;
});
)
::
code::
(
w = Window.new.front;
a = RangeSlider(w, Rect(20, 80, 120, 30))
.lo_(0.2)
.hi_(0.8)
.action_({ |slider|
b.activeLo_(slider.lo); // this will trigger the action of b (and set it's value)
b.hi_(slider.hi);
});
b = RangeSlider(w, Rect(220, 80, 20, 130))
.lo_(0.2)
.hi_(0.8)
.knobColor_(HiliteGradient(Color.grey, Color.white,\h))
.action_({ |slider|
[\sliderLOW, slider.lo, \sliderHI, slider.hi].postln;
});
)
::
subsection:: Use of setDeviation
code::
(
w = Window("setDeviation", Rect(300, 300, 300, 150));
a = RangeSlider(w, Rect(10, 10, 200, 30))
.lo_(0)
.hi_(1);
b = Slider(w, Rect(10, 50, 200, 30))
.action_(
{ arg me;
a.setDeviation(c.value, b.value);
});
c = Slider(w, Rect(10, 100, 200, 30))
.action_(
{ arg me;
a.setDeviation(c.value, b.value);
}
);
c.valueAction = 0.2;
w.front;
)
::
subsection:: Sound example
Shape a bandpass filter.
In Cocoa GUI, hold down the Ctrl key to move the whole range; in other GUI kits you can simply click within the range and drag it.
code::
(
s.waitForBoot({
a={arg freq=1800, bw=0.2;
var r;
BBandPass.ar(WhiteNoise.ar(0.3), freq, bw);
}.play;
w = Window("2DSlider", Rect(100,Window.screenBounds.height-400, 400 ,50));
t = RangeSlider(w, Rect(10, 10, 380, 30))
.lo_(0.4)
.hi_(0.6)
.action_({|sl|
a.set(\freq,1800*(sl.lo+sl.lo)+10,\bw, (sl.hi-sl.lo).abs+0.01);
});
t.doAction;
w.front;
CmdPeriod.doOnce({w.close});
})
)
::
|