3 summary:: A 2D slider with support for extended wacom data
5 related:: Classes/Slider2D, Classes/TabletView
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::.
18 An instance of link::Classes/Rect::, or a link::Classes/Point:: indicating code::width@height::.
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:
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.
43 Double click, triple click ... most relevant for the code::mouseDown::, but still valid for the dragged and code::mouseUp::.
45 The wheel on the side of some mice.
47 In degrees, only on the 4d mice.
56 window = Window("2DSlider", Rect(100, 100, 140,140));
59 slider = TabletSlider2D(window, Rect(20, 20,80, 80))
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)
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)
85 [\sliderX, sl.x, \sliderY, sl.y].postln;
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);
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;
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);
114 RLPF.ar(Mix.ar(p),freq * ffreqInterval.midiratio,rq)
115 * EnvGen.kr(Env.adsr, gate, gate)
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;
130 \ffreqInterval, int.map(pressure),
131 \gate, pressure.postln
135 v.mouseDownAction = { arg view, x, y, pressure;
137 \freq , rrand(30,80).midicps,
138 \gate, pressure.postln
141 v.mouseUpAction = { arg view, x, y, pressure;
142 synth.set(\gate, 0.postln)