Removing an old, cherished, yet pointless caveat "This documentation is
[supercollider.git] / Help / GUI / Cocoa-GUI / SC2DTabletSlider.html
blob7c78308d34fd3b43fe67634f8d912b00570e7fd4
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <meta http-equiv="Content-Style-Type" content="text/css">
6 <title></title>
7 <meta name="Generator" content="Cocoa HTML Writer">
8 <meta name="CocoaVersion" content="949.43">
9 <style type="text/css">
10 p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}
11 p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px}
12 p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; color: #001bec}
13 p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Helvetica}
14 p.p5 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 9.0px Monaco; min-height: 12.0px}
15 p.p6 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 12.0px Helvetica}
16 p.p7 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 12.0px Helvetica; min-height: 14.0px}
17 p.p8 {margin: 0.0px 0.0px 0.0px 85.0px; text-indent: -85.0px; font: 12.0px Helvetica}
18 p.p9 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 14.0px Helvetica}
19 p.p10 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; min-height: 12.0px}
20 p.p11 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco}
21 p.p12 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #96251f}
22 p.p13 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #606060}
23 span.s1 {font: 18.0px Helvetica}
24 span.s2 {color: #000000}
25 span.s3 {color: #3d57c3}
26 span.s4 {text-decoration: underline}
27 span.s5 {color: #5061b0}
28 span.s6 {color: #6f7178}
29 span.s7 {color: #0021b6}
30 span.s8 {color: #606060}
31 span.s9 {color: #426d13}
32 span.Apple-tab-span {white-space:pre}
33 </style>
34 </head>
35 <body>
36 <p class="p1"><span class="s1"><b>SC2DTabletSlider<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b></span><b>a 2D slider with support for extended wacom data</b><span class="s1"><b><span class="Apple-tab-span"> </span></b></span></p>
37 <p class="p2"><br></p>
38 <p class="p3"><span class="s2"><b>Inherits from: </b><a href="../../Core/Object.html"><b>Object</b></a><b> : </b><a href="SCView.html"><b>SCView</b></a><b> : </b><a href="SCControlView.html"><span class="s3"><b>SCControlView</b></span></a><b> : </b><a href="SCSliderBase.html"><b>SCSliderBase</b></a><b> : </b><a href="SC2DSlider.html"><b>SC2DSlider</b></a></span></p>
39 <p class="p2"><br></p>
40 <p class="p3"><span class="s2"><b>See also:</b> <a href="SC2DSlider.html"><span class="s4">SC2DSlider</span></a>, <a href="SCTabletView.html"><span class="s4">SCTabletView</span></a></span></p>
41 <p class="p2"><br></p>
42 <p class="p4"><b>Some Important Issues Concerning SC2DTabletSlider</b></p>
43 <p class="p2"><br></p>
44 <p class="p1">Inherits much of its behavior form SC2DSlider and SCSliderBase. Drag and drop returns and accepts a <a href="../../Geometry/Point.html"><span class="s5">Point</span></a>.</p>
45 <p class="p2"><br></p>
46 <p class="p4"><b>Creation / Class Methods</b></p>
47 <p class="p5"><br></p>
48 <p class="p6"><b><span class="Apple-tab-span"> </span>*new (parent, bounds)</b></p>
49 <p class="p7"><b><span class="Apple-tab-span"> </span></b></p>
50 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>parent </b>- The parent view.</p>
51 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>bounds </b>- An instance of <a href="../../Geometry/Rect.html"><span class="s6">Rect</span></a>, or a <a href="../../Geometry/Point.html"><span class="s6">Point</span></a> indicating width@height.</p>
52 <p class="p5"><br></p>
53 <p class="p9"><b>Accessing Instance and Class Variables</b></p>
54 <p class="p7"><span class="Apple-tab-span"> </span></p>
55 <p class="p6"><b><span class="Apple-tab-span"> </span>mouseDown (x, y, pressure, tiltx, tilty, deviceID, buttonNumber, clickCount, absoluteZ, rotation)</b></p>
56 <p class="p6"><b><span class="Apple-tab-span"> </span>mouseUp (x, y, pressure, tiltx, tilty, deviceID, buttonNumber, clickCount, absoluteZ, rotation)</b></p>
57 <p class="p6"><b><span class="Apple-tab-span"> </span>doAction (x, y, pressure, tiltx, tilty, deviceID, buttonNumber, clickCount, absoluteZ, rotation)</b></p>
58 <p class="p7"><b><span class="Apple-tab-span"> </span></b></p>
59 <p class="p1"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>Each of the three actions are passed the following wacom tablet values:</p>
60 <p class="p1"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>view</b> - the view</p>
61 <p class="p1"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>x</b> - 0..1 value</p>
62 <p class="p1"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>y</b> - 0..1 value</p>
63 <p class="p1"><span class="Apple-tab-span"> </span><b><span class="Apple-tab-span"> </span>pressure - </b>0..1</p>
64 <p class="p1"><span class="Apple-tab-span"> </span><b><span class="Apple-tab-span"> </span>tiltX - </b>0..1 where available</p>
65 <p class="p1"><span class="Apple-tab-span"> </span><b><span class="Apple-tab-span"> </span>tiltY - </b>0..1 where available</p>
66 <p class="p1"><span class="Apple-tab-span"> </span><b><span class="Apple-tab-span"> </span>deviceID - </b>will be used to look up if the tip or the eraser is used</p>
67 <p class="p1"><span class="Apple-tab-span"> </span><b><span class="Apple-tab-span"> </span>buttonNumber - </b>0 left, 1 right, 2 middle wheel click</p>
68 <p class="p1"><span class="Apple-tab-span"> </span><b><span class="Apple-tab-span"> </span>clickCount - </b>double click, triple click ...</p>
69 <p class="p1"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>most relevant for the mouseDown, but still valid for the dragged and mouseUp</p>
70 <p class="p1"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>absoluteZ</b> - the wheel on the side of some mice</p>
71 <p class="p1"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>rotation</b> - in degrees, only on the 4d mice</p>
72 <p class="p5"><br></p>
73 <p class="p9"><b>Examples</b></p>
74 <p class="p10"><br></p>
75 <p class="p11">(</p>
76 <p class="p11"><span class="s7">var</span> window;</p>
77 <p class="p11"><span class="s7">var</span> slider;</p>
78 <p class="p10"><br></p>
79 <p class="p11">window = <span class="s7">Window</span>(<span class="s8">"2DSlider"</span>, <span class="s7">Rect</span>(100,100, 140 ,140));</p>
80 <p class="p11">window.front;</p>
81 <p class="p10"><br></p>
82 <p class="p11"><span class="Apple-tab-span"> </span>slider = <span class="s7">TabletSlider2D</span>(window, <span class="s7">Rect</span>(20, 20,80, 80))</p>
83 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>.x_(0.5).y_(1);</p>
84 <p class="p11"><span class="Apple-tab-span"> </span>slider.mouseDownAction = { <span class="s7">arg</span> view,x,y,pressure,tiltx,tilty,deviceID, buttonNumber,clickCount;</p>
85 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>[<span class="s8">"down"</span>,view,x,y,pressure,tiltx,tilty,deviceID, buttonNumber,clickCount].postln;</p>
86 <p class="p11"><span class="Apple-tab-span"> </span>};<span class="Apple-tab-span"> </span></p>
87 <p class="p11"><span class="Apple-tab-span"> </span>slider.action = { <span class="s7">arg</span> view,x,y,pressure,tiltx,tilty,deviceID, buttonNumber,clickCount;</p>
88 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>[view,x,y,pressure,tiltx,tilty,deviceID, buttonNumber,clickCount].postln;</p>
89 <p class="p11"><span class="Apple-tab-span"> </span>};</p>
90 <p class="p11"><span class="Apple-tab-span"> </span>slider.mouseUpAction = { <span class="s7">arg</span> view,x,y,pressure,tiltx,tilty,deviceID, buttonNumber,clickCount;</p>
91 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>[<span class="s8">"up"</span>,view,x,y,pressure,tiltx,tilty,deviceID, buttonNumber,clickCount].postln;</p>
92 <p class="p11"><span class="Apple-tab-span"> </span>};</p>
93 <p class="p11"><span class="Apple-tab-span"> </span>slider.setProperty(<span class="s9">\clipInBounds</span>,0)</p>
94 <p class="p11">)</p>
95 <p class="p10"><br></p>
96 <p class="p12">// drag an drop Points</p>
97 <p class="p11">(</p>
98 <p class="p10"><br></p>
99 <p class="p11">w = <span class="s7">Window</span>(<span class="s8">"TabletSlider2D"</span>, <span class="s7">Rect</span>(100,100, 500 ,300));</p>
100 <p class="p11">w.view.decorator = <span class="s7">FlowLayout</span>(w.view.bounds);</p>
101 <p class="p10"><br></p>
102 <p class="p11">t = <span class="s7">TabletSlider2D</span>(w, <span class="s7">Rect</span>(20, 20,280, 280))</p>
103 <p class="p12"><span class="s2"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>.x_(0.5)<span class="Apple-tab-span"> </span></span>// initial location of x</p>
104 <p class="p12"><span class="s2"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>.y_(1)<span class="Apple-tab-span"> </span></span>// initial location of y</p>
105 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>.knobColor_(<span class="s7">Color</span>.rand)</p>
106 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>.action_({<span class="s7">|sl|</span></p>
107 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>[<span class="s9">\sliderX</span>, sl.x, <span class="s9">\sliderY</span>, sl.y].postln;</p>
108 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>});</p>
109 <p class="p11">t.step_(0.01);</p>
110 <p class="p10"><br></p>
111 <p class="p11">n=<span class="s7">CompositeView</span>.new(w, 200@300);</p>
112 <p class="p11">n.decorator= <span class="s7">FlowLayout</span>(n.bounds);</p>
113 <p class="p10"><br></p>
114 <p class="p11">v = { <span class="s7">|i|</span> <span class="s7">DragBoth</span>(n, <span class="s7">Rect</span>(0, i * 20, 200, 20)).align_(<span class="s9">\center</span>).background_(<span class="s7">Color</span>.rand) }.dup(5);</p>
115 <p class="p13"><span class="s7">StaticText</span><span class="s2">.new(n,200@150).string_(</span>"hold down cmd and drag points from the slider to the drag slots, or reverse"<span class="s2">).stringColor_(</span><span class="s7">Color</span><span class="s2">.white);<span class="Apple-tab-span"> </span></span></p>
116 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
117 <p class="p11">w.front;</p>
118 <p class="p11">)</p>
119 <p class="p10"><br></p>
120 <p class="p12">// sound example</p>
121 <p class="p10"><br></p>
122 <p class="p11">(</p>
123 <p class="p11">s.waitForBoot({</p>
124 <p class="p10"><span class="Apple-tab-span"> </span></p>
125 <p class="p11"><span class="Apple-tab-span"> </span><span class="s7">var</span> w, v,int,synth;</p>
126 <p class="p10"><span class="Apple-tab-span"> </span></p>
127 <p class="p11"><span class="Apple-tab-span"> </span>synth=<span class="s7">SynthDef</span>(<span class="s8">"help-TabletSlider2D"</span>,{ <span class="s7">arg</span> freq=440,int1=5,int2 = -5,</p>
128 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>ffreqInterval=0,rq=0.4,gate=0.0;</p>
129 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s7">var</span> p,c,d,f;</p>
130 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>c=<span class="s7">LFNoise1</span>.kr(0.1,0.45,0.55);</p>
131 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>d=<span class="s7">LFNoise1</span>.kr(0.1,0.45,0.55);</p>
132 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>f=<span class="s7">LFNoise1</span>.kr(0.1,2);</p>
133 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>p=<span class="s7">Pulse</span>.ar([ freq * int1.midiratio + f , freq, freq * int2.midiratio - f],</p>
134 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>[c,d,c],0.2);</p>
135 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s7">Out</span>.ar(0,</p>
136 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s7">RLPF</span>.ar(<span class="s7">Mix</span>.ar(p),freq * ffreqInterval.midiratio,rq)</p>
137 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>* <span class="s7">EnvGen</span>.kr(<span class="s7">Env</span>.adsr, gate, gate)</p>
138 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>)</p>
139 <p class="p11"><span class="Apple-tab-span"> </span>},[0.1,0.1,0.1,0.1,0.1,<span class="s7">nil</span>]).play(s);</p>
140 <p class="p10"><span class="Apple-tab-span"> </span></p>
141 <p class="p11"><span class="Apple-tab-span"> </span>w = <span class="s7">Window</span>.new.front;</p>
142 <p class="p10"><span class="Apple-tab-span"> </span></p>
143 <p class="p11"><span class="Apple-tab-span"> </span>int = <span class="s7">ControlSpec</span>(-48,48,<span class="s9">\linear</span>,1);</p>
144 <p class="p10"><span class="Apple-tab-span"> </span></p>
145 <p class="p11"><span class="Apple-tab-span"> </span>v = <span class="s7">TabletSlider2D</span>(w,<span class="s7">Rect</span>(10,10,380,380));</p>
146 <p class="p11"><span class="Apple-tab-span"> </span>v.background = <span class="s7">Color</span>.blue.alpha_(0.2);</p>
147 <p class="p11"><span class="Apple-tab-span"> </span>v.knobColor = <span class="s7">Color</span>.red;</p>
148 <p class="p11"><span class="Apple-tab-span"> </span>v.action = { <span class="s7">arg</span> view,x,y,pressure,tiltx,tilty;</p>
149 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>synth.set(<span class="Apple-tab-span"> </span></p>
150 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s9">\int1</span>, int.map(x),</p>
151 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s9">\int2</span>, int.map(y),</p>
152 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s9">\ffreqInterval</span>, int.map(pressure),</p>
153 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s9">\gate</span>, pressure.postln</p>
154 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>);</p>
155 <p class="p11"><span class="Apple-tab-span"> </span>};</p>
156 <p class="p10"><span class="Apple-tab-span"> </span></p>
157 <p class="p11"><span class="Apple-tab-span"> </span>v.mouseDownAction = { <span class="s7">arg</span> view,x,y,pressure;</p>
158 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>synth.set(</p>
159 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s9">\freq</span> , rrand(30,80).midicps,</p>
160 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s9">\gate</span>, pressure.postln</p>
161 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>)</p>
162 <p class="p11"><span class="Apple-tab-span"> </span>};</p>
163 <p class="p11"><span class="Apple-tab-span"> </span>v.mouseUpAction = { <span class="s7">arg</span> view,x,y,pressure;</p>
164 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>synth.set( <span class="s9">\gate</span>, 0.postln )</p>
165 <p class="p11"><span class="Apple-tab-span"> </span>};</p>
166 <p class="p11">});</p>
167 <p class="p11">)</p>
168 </body>
169 </html>