EZKnob:
Filter:
Classes | GUI > EZ-GUI

EZKnob : EZGui : Object

Wrapper class for label, knob, number box
Source: EZKnob.sc

Description

EZKnob is wrapper class which creates an (optional) StaticText, and a Knob plus a NumberBox. If the parent is nil, then EZKnob will create its own window. See EZGui more options.

Some Important Issues Regarding NumberBox

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 equivalent creation code for the new EZKnob.
NOTE: Bounds: Make certain to choose bounds that are large enough to encompass the knob, the number box, and the label (if you use one), otherwise you may get confusing results. See the examples below.

Class Methods

EZKnob.new(parent, bounds, label, controlSpec, action, initVal, initAction: false, labelWidth: 60, knobSize, unitWidth: 0, labelHeight: 20, layout: 'vert', gap, margin)

Arguments:

parent

The parent view or window. If the parent is nil, then EZKnob will create its own Window, and place it conveniently on the screen if the bounds are a Point. If the bounds are a Rect, then the Rect determines the window bounds.

bounds

An instance of Rect or Point. Default value is 160@20. Make certain to choose bounds that are large enough to encompass the knob, the number box, and the label (if you use one), otherwise you may get confusing results. See the examples below.

label

The label. Default value is nil. If nil, then no StaticText is created.

controlSpec

The ControlSpec for scaling the value. If the minVal + maxVal of the spec is 0, then centered will be set to true automatically.

action

A Function called when the value changes. The function is passed the EZKnob instance as its argument.

initVal

The value to initialize the knob and number box with. If nil, then it uses the ControlSpec's default value.

initAction

A Boolean indicating whether the action function should be called when setting the initial value. The default is false.

labelWidth

Number of pixels width for the label. default is 60. This is only valid for the \horz layout.

knobSize

An instance of Point. It will adjust itself to maximize the space use of width/height. By default, it uses the maximum available height, and adjusts the width accordingly.

unitWidth

Number of pixels width for the unit label. Default is 0. If 0, then no unitLabel is created.

labelHeight

Default is 20.

layout

\vert, vert2, \line2, or \horz. default is \vert.

gap

A Point. By default, the view tries to get its parent's gap, otherwise it defaults to 2@2. Setting it overrides these.

margin

A Point. This will inset the bounds occupied by the subviews of view.

Discussion:

The contained views can be accessed via the EZKnob instance variables: labelView, knobView, numberView.

Inherited class methods

Undocumented class methods

EZKnob.compactRatio

EZKnob.compactRatio = value

Instance Methods

Accessing Instance Variables

.numberView

Returns:

the numberView

.knobView

Returns:

the knobView

.labelView

.labelView = value

From superclass: EZGui

Set/get the labelView

.action

.action = value

From superclass: EZGui

A function to be evaluated when the value changes. Te first argument will be the EZKnob.

Arguments:

(arg1)

An instance of Function or FunctionList. Default value is nil.

.value

.value = val

From superclass: EZGui

The value of the knob

.centered

.centered = bool

Sets/gets whether the knob is in centered mode. See Knob.

.round

.round = value

Rounds the values in the number box.

.controlSpec

.controlSpec = value

An instance of ControlSpec for scaling the values.

.value

.value = val

From superclass: EZGui

Gets/sets the list/menu to the index at value. Does not perform the action.

Arguments:

val

An Integer.

.doAction

Performs the action at the current index and the global action.

.set(label, spec, argAction, initVal, initAction: false)

Set the args after creation. You can only set the label if it was not nil from the beginning.

.visible

.visible = bool

From superclass: EZGui

Sets/gets if the component views are visible.

Arguments:

bool

An instance of Boolean. Default is true.

Changing Appearance

.setColors(stringBackground, stringColor, numBackground, numStringColor, numNormalColor, numTypingColor, knobColors, background)

Arguments:

stringBackground

An instance of Color. The background of the label and unit views.

stringColor

An instance of Color. The stringColor of the label and unit views.

numBackground

An instance of Color. The numColor of the number view.

numStringColor

An instance of Color. The stringColor of the number view.

numNormalColor

An instance of Color. The normalColor of the number view.

numTypingColor

An instance of Color. The typingColor of the number view.

knobColors

An instance of Color. The knobColors of the knob view.

background

An instance of Color. The background of the enclosing view.

.font = font

Set the Font used by all the views.

Arguments:

font

An instance of Font.

Inherited instance methods

Undocumented instance methods

.prSetViewParams

.prSubViewBounds(rect, hasLabel, hasUnit)

.unitView

.valueAction = val

Examples