/usr/share/SuperCollider/HelpSource/Classes/Knob.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 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 | class:: Knob
summary:: A rotary controller view
categories:: GUI>Views
related:: Classes/Slider, Classes/Slider2D
DESCRIPTION::
Knob displays a value from 0.0 to 1.0 in rotary fashion, and allows to control it with either circular or linear mouse motion.
It also displays the deviation of the value from either 0.0 or 0.5, which you can choose using link::#-centered::.
To switch between the mouse interaction modes, use link::#-mode::.
The amount by which the value changes at interaction can be fine-tuned using link::#-step::, link::#-keystep::, link::#-shift_scale::, link::#-ctrl_scale::, and link::#-alt_scale::
CLASSMETHODS::
PRIVATE:: key
METHOD:: defaultMode
The default link::#-mode:: for newly created Knobs.
INSTANCEMETHODS::
SUBSECTION:: Data
METHOD:: value
The displayed value.
argument::
A Number in the range of 0.0 to 1.0.
METHOD:: valueAction
Sets the value and triggers link::#-action::.
METHOD:: increment
Increments the value by link::#-keystep:: multiplied by the argument.
argument::
A Number.
METHOD:: decrement
Decrements the value by link::#-keystep:: multiplied by the argument.
argument:: zoom
A Number.
SUBSECTION:: Interaction
METHOD:: mode
The way value is controlled with respect to mouse movement after clicking on the view:
list::
## code::\round:: - value follows circular movement
## code::\horiz:: - value follows linear movement in horizontal direction
## code::\vert:: - value follows linear movement in vertical direction
::
Defaults to code::\round::.
Argument::
One of the symbols listed above.
METHOD:: keystep
The amount by which the value is incremented/decremented when pressing a relevant key.
Defaults to 0.01;
Argument::
A Number.
METHOD:: step
The amount by which the value is incremented/decremented using the mouse in 'horizontal' and 'vertical' link::#-mode#modes::.
Argument::
A Number.
METHOD:: shift_scale
The factor by which link::#-step:: or link::#-keystep:: is multiplied when used at mouse or keyboard interaction while the Shift key is pressed.
argument::
A Float.
METHOD:: ctrl_scale
The factor by which link::#-step:: or link::#-keystep:: is multiplied when used at mouse or keyboard interaction while the Ctrl key is pressed.
argument::
A Float.
METHOD:: alt_scale
The factor by which link::#-step:: or link::#-keystep:: is multiplied when used at mouse or keyboard interaction while the Alt key is pressed.
argument::
A Float.
SUBSECTION:: Appearance
METHOD:: centered
Whether the deviation of value will be displayed in relation to 0.0 or 0.5 (e.g. as in a panning controller);
Argument::
A Boolean.
METHOD:: color
The colors used by the Knob to draw the following elements:
list::
## the main Knob color
## the value indicator
## the deviation indicator
## the background of the deviation indicator
::
Argument::
An Array of four Colors in the order listed above.
SUBSECTION:: Actions
METHOD:: action
The action object evaluated whenever the user interacts with the Knob using the mouse or the keyboard.
METHOD:: defaultKeyDownAction
Implements the default effects of key presses as follows:
table::
## strong::Key:: || strong::Effect::
## r || valueAction_(1.0.rand)
## n || valueAction_(0)
## x || valueAction_(1)
## c || valueAction_(0.5)
## ] || increment
## [ || decrement
## up arrow || increment
## down arrow || decrement
## right arrow || increment
## left arrow || decrement
::
See also: link::#-keystep::, link::#-shift_scale::, link::#-ctrl_scale::, link::#-alt_scale::.
SUBSECTION:: Drag and drop
METHOD:: defaultGetDrag
returns::
The link::#-value::.
METHOD:: defaultCanReceiveDrag
returns::
True if the current drag data is a Number.
METHOD:: defaultReceiveDrag
Sets link::#-valueAction:: to the current drag data.
EXAMPLES::
subsection:: Basic Example
code::
(
var window, size = 32; // try different sizes - from 15 to 200 or more!
window = Window.new("Knob", Rect(640,630,270,70)).front;
k = Knob.new(window, Rect(20, 10, size, size));
k.action_({|v,x,y,m| postf("action func called: %\n", v.value); });
//k.color[1] = Color.gray(alpha:0);
)
k.value
k.value = 0.25
k.valueAction = 0.125
// modes
k.mode = \vert;
k.mode = \horiz;
k.mode = \round; // default
k.visible
k.visible = false
k.visible = true
k.enabled = false
k.enabled_(true)
k.canFocus = false
k.canFocus = true
::
subsection:: Centered Mode
Center mode is useful for pan or eq gain control etc.
code::
(
var window;
window = Window.new("Pan Knob", Rect(640,630,270,70)).front;
k = Knob.new(window, Rect(20,10,36,36));
k.action_({|v,x,y,m| \pan.asSpec.map(v.value).postln; })
// .mode_(\horiz)
.centered_(false)
.value_(\pan.asSpec.unmap(0)); // 0.5
//k.color[1] = Color.gray(alpha:0);
)
k.centered
k.centered = true
k.centered = false
::
subsection:: step
link::#-step:: only affects the 'horiz' and 'vert' modes:
code::
(
var window, midispec;
midispec = [0,127,'linear',1].asSpec;
window = Window.new("step Knob", Rect(640,630,270,70)).front;
k = Knob.new(window, Rect(20,10,32,32));
k.action_({|v,x,y,m| midispec.map(v.value).postln; })
.value_(midispec.unmap(0));
k.mode = \vert;
)
k.step
k.step = 10/127 // step by 10
k.mode = \horiz;
k.mode = \round;
::
subsection:: mouseOverAction
code::
(
var size = 28;
w = Window.new("Knobs", Rect(250,500,270,70));
w.acceptsMouseOver=true; // must be true in parent window!
w.view.decorator = FlowLayout(w.view.bounds);
h = StaticText(w, 150 @ 10);
w.view.decorator.nextLine;
k = Array(8);
8.do({|item, i|
var knob;
knob = Knob.new(w, size @ size)
.action_({|v,x,y,m| h.string = "val: " ++ v.value.asString; })
.mouseOverAction_({|v,x,y| h.string = "val: " ++ v.value.asString; });
k = k.add(knob);
});
w.front
)
k[4].value
::
subsection:: Drag and Drop
code::
(
var w, txt, size = 36;
w = Window.new("Knobs", Rect(400,400,250,100)).front;
w.acceptsMouseOver=true;
w.view.decorator = FlowLayout(w.view.bounds).gap_(10 @ 10).margin_(10 @10);
txt = StaticText(w, 200 @ 14);
w.view.decorator.nextLine;
k = Knob(w, size @ size);
k.action = {arg v,x,y; v.value.postln; txt.string_("value: " ++ v.value); };
k.mouseOverAction = {|v| txt.string_("value: " ++ v.value); };
j = Knob(w, size @ size);
j.action = {arg v,x,y; j.value.postln; txt.string_("value: " ++ v.value); };
j.mouseOverAction = { txt.string_("value: " ++ j.value); };
n = NumberBox(w, 100 @ 20);
//n.setProperty(\boxColor,Color.grey(alpha:0.0));
n.value = 0.0;
)
// customize drag and drop methods
k.canReceiveDragHandler
k.canReceiveDragHandler = false; // don't accept drops
k.canReceiveDragHandler = { View.currentDrag.isFloat }; // accept only if drag is float
k.receiveDragHandler = { ("value dropped in: " ++ View.currentDrag).postln }
k.receiveDragHandler = { k.valueAction = View.currentDrag.clip(0.0, 1.0); }
k.beginDragAction = { ("drag out -> " ++ k.value).postln; }
k.beginDragAction = { k.value.asFloat; }
::
|