EZKnobOld a composite gui control with a Knob


EZKnobOld.new(window, dimensions, label, controlSpec, action, initVal, 

initAction, labelWidth, numberWidth, centered, back)

window - parent

dimensions - a Point that specifies the Knob's size @ label and number height. defaults to 32 @ 16

label - the control's caption

controlSpec - the control's spec

action - a function to be evaluated when the control is changed

initVal, - the control's initial value

initAction - perform action on creation.

labelWidth = 40 - the label's width

numberWidth = 40 - number width

centered=false - Knob's center mode

back - background color

value - set or get the control's value.

set(label, spec, argAction, initVal, initAction=false)

centered_(bool) - true places the knob in centered mode.

visible_(bool) - show/hide the control

enabled_(bool) - enable/disable the control

enabled -  bool. control's state

labelView - the label control

knobView -  the Knob control

numberView - the number control


Warning: EZKnob replaces the EZKnob Quark, which is now called EZKnobOld.  It is encouraged to update your code. The two classes have different creation methods and approaches, particularly concerning the dimensions (now bounds). To make the conversion process easier,  EZKnobOld has an instance method called convert which will post the equivallent creation code for the new EZKnob.


Behavior:

The Knob's default tracking mode is \round.

Pressing the Control key and drag places the knob temporarily into \vert tracking mode.

Pressing the Option key and drag places the knob temporarily into \horiz tracking mode.

Pressing the Command or Apple key drags out the knob's value. like for other views.


In \round mode, draging farther from the knob's center increases the control's precision.


see also: [Knob], [KnobEditor]


// example

(

w = SCWindow("EZKnobOld", Rect(380,400,300,180)).front;

w.view.decorator = FlowLayout(w.view.bounds);

k = EZKnobOld(w, 32 @ 16, "Knob", action: { arg knb; knb.value.postln; });

)

k.centered_(true)

k.value=0.5;

k.visible_(false)

k.visible_(true)


k.enabled_(false)

k.value = 0.1

k.enabled

k.enabled_(true)

k.value = 0.25


(

w = SCWindow("EZKnobOld", Rect(380,400,300,180)).front;

w.view.decorator = FlowLayout(w.view.bounds, gap: 1@1);

SCStaticText(w, (42 * 4 + 3) @ 16).string_("EZKnob Cluster").background_(Color.blue(0.1,0.1));

w.view.decorator.nextLine;

a = [

EZKnobOld(w, 32 @ 16, "knob 1"),

EZKnobOld(w, 32 @ 16, "knob 2", controlSpec: \freq),

EZKnobOld(w, 32 @ 16, "knob 3", controlSpec: \pan, centered: true).round_(0.001),

EZKnobOld(w, 32 @ 16, "knob 4", controlSpec: \rq)

];

)

// a now holds the array of knobs

a

a[0].value

a[3].value_(0.5)

a.collect(_.value );


// different sizes

(

w = SCWindow("EZKnob Old", Rect(380,400,350,180)).front;

w.view.decorator = FlowLayout(w.view.bounds);

a = EZKnobOld(w, 48 @ 16, "ez knob1", action: { arg v; v.value.postln }, initVal: 0.25, labelWidth:60, numberWidth:60);

a.labelView.align = \left;

b = EZKnobOld(w, 32 @ 16, "ez knob2", labelWidth:80, numberWidth:80, initVal: 0.5, centered: true);

c = EZKnobOld(w, 64 @ 16, "ez knob3", labelWidth:80, numberWidth:80);

d = EZKnobOld(w, 52 @ 16, "ez knob4", labelWidth:52, numberWidth:52);

)

a.value = 0

b.value = 0.15

c.value = 0.25

c.visible = false

c.visible = true

c.centered = true


// on Sheet

Sheet({ arg l; k = Array.fill(4, { arg i; EZKnobOld.new(l, 45@16, "Knob" + (i+1)) }) }, "EZKnob");


k.collect(_.value);