clean up indentation and spacing
[supercollider.git] / HelpSource / Classes / TabletSlider2D.schelp
blob174eea8252e71c229194c3b2f3f314e5ee16b4ed
1 CLASS:: TabletSlider2D
2 redirect:: implClass
3 summary:: An extended Slider2D responding to Wacom tablet
4 categories:: GUI>Views
5 related:: Classes/TabletView
7 DESCRIPTION::
9 TabletSlider2D inherits most of its functionality from link::Classes/Slider2D::. Aside from that it receives extended wacom tablet data.
11 note:: TabletSlider2D is only available in Cocoa GUI ::
13 strong::Drag-and-drop:: returns and accepts a Point, describing the current x and y value.
15 All the strong::mouse actions:: ( link::Classes/Slider2D#-action#action::, link::Classes/View#-mouseDownAction#mouseDownAction::, and link::Classes/View#-mouseUpAction#mouseUpAction:: ) receive the following arguments:
17 table::
19 ## view || the view
21 ## x || subpixel location in view
23 ## y || subpixel location in view
25 ## pressure || 0..1
27 ## tiltX || 0 (max. left) ... 1 (max. right)
29 ## tiltY || 0 (max. down) ... 1 (max. up)
31 ## deviceID || All tablet-pointer events generated in the period between the device entering and leaving tablet proximity have the same device ID. Therefore, when working with multiple tablets / mice, you can match actions by looking at the deviceID.
33 ## buttonNumber || 0 left, 1 right, 2 middle wheel click.
35 ## clickCount || double click, triple click ... most relevant for the mouseDown, but still valid for the dragged and mouseUp
37 ## absoluteZ || the wheel on the side of some mice
39 ## rotation || in degrees. Used for example on the "4d mouse", and the "art marker". Note: on Mac OS X 10.4.11 using an Intuos3 tablet with Art Marker, the returned value must be multiplied by 1024 to actually obtain degrees (bug?).
43 CLASSMETHODS::
44 PRIVATE:: key
46 EXAMPLES::
48 SUBSECTION:: Basic use
50 code::
52 var window;
53 var slider;
55 window = Window("2DSlider", Rect(100,100, 140 ,140));
56 window.front;
58 slider = TabletSlider2D(window, Rect(20, 20,80, 80))
59     .x_(0.5).y_(1);
60 slider.mouseDownAction = { arg view,x,y,pressure,tiltx,tilty,deviceID, buttonNumber,clickCount;
61     ["down",view,x,y,pressure,tiltx,tilty,deviceID, buttonNumber,clickCount].postln;
63 slider.action = { arg view,x,y,pressure,tiltx,tilty,deviceID, buttonNumber,clickCount;
64     [view,x,y,pressure,tiltx,tilty,deviceID, buttonNumber,clickCount].postln;
66 slider.mouseUpAction = { arg view,x,y,pressure,tiltx,tilty,deviceID, buttonNumber,clickCount;
67     ["up",view,x,y,pressure,tiltx,tilty,deviceID, buttonNumber,clickCount].postln;
69 slider.setProperty(\clipInBounds,0)
73 SUBSECTION:: Drag and 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 SUBSECTION:: A sound example
101 code::
103 s.waitForBoot({
105     var w, v,int,synth;
107     synth=SynthDef("help-TabletSlider2D",{ arg freq=440,int1=5,int2 = -5,
108                 ffreqInterval=0,rq=0.4,gate=0.0;
109         var p,c,d,f;
110         c=LFNoise1.kr(0.1,0.45,0.55);
111         d=LFNoise1.kr(0.1,0.45,0.55);
112         f=LFNoise1.kr(0.1,2);
113         p=Pulse.ar([ freq * int1.midiratio + f , freq, freq * int2.midiratio - f],
114                 [c,d,c],0.2);
115         Out.ar(0,
116             RLPF.ar(Mix.ar(p),freq * ffreqInterval.midiratio,rq)
117                 * EnvGen.kr(Env.adsr, gate, gate)
118         )
119     },[0.1,0.1,0.1,0.1,0.1,nil]).play(s);
121     w = Window.new.front;
123     int = ControlSpec(-48,48,\linear,1);
125     v = TabletSlider2D(w,Rect(10,10,380,380));
126     v.background = Color.blue.alpha_(0.2);
127     v.knobColor = Color.red;
128     v.action = { arg view,x,y,pressure,tiltx,tilty;
129         synth.set(
130                 \int1, int.map(x),
131                 \int2, int.map(y),
132                 \ffreqInterval, int.map(pressure),
133                 \gate, pressure.postln
134             );
135     };
137     v.mouseDownAction = { arg view,x,y,pressure;
138         synth.set(
139                 \freq , rrand(30,80).midicps,
140                 \gate, pressure.postln
141             )
142     };
143     v.mouseUpAction = { arg view,x,y,pressure;
144         synth.set( \gate, 0.postln )
145     };