1 <!DOCTYPE html PUBLIC
"-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
4 <meta http-equiv=
"Content-Type" content=
"text/html; charset=UTF-8">
5 <meta http-equiv=
"Content-Style-Type" content=
"text/css">
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: #001ee6}
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 0.0px; font: 14.0px Helvetica
; min-height: 17.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 85.0px; text-indent: -85.0px; font: 12.0px Helvetica
; min-height: 14.0px}
19 p
.p10
{margin: 0.0px 0.0px 0.0px 85.0px; text-indent: -85.0px; font: 9.0px Monaco
; color: #000000}
20 p
.p11
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 9.0px Monaco
; min-height: 12.0px}
21 p
.p12
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 14.0px Helvetica
}
22 p
.p13
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 14.0px Helvetica
; min-height: 17.0px}
23 p
.p14
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
}
24 p
.p15
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; min-height: 12.0px}
25 p
.p16
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #000000; min-height: 12.0px}
26 p
.p17
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #bf0000}
27 p
.p18
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #000000}
28 p
.p19
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #0000bf}
29 p
.p20
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #606060}
30 span
.s1
{font: 18.0px Helvetica
}
31 span
.s2
{color: #000000}
32 span
.s3
{color: #5c5e65}
33 span
.s4
{font: 9.0px Monaco
}
34 span
.s5
{color: #0000bf}
35 span
.s6
{color: #606060}
36 span
.s7
{color: #1638e6}
37 span
.s8
{color: #0c2eee}
38 span
.s9
{color: #1129ac}
39 span
.s10
{color: #516a24}
40 span
.s11
{font: 14.0px Helvetica
}
41 span
.s12
{color: #007300}
42 span
.s13
{color: #bf0000}
43 span
.Apple-tab-span
{white-space:pre
}
47 <p class=
"p1"><span class=
"s1"><b>SCKnob
<span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b></span><b>a gui control with round, horizontal or vertical action
</b><span class=
"s1"><b><span class=
"Apple-tab-span"> </span></b></span></p>
48 <p class=
"p2"><br></p>
49 <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=
"SCUserView.html"><b>SCUserView
</b></a></span></p>
50 <p class=
"p2"><br></p>
51 <p class=
"p1"><b>See also:
</b> EZKnob
</p>
52 <p class=
"p2"><br></p>
53 <p class=
"p4"><b>Creation / Class Methods
</b></p>
54 <p class=
"p5"><br></p>
55 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>*new (parent, bounds)
</b></p>
56 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span></b></p>
57 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>parent
</b>- The parent view.
</p>
58 <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=
"s3">Rect
</span></a>, or a
<a href=
"../../Geometry/Point.html"><span class=
"s3">Point
</span></a> indicating width@height.
</p>
59 <p class=
"p9"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
60 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s4">(
</span></p>
61 <p class=
"p10"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>w=
<span class=
"s5">Window
</span>.new(
<span class=
"s6">"Knob"</span>,
<span class=
"s5">Rect
</span>(
640,
630,
270,
70)).front;
</p>
62 <p class=
"p10"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>k =
<span class=
"s5">Knob
</span>.new(w,
<span class=
"s5">Rect
</span>(
20,
10,
48,
48));
</p>
63 <p class=
"p10"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>k.action_({
<span class=
"s5">|v,x,y,m|
</span> postf(
<span class=
"s6">"action func called: %\n"</span>, v.value); });
</p>
64 <p class=
"p10"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s2">)
</span></p>
65 <p class=
"p11"><br></p>
66 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>*defaultMode
</b></p>
67 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>*defaultMode_(val)
</b></p>
68 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span></b></p>
69 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>Class variable that states the default tracking mode for new knobs..
</p>
70 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>val
</b> - An instance of
<a href=
"../../Core/Symbol.html"><span class=
"s7">Symbol
</span></a>. \vert, \round, or \horiz. Default value is \round.
</p>
71 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
72 <p class=
"p12"><b>Accessing Instance and Class Variables
</b></p>
73 <p class=
"p13"><br></p>
74 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>centered
</b></p>
75 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>centered_ (bool)
</b></p>
76 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span></b></p>
77 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b>If true, the knob's center scale,
0.5 is zero in the value scale. eg. as in a pan control. .
</p>
78 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>bool
</b>- An instance of
<a href=
"../../Core/Boolean.html"><span class=
"s8">Boolean
</span></a>.
<span class=
"Apple-converted-space"> </span>Default is false.
</p>
79 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
80 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>mode
</b></p>
81 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>mode_(arg1)
</b></p>
82 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span></b><span class=
"Apple-tab-span"> </span></p>
83 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>The knob's tracking mode .
</p>
84 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>arg1
</b> - An instance of
<a href=
"../../Core/Symbol.html"><span class=
"s8">Symbol
</span></a>. \round, \horiz or \vert. Default
<span class=
"Apple-converted-space"> </span>is
<span class=
"Apple-converted-space"> </span>\round .
</p>
85 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
86 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>value
</b></p>
87 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>value_ (val)
</b></p>
88 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b></p>
89 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>Gets/sets the the
<b>value
</b>. This will not do the
<b>action
</b>.
</p>
90 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>val
</b> -
<span class=
"Apple-converted-space"> </span>A
<a href=
"../../Math/Number.html"><span class=
"s8">Number
</span></a>.
</p>
91 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span></b></p>
92 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>valueAction_ (val)
</b></p>
93 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span></b></p>
94 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>Sets the
<b>value
</b>. Does the
<b>action
</b>.
</p>
95 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>val
</b> -
<span class=
"Apple-converted-space"> </span>A Number.
</p>
96 <p class=
"p7"><br></p>
97 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>keystep
</b></p>
98 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>keystep_(arg1)
</b></p>
99 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span></b><span class=
"Apple-tab-span"> </span></p>
100 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>The step by which the value is incremented/decremented with the keyboard.
</p>
101 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>arg1
</b> - A
<a href=
"../../Math/Float.html"><span class=
"s7">Float
</span></a>. Default is
0.01.
</p>
102 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
103 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>step
</b></p>
104 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>step_(arg1)
</b></p>
105 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span></b><span class=
"Apple-tab-span"> </span></p>
106 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>The step in which the value is incremented/decremented while draging in \horiz and \vert modes.
</p>
107 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>arg1
</b> - A
<a href=
"../../Math/Float.html"><span class=
"s7">Float
</span></a>. Default is
0.01.
</p>
108 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
109 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>increment
</b></p>
110 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>decrement
</b></p>
111 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span></b></p>
112 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b>Increments or decrements the
<b>value
</b> by
<b>keystep
</b>.
</p>
113 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
114 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>refresh
</b></p>
115 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
116 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>Redraws the knob
</p>
117 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
118 <p class=
"p12"><b>Customizing Appearance
</b></p>
119 <p class=
"p7"><br></p>
120 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>color_(arg1)
</b></p>
121 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>color
</b></p>
122 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span></b><span class=
"Apple-tab-span"> </span></p>
123 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>arg1
</b> - An
<a href=
"../../Collections/Array.html"><span class=
"s7">Array
</span></a> of
<a href=
"../GUI-Tools/Color.html"><span class=
"s7">Color
</span></a>s: [center Color,
<span class=
"Apple-converted-space"> </span>value Color, range Color, dial Color].
</p>
124 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
125 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>skin
</b></p>
126 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>skin_ (newskin)
</b></p>
127 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span></b></p>
128 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b>Get, set the skin of the knob.
<span class=
"Apple-converted-space"> </span>See
<b>Examples
</b> below for how to set
<span class=
"Apple-converted-space"> </span>a skin.
<span class=
"Apple-converted-space"> </span></p>
129 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>newskin
</b>- An instance of Symobl. The default is \default:
</p>
130 <p class=
"p9"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
131 <p class=
"p14"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>(
</p>
132 <p class=
"p14"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>scale:
<span class=
"Apple-tab-span"> </span><span class=
"s9">Color
</span>.black.alpha_(
0.3),
</p>
133 <p class=
"p14"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>center:
<span class=
"Apple-tab-span"> </span><span class=
"s9">Color
</span>.blue(
0.7,
0.5),
</p>
134 <p class=
"p14"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>level:
<span class=
"Apple-tab-span"> </span><span class=
"s9">Color
</span>.green(
0.8,
0.8),
</p>
135 <p class=
"p14"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>dial:
<span class=
"Apple-tab-span"> </span><span class=
"s9">Color
</span>.black.alpha_(
0.7),
</p>
136 <p class=
"p14"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>defaultMode:
<span class=
"s10">'round'
</span></p>
137 <p class=
"p14"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>)
</p>
138 <p class=
"p15"><span class=
"Apple-tab-span"> </span></p>
139 <p class=
"p12"><b>Subclassing and Internal Methods
</b></p>
140 <p class=
"p6"><span class=
"s11"><span class=
"Apple-tab-span"> </span></span>The following methods are usually not used directly or are called by a primitive. Programmers can still call or override these as needed.
</p>
141 <p class=
"p7"><span class=
"Apple-tab-span"> </span></p>
142 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>defaultKeyDownAction (char, modifiers, unicode)
</b></p>
143 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span></b></p>
144 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b>The default keydown actions are:
</p>
145 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
146 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>key
</b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>action
</b><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=
"Apple-tab-span"> </span><b>comment
</b></p>
147 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b>r
<span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>valueAction_
</b>(
1.0.rand)
<span class=
"Apple-tab-span"> </span></p>
148 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>n
<span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>valueAction_
</b>(
0)
<span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
149 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>x
<span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>valueAction_
</b>(
1)
<span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
150 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>c
<span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>valueAction_
</b>(
0.5)
<span class=
"Apple-tab-span"> </span></p>
151 <p class=
"p6"><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=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>increment by
<b>keystep
</b></p>
152 <p class=
"p6"><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=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>decrement by
<b>keystep
</b></p>
153 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>unicode
16rF700,
<span class=
"Apple-tab-span"> </span>increment by
<b>keystep
</b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>up arrow
</p>
154 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>unicode
16rF703,
<span class=
"Apple-tab-span"> </span>increment by
<b>keystep
</b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>right arrow
</p>
155 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>unicode
16rF701,
<span class=
"Apple-tab-span"> </span>decrement by
<b>keystep
</b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>down arrow
</p>
156 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>unicode
16rF702,
<span class=
"Apple-tab-span"> </span>decrement by
<b>keystep
</b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>left arrow
</p>
157 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
158 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>mouseDown (x, y, modifiers, buttonNumber, clickCount)
</b></p>
159 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>mouseMove (x, y, modifiers)
</b></p>
160 <p class=
"p11"><br></p>
161 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>*isSquare
</b></p>
162 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>*isSquare_(bool)
</b></p>
163 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>*viewClass
</b></p>
164 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>*compactRatio
</b></p>
165 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>*initClass
</b></p>
166 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>*paletteExample (parent, bounds)
</b></p>
167 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>oldMethodsCompat
</b></p>
168 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>init (argParent, argBounds)
</b></p>
169 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>bounds_ (rect)
</b></p>
170 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>calcConsts (rect)
</b></p>
171 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>draw
</b></p>
172 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span></b></p>
173 <p class=
"p12"><b>Examples
</b></p>
174 <p class=
"p16"><br></p>
175 <p class=
"p16"><br></p>
176 <p class=
"p17">// examples
</p>
178 <p class=
"p17"><span class=
"s5">var
</span><span class=
"s2"> window, size =
32;
</span>// try different sizes - from
15 to
200 or more!
</p>
179 <p class=
"p18">window =
<span class=
"s5">Window
</span>.new(
<span class=
"s6">"Knob"</span>,
<span class=
"s5">Rect
</span>(
640,
630,
270,
70)).front;
</p>
180 <p class=
"p18">k =
<span class=
"s5">Knob
</span>.new(window,
<span class=
"s5">Rect
</span>(
20,
10, size, size));
</p>
181 <p class=
"p18">k.action_({
<span class=
"s5">|v,x,y,m|
</span> postf(
<span class=
"s6">"action func called: %\n"</span>, v.value); });
</p>
182 <p class=
"p17">//k.color[
1] = Color.gray(alpha:
0);
</p>
184 <p class=
"p18">k.value
</p>
185 <p class=
"p18">k.value =
0.25</p>
186 <p class=
"p18">k.valueAction =
0.125</p>
187 <p class=
"p16"><br></p>
188 <p class=
"p17">// modes
</p>
189 <p class=
"p18">k.mode =
<span class=
"s12">\vert
</span>;
</p>
190 <p class=
"p18">k.mode =
<span class=
"s12">\horiz
</span>;
</p>
191 <p class=
"p18">k.mode =
<span class=
"s12">\round
</span>;
<span class=
"s13">// default
</span></p>
192 <p class=
"p16"><br></p>
193 <p class=
"p18">k.visible
</p>
194 <p class=
"p18">k.visible =
<span class=
"s5">false
</span></p>
195 <p class=
"p18">k.visible =
<span class=
"s5">true
</span></p>
196 <p class=
"p18">k.enabled =
<span class=
"s5">false
</span></p>
197 <p class=
"p18">k.enabled_(
<span class=
"s5">true
</span>)
</p>
198 <p class=
"p18">k.canFocus =
<span class=
"s5">false
</span></p>
199 <p class=
"p18">k.canFocus =
<span class=
"s5">true
</span></p>
200 <p class=
"p16"><br></p>
201 <p class=
"p17">// centered mode - like in a pan or eq gain control etc.
</p>
203 <p class=
"p18"><span class=
"s5">var
</span> window;
</p>
204 <p class=
"p18">window =
<span class=
"s5">Window
</span>.new(
<span class=
"s6">"Pan Knob"</span>,
<span class=
"s5">Rect
</span>(
640,
630,
270,
70)).front;
</p>
205 <p class=
"p18">k =
<span class=
"s5">Knob
</span>.new(window,
<span class=
"s5">Rect
</span>(
20,
10,
36,
36));
</p>
206 <p class=
"p18">k.action_({
<span class=
"s5">|v,x,y,m|
</span> <span class=
"s12">\pan
</span>.asSpec.map(v.value).postln; })
</p>
207 <p class=
"p17">//
<span class=
"Apple-tab-span"> </span>.mode_(\horiz)
</p>
208 <p class=
"p18"><span class=
"Apple-tab-span"> </span>.centered_(
<span class=
"s5">false
</span>)
</p>
209 <p class=
"p18"><span class=
"Apple-tab-span"> </span>.value_(
<span class=
"s12">\pan
</span>.asSpec.unmap(
0));
<span class=
"s13">//
0.5</span></p>
210 <p class=
"p17">//k.color[
1] = Color.gray(alpha:
0);
</p>
212 <p class=
"p18">k.centered
</p>
213 <p class=
"p18">k.centered =
<span class=
"s5">true
</span></p>
214 <p class=
"p18">k.centered =
<span class=
"s5">false
</span></p>
215 <p class=
"p16"><br></p>
216 <p class=
"p17">// mouseOverAction
</p>
218 <p class=
"p18"><span class=
"s5">var
</span> size =
28;
</p>
219 <p class=
"p18"><span class=
"s5">GUI
</span>.skins.default.knob.mySkin = ( );
</p>
220 <p class=
"p18">w =
<span class=
"s5">Window
</span>.new(
<span class=
"s6">"Knobs"</span>,
<span class=
"s5">Rect
</span>(
384,
630,
320,
80));
</p>
221 <p class=
"p17"><span class=
"s2">w.acceptsMouseOver=
</span><span class=
"s5">true
</span><span class=
"s2">;
</span>// true in parent window!
</p>
222 <p class=
"p18">w.view.decorator =
<span class=
"s5">FlowLayout
</span>(w.view.bounds,
10@
4,
10@
4);
</p>
223 <p class=
"p18">h =
<span class=
"s5">StaticText
</span>(w,
300 @
16).background_(
<span class=
"s5">Color
</span>.blue(
0.2,
0.1));
</p>
224 <p class=
"p18">w.view.decorator.nextLine;
</p>
225 <p class=
"p18">k =
<span class=
"s5">Array
</span>.fill(
8, {
<span class=
"s5">|item, i|
</span></p>
226 <p class=
"p18"><span class=
"Apple-tab-span"> </span><span class=
"s5">var
</span> knob;
</p>
227 <p class=
"p18"><span class=
"Apple-tab-span"> </span>knob =
<span class=
"s5">Knob
</span>.new(w, size @ size)
</p>
228 <p class=
"p17"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>//
<span class=
"Apple-tab-span"> </span>.canFocus_(false)
</p>
229 <p class=
"p18"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>.action_({
<span class=
"s5">|v,x,y,m|
</span> h.string =
<span class=
"s6">"value: "</span> ++ v.value.asString; })
</p>
230 <p class=
"p18"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>.mouseOverAction_({
<span class=
"s5">|v,x,y|
</span> h.string =
<span class=
"s6">"value: "</span> ++ v.value.asString; });
</p>
231 <p class=
"p16"><span class=
"Apple-tab-span"> </span></p>
232 <p class=
"p18"><span class=
"Apple-tab-span"> </span><span class=
"s5">GUI
</span>.skins.default.knob.mySkin.center_(
<span class=
"s5">Color
</span>.rand);
</p>
233 <p class=
"p18"><span class=
"Apple-tab-span"> </span>knob.skin_(
<span class=
"s5">GUI
</span>.skins.default.knob.mySkin );
</p>
234 <p class=
"p18"><span class=
"Apple-tab-span"> </span>knob;
</p>
235 <p class=
"p18">});
</p>
236 <p class=
"p18">w.front
</p>
238 <p class=
"p18">k.collect(
<span class=
"s5">_
</span>.value);
</p>
239 <p class=
"p16"><br></p>
240 <p class=
"p17">// step - 'horiz' and 'vert' modes only
</p>
242 <p class=
"p18"><span class=
"s5">var
</span> window, midispec;
</p>
243 <p class=
"p18">midispec = [
0,
127,
<span class=
"s12">'linear'
</span>,
1].asSpec;
</p>
244 <p class=
"p18">window =
<span class=
"s5">Window
</span>.new(
<span class=
"s6">"step Knob"</span>,
<span class=
"s5">Rect
</span>(
640,
630,
270,
70)).front;
</p>
245 <p class=
"p18">k =
<span class=
"s5">Knob
</span>.new(window,
<span class=
"s5">Rect
</span>(
20,
10,
32,
32));
</p>
246 <p class=
"p18">k.action_({
<span class=
"s5">|v,x,y,m|
</span> midispec.map(v.value).postln; })
</p>
247 <p class=
"p18"><span class=
"Apple-converted-space"> </span>.value_(midispec.unmap(
0));
</p>
248 <p class=
"p16"><br></p>
249 <p class=
"p18">k.mode =
<span class=
"s12">\vert
</span>;
</p>
250 <p class=
"p16"><br></p>
252 <p class=
"p18">k.step
</p>
253 <p class=
"p18">k.step =
10/
127 // step by
10</p>
254 <p class=
"p16"><br></p>
255 <p class=
"p18">k.mode =
<span class=
"s12">\horiz
</span>;
</p>
256 <p class=
"p18">k.mode =
<span class=
"s12">\round
</span>;
</p>
257 <p class=
"p16"><br></p>
258 <p class=
"p17">// on Sheet
</p>
260 <p class=
"p19"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>Sheet
<span class=
"s2">({
</span>arg
<span class=
"s2"> l;
</span></p>
261 <p class=
"p18"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>l.view.decorator.gap=
4@
4;
</p>
262 <p class=
"p18"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>l.view.decorator.margin=
4@
4;
</p>
263 <p class=
"p18"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>c =
<span class=
"s5">Array
</span>.fill(
8, {
<span class=
"s5">Knob
</span>.new(l,
28@
28) });
</p>
264 <p class=
"p20"><span class=
"s2"><span class=
"Apple-tab-span"> </span>},
</span>"Knob"<span class=
"s2">)
</span></p>
267 <p class=
"p18">c.collect(
<span class=
"s5">_
</span>.value);
</p>
268 <p class=
"p16"><br></p>
269 <p class=
"p17">// GUI Kit
</p>
271 <p class=
"p18"><span class=
"Apple-tab-span"> </span>f = {
</p>
272 <p class=
"p18"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s5">var
</span> size =
32;
</p>
273 <p class=
"p18"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>w =
<span class=
"s5">GUI
</span>.window.new(
<span class=
"s6">"GUI.knob Test"</span>,
<span class=
"s5">Rect
</span>(
580,
590,
300,
80));
</p>
274 <p class=
"p16"><span class=
"Apple-tab-span"> </span></p>
275 <p class=
"p18"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>k =
<span class=
"s5">GUI
</span>.knob.new(w,
<span class=
"s5">Rect
</span>(
20,
10, size, size));
</p>
276 <p class=
"p18"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>k.action_({
<span class=
"s5">|v|
</span> v.value.postln; });
</p>
277 <p class=
"p16"><span class=
"Apple-tab-span"> </span></p>
278 <p class=
"p18"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>w.front;
</p>
279 <p class=
"p18"><span class=
"Apple-tab-span"> </span>};
</p>
281 <p class=
"p16"><br></p>
282 <p class=
"p17"><span class=
"s5">GUI
</span><span class=
"s2">.cocoa;
</span>// select cocoa gui
</p>
283 <p class=
"p18">f.value;
</p>
284 <p class=
"p16"><br></p>
285 <p class=
"p17"><span class=
"s5">GUI
</span><span class=
"s2">.swing;
</span>// select swing gui
</p>
286 <p class=
"p18">f.value;
</p>
287 <p class=
"p16"><br></p>
288 <p class=
"p17">// GUI skins
</p>
289 <p class=
"p17">//
<span class=
"Apple-tab-span"> </span>default skin
</p>
290 <p class=
"p17">//
<span class=
"Apple-tab-span"> </span>GUI.skins.knob.default = (
</p>
291 <p class=
"p17">//
<span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>scale: Color.black.alpha_(
0.3),
</p>
292 <p class=
"p17">//
<span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>dial: Color.black.alpha_(
0.7),
</p>
293 <p class=
"p17">//
<span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>center: Color.blue(
0.7,
0.5),
</p>
294 <p class=
"p17">//
<span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>level: Color.green(
0.8,
0.8)
</p>
295 <p class=
"p17">//
<span class=
"Apple-tab-span"> </span>);
</p>
296 <p class=
"p16"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
297 <p class=
"p18"><span class=
"s5">GUI
</span>.skins.knob.default.level
</p>
298 <p class=
"p18"><span class=
"s5">GUI
</span>.skins.knob.default.center
</p>
299 <p class=
"p16"><br></p>
300 <p class=
"p16"><br></p>
301 <p class=
"p18"><span class=
"s5">GUI
</span>.skins.keys
</p>
302 <p class=
"p18"><span class=
"s5">GUI
</span>.skins.default.keys
</p>
303 <p class=
"p16"><br></p>
305 <p class=
"p18"><span class=
"s5">GUI
</span>.skins.default.knob.mySkin = ( );
</p>
306 <p class=
"p16"><br></p>
307 <p class=
"p19">Sheet
<span class=
"s2">({
</span>arg
<span class=
"s2"> l;
</span></p>
308 <p class=
"p16"><span class=
"Apple-tab-span"> </span></p>
309 <p class=
"p18"><span class=
"Apple-tab-span"> </span>a =
<span class=
"s5">Array
</span>.fill(
8, {
</p>
310 <p class=
"p16"><span class=
"Apple-tab-span"> </span></p>
311 <p class=
"p18"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s5">GUI
</span>.skins.default.knob.mySkin.center_(
<span class=
"s5">Color
</span>.rand);
</p>
312 <p class=
"p16"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
313 <p class=
"p18"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s5">Knob
</span>(l,
32@
32).skin_(
<span class=
"s5">GUI
</span>.skins.default.knob.mySkin );
</p>
314 <p class=
"p18"><span class=
"Apple-tab-span"> </span>})
</p>
315 <p class=
"p16"><span class=
"Apple-tab-span"> </span></p>
316 <p class=
"p20"><span class=
"s2">},
</span>"Knobs"<span class=
"s2">);
</span></p>
318 <p class=
"p16"><br></p>
319 <p class=
"p18">a.collect(
<span class=
"s5">_
</span>.value);
</p>
320 <p class=
"p16"><br></p>
321 <p class=
"p17">// drag and drop
</p>
323 <p class=
"p18"><span class=
"s5">var
</span> w, txt, size =
36;
</p>
324 <p class=
"p18">w =
<span class=
"s5">Window
</span>.new(
<span class=
"s6">"Knobs"</span>,
<span class=
"s5">Rect
</span>(
400,
400,
250,
100)).front;
</p>
325 <p class=
"p18">w.acceptsMouseOver=
<span class=
"s5">true
</span>;
</p>
326 <p class=
"p18">w.view.decorator =
<span class=
"s5">FlowLayout
</span>(w.view.bounds).gap_(
10 @
10).margin_(
10 @
10);
</p>
327 <p class=
"p18">txt =
<span class=
"s5">StaticText
</span>(w,
200 @
14);
</p>
328 <p class=
"p18">w.view.decorator.nextLine;
</p>
329 <p class=
"p16"><br></p>
330 <p class=
"p18">k =
<span class=
"s5">Knob
</span>(w, size @ size);
</p>
331 <p class=
"p18">k.action = {
<span class=
"s5">arg
</span> v,x,y;
<span class=
"Apple-converted-space"> </span>v.value.postln; txt.string_(
<span class=
"s6">"value: "</span> ++ v.value); };
</p>
332 <p class=
"p18">k.mouseOverAction = {
<span class=
"s5">|v|
</span> txt.string_(
<span class=
"s6">"value: "</span> ++ v.value); };
</p>
333 <p class=
"p16"><br></p>
334 <p class=
"p18">j =
<span class=
"s5">Knob
</span>(w, size @ size);
</p>
335 <p class=
"p18">j.action = {
<span class=
"s5">arg
</span> v,x,y;
<span class=
"Apple-converted-space"> </span>j.value.postln; txt.string_(
<span class=
"s6">"value: "</span> ++ v.value); };
</p>
336 <p class=
"p18">j.mouseOverAction = { txt.string_(
<span class=
"s6">"value: "</span> ++ j.value); };
</p>
337 <p class=
"p16"><br></p>
338 <p class=
"p18">n =
<span class=
"s5">NumberBox
</span>(w,
100 @
20);
</p>
339 <p class=
"p17">//n.setProperty(\boxColor,Color.grey(alpha:
0.0));
</p>
340 <p class=
"p18">n.value =
0.0;
</p>
342 <p class=
"p16"><br></p>
343 <p class=
"p17">// customize drag and drop methods
</p>
344 <p class=
"p18">k.canReceiveDragHandler
</p>
345 <p class=
"p18">k.canReceiveDragHandler =
<span class=
"s5">false
</span>;
<span class=
"s13">// don't accept drops
</span></p>
346 <p class=
"p16"><br></p>
347 <p class=
"p18">k.canReceiveDragHandler = {
<span class=
"s5">View
</span>.currentDrag.isFloat };
<span class=
"s13">// accept only if drag is float
</span></p>
348 <p class=
"p16"><br></p>
349 <p class=
"p18">k.receiveDragHandler = { (
<span class=
"s6">"value droped in: "</span> ++
<span class=
"s5">View
</span>.currentDrag).postln }
</p>
350 <p class=
"p16"><br></p>
351 <p class=
"p18">k.receiveDragHandler = { k.valueAction =
<span class=
"s5">View
</span>.currentDrag.clip(
0.0,
1.0); }
</p>
352 <p class=
"p16"><br></p>
353 <p class=
"p18">k.beginDragAction = { (
<span class=
"s6">"drag out -> "</span> ++ k.value).postln; }
</p>
354 <p class=
"p16"><br></p>
355 <p class=
"p18">k.beginDragAction = { k.value.asFloat; }
</p>