File.exists: use boost::filesystem::exists
[supercollider.git] / HelpSource / Classes / TabletSlider2D.schelp
blob9af307e8a1f45c3372dfb11b299cc658f9bc6a06
1 class:: TabletSlider2D
2 redirect:: implClass
3 summary:: A 2D slider with support for extended wacom data
4 categories:: GUI
5 related:: Classes/Slider2D, Classes/TabletView
7 description::
8 subsection:: Some Important Issues Concerning TabletSlider2D
10 Inherits much of its behavior form link::Classes/Slider2D:: and link::Classes/SCSliderBase::. Drag and drop returns and accepts a link::Classes/Point::.
12 classmethods::
14 method:: new
15 argument:: parent
16 The parent view.
17 argument:: bounds
18 An instance of link::Classes/Rect::, or a link::Classes/Point:: indicating code::width@height::.
20 instancemethods::
22 method:: mouseDown (x, y, pressure, tiltx, tilty, deviceID, buttonNumber, clickCount, absoluteZ, rotation)
23 method:: mouseUp (x, y, pressure, tiltx, tilty, deviceID, buttonNumber, clickCount, absoluteZ, rotation)
24 method:: doAction (x, y, pressure, tiltx, tilty, deviceID, buttonNumber, clickCount, absoluteZ, rotation)
25 Each of the three actions are passed the following wacom tablet values:
26 argument:: view
27 The view.
28 argument:: x
29 0..1 value.
30 argument:: y
31 0..1 value.
32 argument:: pressure
33 0..1 value.
34 argument:: tiltx
35 0..1 where available.
36 argument.: tilty
37 0..1 where available.
38 argument:: deviceID
39 Will be used to look up if the tip or the eraser is used.
40 argument:: buttonNumber
41 0 left, 1 right, 2 middle wheel click.
42 argument:: clickCount
43 Double click, triple click ... most relevant for the code::mouseDown::, but still valid for the dragged and code::mouseUp::.
44 argument:: absoluteZ
45 The wheel on the side of some mice.
46 argument:: rotation
47 In degrees, only on the 4d mice.
49 examples::
51 code::
53 var window;
54 var slider;
56 window = Window("2DSlider", Rect(100, 100, 140,140));
57 window.front;
59 slider = TabletSlider2D(window, Rect(20, 20,80, 80))
60                 .x_(0.5).y_(1);
61 slider.mouseDownAction = { arg view, x, y, pressure, tiltx, tilty, deviceID, buttonNumber, clickCount;
62         ["down", view, x, y, pressure, tiltx, tilty, deviceID, buttonNumber, clickCount].postln;
64 slider.action = { arg view, x, y, pressure, tiltx, tilty, deviceID, buttonNumber, clickCount;
65         [view, x, y, pressure, tiltx, tilty, deviceID, buttonNumber, clickCount].postln;
67 slider.mouseUpAction = { arg view, x, y, pressure, tiltx, tilty, deviceID, buttonNumber, clickCount;
68         ["up", view, x, y, pressure, tiltx, tilty, deviceID, buttonNumber, clickCount].postln;
70 slider.setProperty(\clipInBounds, 0)
74 Drag an drop Points
75 code::
77 w = Window("TabletSlider2D", Rect(100, 100, 500, 300));
78 w.view.decorator = FlowLayout(w.view.bounds);
80 t = TabletSlider2D(w, Rect(20, 20, 280, 280))
81                 .x_(0.5) // initial location of x
82                 .y_(1)   // initial location of y
83                 .knobColor_(Color.rand)
84                 .action_({|sl|
85                         [\sliderX, sl.x, \sliderY, sl.y].postln;
86                 });
87 t.step_(0.01);
89 n = CompositeView.new(w, 200@300);
90 n.decorator = FlowLayout(n.bounds);
92 v = { |i| DragBoth(n, Rect(0, i * 20, 200, 20)).align_(\center).background_(Color.rand) }.dup(5);
93 StaticText.new(n,200@150).string_("hold down cmd and drag points from the slider to the drag slots, or reverse").stringColor_(Color.white);
95 w.front;
99 Sound example
100 code::
102 s.waitForBoot({
103         var w, v, int, synth;
105         synth = SynthDef("help-TabletSlider2D", { arg freq = 440,int1 = 5,int2 = -5,
106                                                       ffreqInterval = 0, rq = 0.4, gate = 0.0;
107                 var p,c,d,f;
109                 c = LFNoise1.kr(0.1, 0.45, 0.55);
110                 d = LFNoise1.kr(0.1, 0.45, 0.55);
111                 f = LFNoise1.kr(0.1, 2);
112                 p = Pulse.ar([ freq * int1.midiratio + f, freq, freq * int2.midiratio - f], [c, d, c], 0.2);
113                 Out.ar(0,
114                         RLPF.ar(Mix.ar(p),freq * ffreqInterval.midiratio,rq)
115                                 * EnvGen.kr(Env.adsr, gate, gate)
116                 )
117         }, [0.1, 0.1, 0.1, 0.1, 0.1, nil]).play(s);
119         w = Window.new.front;
121         int = ControlSpec(-48, 48, \linear, 1);
123         v = TabletSlider2D(w, Rect(10, 10, 380, 380));
124         v.background = Color.blue.alpha_(0.2);
125         v.knobColor = Color.red;
126         v.action = { arg view, x, y, pressure, tiltx, tilty;
127                 synth.set(
128                         \int1, int.map(x),
129                         \int2, int.map(y),
130                         \ffreqInterval, int.map(pressure),
131                         \gate, pressure.postln
132                 );
133         };
135         v.mouseDownAction = { arg view, x, y, pressure;
136                 synth.set(
137                         \freq , rrand(30,80).midicps,
138                         \gate, pressure.postln
139                 )
140         };
141         v.mouseUpAction = { arg view, x, y, pressure;
142                 synth.set(\gate, 0.postln)
143         };