bumping version to 3.5-rc1
[supercollider.git] / Help / GUI / EZ-GUI / EZNumber.html
blob7b9b6392d8125d07f2eb55e76217ec0ef5cb0e82
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: 9.0px Monaco; min-height: 12.0px}
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 85.0px; text-indent: -85.0px; font: 12.0px Helvetica; min-height: 14.0px}
19 p.p10 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco}
20 p.p11 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #606060}
21 p.p12 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #bf0000}
22 p.p13 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 14.0px Helvetica}
23 p.p14 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 14.0px Helvetica; min-height: 17.0px}
24 span.s1 {font: 18.0px Helvetica}
25 span.s2 {color: #0000bf}
26 span.s3 {font: 11.0px Monaco}
27 span.s4 {color: #bf0000}
28 span.s5 {color: #000000}
29 span.s6 {color: #007300}
30 span.s7 {color: #606060}
31 span.s8 {font: 11.0px Monaco; color: #007300}
32 span.Apple-tab-span {white-space:pre}
33 </style>
34 </head>
35 <body>
36 <p class="p1"><span class="s1"><b>EZNumber<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b></span><b>wrapper class for label and number box</b><span class="s1"><b><span class="Apple-tab-span"> </span></b></span></p>
37 <p class="p2"><br></p>
38 <p class="p1"><b>Inherits from: Object : </b><a href="EZGui.html"><span class="s2"><b>EZGui</b></span></a></p>
39 <p class="p3"><br></p>
40 <p class="p1">EZNumber is wrapper class which creates an (optional) <a href="../Main-GUI/StaticText.html"><span class="s2">StaticText</span></a>, and a <a href="../Main-GUI/NumberBox.html"><span class="s2">NumberBox</span></a>.</p>
41 <p class="p2"><br></p>
42 <p class="p4"><b>Some Important Issues Regarding NumberBox</b></p>
43 <p class="p1">If the parent is nil, then EZNumber will create its own window. See <a href="EZGui.html"><span class="s2">EZGui</span></a> more options.<span class="Apple-converted-space"> </span></p>
44 <p class="p2"><br></p>
45 <p class="p4"><b>Scrolling and Arrow Keys</b></p>
46 <p class="p1">EZNumber scrolls by default, using the step size of the <a href="../../Control/ControlSpec.html"><span class="s2">ControlSpec</span></a>. If the controlSpec's step is set to 0, or is not set, then the the stepping and scrolling will be guessed according to the <b>minval</b> and <b>maxval</b> values of the spec on creation of the view.<span class="Apple-converted-space">  </span>Unlike the step variable of a regular NumberBox, <b>controlSpec.step</b> is also the smallest possible increment for the EZNumber.<span class="Apple-converted-space">  </span>By default, the shift-key modifier<span class="Apple-converted-space">  </span>will allow you to step by 100 x controlSpec.step , while the ctrl-key will give you 10x controlSpec.step.<span class="Apple-converted-space">  </span>Since the alt-key would give you 0.1 of the minimum step, it is disabled by default, but you can change that by setting <b>numberView.alt_step</b> to any value you like<b>.</b> Accordingly you can customize the other modifiers to fit your needs. See <a href="../Main-GUI/NumberBox.html"><span class="s2">NumberBox</span></a>.</p>
47 <p class="p2"><br></p>
48 <p class="p4"><b>Creation / Class Methods</b></p>
49 <p class="p5"><br></p>
50 <p class="p6"><b><span class="Apple-tab-span"> </span>*new (parent, bounds, label, controlSpec, action, initVal, initAction, labelWidth, numberWidth, unitWidth, labelHeight, layout, gap)</b></p>
51 <p class="p7"><b><span class="Apple-tab-span"> </span></b></p>
52 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>parent </b>- The parent view or window. If the parent is nil, then EZNumber will create its own <a href="../Main-GUI/Window.html"><span class="s2">Window</span></a>, and place it conveniently on the screen if the bounds are a <a href="../../Geometry/Point.html"><span class="s2">Point</span></a>. If the bounds are a <a href="../../Geometry/Rect.html"><span class="s2">Rect</span></a>, then the Rect determines the window bounds.</p>
53 <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="s2">Rect</span></a> or <a href="../../Geometry/Point.html"><span class="s2">Point</span></a>. Default value is <span class="s3">160@20</span>.</p>
54 <p class="p9"><br></p>
55 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>label </b>- The label. Default value is nil. If nil, then no StaticText is created.<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
56 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>controlSpec </b>- The <a href="../../Control/ControlSpec.html"><span class="s2">ControlSpec</span></a> for scaling the value.</p>
57 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>action </b>- A <a href="../../Core/Kernel/Function.html"><span class="s2">Function</span></a> called when the value changes. The function is passed the EZNumber instance as its argument.</p>
58 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>initVal </b>- The value to initialize the slider and number box with. If nil, then it uses the ControlSpec's default value.</p>
59 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>initAction </b>- A <a href="../../Core/Boolean.html"><span class="s2">Boolean</span></a> indicating whether the action function should be called when setting the initial value. The default is false.</p>
60 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>labelWidth </b>- Number of pixels width for the label. The<span class="Apple-converted-space">  </span>default is 60. In the \horz <b>layout, </b>if you specify the <b>numberWidth</b>, then the <b>labelWidth</b> is ignored and is set to the <b>bounds.width - unitWidth - numberWidth</b>.<span class="Apple-converted-space"> <span class="Apple-tab-span"> </span></span></p>
61 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>numberWidth </b>- Number of pixels width for the number box. The<span class="Apple-converted-space">  </span>default is 45. In \line2 <b>layout</b>, <b>numberWidth</b> defaults to the <b>bounds.width</b> minus the <b>unitWidth</b>.<span class="Apple-converted-space"> </span></p>
62 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>unitWidth </b>- Number of pixels width for the unit label. The default is 0.<span class="Apple-converted-space">  </span>If <b>unitWidth</b> is 0, then no unitLabel is created. In the \line2 <b>layout</b>, if you specify the <b>numberWidth</b>, then the <b>unitWidth</b> is ignored and is set to the <b>bounds.width - unitWidth - numberWidth.</b></p>
63 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>labelHeight</b>- Default is 20;</p>
64 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>layout</b>- \line2, or \horz. The default is horz; \line2 is a two line version.</p>
65 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>gap </b>- A <a href="../../Geometry/Point.html"><span class="s2">Point</span></a>. By default, the view tries to get its parent's gap, otherwise it defaults to 2@2. Setting it overrides these.</p>
66 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>margin </b>- A <a href="../../Geometry/Point.html"><span class="s2">Point</span></a>. This will inset the bounds occupied<span class="Apple-converted-space">  </span>by the subviews of view.</p>
67 <p class="p3"><br></p>
68 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>(</p>
69 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>w = <span class="s2">Window</span>.new.front;</p>
70 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>g = <span class="s2">EZNumber</span>(<span class="Apple-tab-span"> </span>w,<span class="Apple-converted-space">  <span class="Apple-tab-span"> </span></span><span class="s4">// parent</span></p>
71 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>150@20,<span class="Apple-tab-span"> </span><span class="s4">// bounds</span></p>
72 <p class="p11"><span class="s5"><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>" test "<span class="s5">,<span class="Apple-tab-span"> </span></span><span class="s4">// label</span></p>
73 <p class="p12"><span class="s5"><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><span class="s6">\freq</span><span class="s5">, <span class="Apple-tab-span"> </span></span>// controlSpec</p>
74 <p class="p10"><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="s2">|ez|</span> (ez.value.asString ++<span class="s7">" is the value of "</span> ++ ez).postln}, <span class="s4">// action</span></p>
75 <p class="p12"><span class="s5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>330,<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>// initValue</p>
76 <p class="p12"><span class="s5"><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><span class="s2">true</span><span class="s5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>// initAction</p>
77 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>);</p>
78 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>g.setColors(<span class="s2">Color</span>.grey,<span class="s2">Color</span>.white);</p>
79 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>);</p>
80 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
81 <p class="p3"><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>
82 <p class="p12"><span class="s5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>// Simplest version, no parent view, so a window is created</p>
83 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>(</p>
84 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>g=<span class="s2">EZNumber</span>(label:<span class="s7">" test "</span>, controlSpec: <span class="s6">\amp</span>.asSpec.step_(0.01) );</p>
85 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>g.action_({<span class="s2">|ez|</span> (ez.value.asString ++<span class="s7">" is the value of "</span> ++ ez).postln});</p>
86 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>);</p>
87 <p class="p7"><br></p>
88 <p class="p1">The contained views can be accessed via the EZNumber instance variables:</p>
89 <p class="p1"><span class="Apple-tab-span"> </span><b>labelView</b>, <b>numberView</b></p>
90 <p class="p2"><b><span class="Apple-tab-span"> </span></b></p>
91 <p class="p7"><span class="Apple-tab-span"> </span></p>
92 <p class="p6"><b><span class="Apple-tab-span"> </span>numberView</b></p>
93 <p class="p7"><b><span class="Apple-tab-span"> </span></b><span class="Apple-tab-span"> </span></p>
94 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>Returns the <b>numberView</b></p>
95 <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>
96 <p class="p6"><b><span class="Apple-tab-span"> </span>action</b></p>
97 <p class="p6"><b><span class="Apple-tab-span"> </span>action_(arg1)</b></p>
98 <p class="p7"><b><span class="Apple-tab-span"> </span></b></p>
99 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>A function to be evaluated when the value changes. Te first argument will be the EZNumber.</p>
100 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>arg1 </b>- An instance of <a href="../../Core/Kernel/Function.html"><span class="s2">Function</span></a> or <a href="../../Core/Kernel/FunctionList.html"><span class="s2">FunctionList</span></a>. Default value is nil.</p>
101 <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>
102 <p class="p6"><b><span class="Apple-tab-span"> </span>value</b></p>
103 <p class="p7"><b><span class="Apple-tab-span"> </span></b><span class="Apple-tab-span"> </span></p>
104 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>The value of the slider</p>
105 <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>
106 <p class="p6"><b><span class="Apple-tab-span"> </span>round_(arg1)</b></p>
107 <p class="p6"><b><span class="Apple-tab-span"> </span>round</b></p>
108 <p class="p7"><b><span class="Apple-tab-span"> </span></b><span class="Apple-tab-span"> </span></p>
109 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>Rounds the values in the number box.</p>
110 <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><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>
111 <p class="p6"><b><span class="Apple-tab-span"> </span>controlSpec_(arg1)</b></p>
112 <p class="p6"><b><span class="Apple-tab-span"> </span>controlSpec</b></p>
113 <p class="p7"><b><span class="Apple-tab-span"> </span></b><span class="Apple-tab-span"> </span></p>
114 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>An instance of <a href="../../Control/ControlSpec.html"><span class="s2">ControlSpec</span></a> for scaling the values.</p>
115 <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>
116 <p class="p6"><b><span class="Apple-tab-span"> </span>value</b></p>
117 <p class="p6"><b><span class="Apple-tab-span"> </span>value_ (val)</b></p>
118 <p class="p7"><b><span class="Apple-tab-span"> </span></b></p>
119 <p class="p6"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Gets/sets the list/menu to the index at value. Does not perform the action.</p>
120 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>val </b>- An integer.</p>
121 <p class="p5"><br></p>
122 <p class="p6"><b><span class="Apple-tab-span"> </span>valueAction_ (val)</b></p>
123 <p class="p7"><b><span class="Apple-tab-span"> </span></b></p>
124 <p class="p6"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Sets the value and performs the action at the index value and the global action.</p>
125 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>val </b>- An integer.</p>
126 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
127 <p class="p6"><b><span class="Apple-tab-span"> </span>doAction</b></p>
128 <p class="p7"><b><span class="Apple-tab-span"> </span></b></p>
129 <p class="p6"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Performs the action at the current index and the global action.</p>
130 <p class="p7"><br></p>
131 <p class="p5"><br></p>
132 <p class="p6"><b><span class="Apple-tab-span"> </span>set (label, spec, argAction, initVal, initAction)</b></p>
133 <p class="p7"><b><span class="Apple-tab-span"> </span></b></p>
134 <p class="p6"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Set the args after creation.</p>
135 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
136 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
137 <p class="p6"><b><span class="Apple-tab-span"> </span>enabled</b></p>
138 <p class="p6"><b><span class="Apple-tab-span"> </span>enabled_(bool)</b></p>
139 <p class="p7"><b><span class="Apple-tab-span"> </span></b></p>
140 <p class="p6"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Sets/gets if the list is enabled.</p>
141 <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="s2">Boolean</span></a>. Default is true;</p>
142 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
143 <p class="p9"><br></p>
144 <p class="p13"><b>Changing Appearance</b></p>
145 <p class="p2"><span class="Apple-tab-span"> </span></p>
146 <p class="p6"><b><span class="Apple-tab-span"> </span>setColors(stringBackground,stringColor,numBackground,</b></p>
147 <p class="p6"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>numStringColor,numNormalColor,numTypingColor,background)</b></p>
148 <p class="p7"><b><span class="Apple-tab-span"> </span></b></p>
149 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>stringBackground </b>- An instance of <a href="../GUI-Tools/Color.html"><span class="s2">Color</span></a>. The <b>background</b> of the label and unit views.</p>
150 <p class="p8"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>stringColor </b>- An instance of <a href="../GUI-Tools/Color.html"><span class="s2">Color</span></a>. The <b>stringColor</b> of the label and unit views.</p>
151 <p class="p8"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>numBackground </b>- An instance of <a href="../GUI-Tools/Color.html"><span class="s2">Color</span></a>. The <b>background</b> of the number view.</p>
152 <p class="p8"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>numStringColor </b>- An instance of <a href="../GUI-Tools/Color.html"><span class="s2">Color</span></a>. The <b>stringColor</b> of the number view.</p>
153 <p class="p8"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>numNormalColor </b>- An instance of <a href="../GUI-Tools/Color.html"><span class="s2">Color</span></a>. The <b>normalColor</b> of the number view.</p>
154 <p class="p8"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>numTypingColor </b>- An instance of <a href="../GUI-Tools/Color.html"><span class="s2">Color</span></a>. The <b>typingColor</b> of the number view.</p>
155 <p class="p8"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>background </b>- An instance of <a href="../GUI-Tools/Color.html"><span class="s2">Color</span></a>. The <b>backround</b> of the enclosing view.</p>
156 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
157 <p class="p6"><b><span class="Apple-tab-span"> </span>font_(font)</b></p>
158 <p class="p6"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Set the Font used by all the views.</p>
159 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>font </b>- An instance of <a href="../Main-GUI/Font.html"><span class="s2">Font</span></a>.<span class="Apple-converted-space"> </span></p>
160 <p class="p5"><br></p>
161 <p class="p5"><br></p>
162 <p class="p13"><b>Examples</b></p>
163 <p class="p14"><br></p>
164 <p class="p14"><br></p>
165 <p class="p12">// Simplest version</p>
166 <p class="p12"><span class="s5">(<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>// basic use</p>
167 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>w=<span class="s2">Window</span>.new.front;</p>
168 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>g=<span class="s2">EZNumber</span>(w, 170@16,<span class="s7">" test<span class="Apple-converted-space">  </span>"</span>, <span class="s6">\</span><span class="s8">freq</span>,unitWidth:30, numberWidth:60,layout:<span class="s6">\horz</span>);</p>
169 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>g.setColors(<span class="s2">Color</span>.grey,<span class="s2">Color</span>.white);</p>
170 <p class="p10">);</p>
171 <p class="p14"><br></p>
172 <p class="p14"><br></p>
173 <p class="p12">// lots of numberviews on on view</p>
174 <p class="p10">(</p>
175 <p class="p10">w=<span class="s2">Window</span>.new.front;</p>
176 <p class="p10">w.view.decorator=<span class="s2">FlowLayout</span>(w.view.bounds);</p>
177 <p class="p10">w.view.decorator.gap=2@2;</p>
178 <p class="p3"><br></p>
179 <p class="p10">40.do{</p>
180 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>g=<span class="s2">EZNumber</span>(w, 170@16,<span class="s7">" test<span class="Apple-converted-space">  </span>"</span>, <span class="s6">\</span><span class="s8">freq</span>,unitWidth:30, numberWidth:60,layout:<span class="s6">\horz</span>);</p>
181 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>g.setColors(<span class="s2">Color</span>.grey,<span class="s2">Color</span>.white, <span class="s2">Color</span>.grey(0.8));</p>
182 <p class="p10">};</p>
183 <p class="p10">);</p>
184 <p class="p3"><br></p>
185 <p class="p3"><br></p>
186 <p class="p12">// click these parentheses to see all features and layouts<span class="Apple-converted-space"> </span></p>
187 <p class="p10">(<span class="Apple-converted-space">   </span></p>
188 <p class="p3"><br></p>
189 <p class="p10">m=<span class="s2">nil</span>;</p>
190 <p class="p12"><span class="s5">m=2@2;<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>//comment for no margin</p>
191 <p class="p3"><br></p>
192 <p class="p12">/////////////////</p>
193 <p class="p12">/// Layout \horz</p>
194 <p class="p3"><br></p>
195 <p class="p12"><span class="s5">(<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>// all features</p>
196 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>g=<span class="s2">EZNumber</span>(<span class="s2">nil</span>, 170@20,<span class="s7">" freq<span class="Apple-converted-space">  </span>"</span>, <span class="s6">\</span><span class="s8">freq</span>,unitWidth:30, numberWidth:60,layout:<span class="s6">\horz</span>,margin:m);</p>
197 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>g.setColors(<span class="s2">Color</span>.grey,<span class="s2">Color</span>.white,background: <span class="s2">Color</span>.grey(0.7));</p>
198 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>g.window.bounds = g.window.bounds.moveBy(-180,50);</p>
199 <p class="p10">);</p>
200 <p class="p3"><br></p>
201 <p class="p12"><span class="s5">(<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>// no unitView</p>
202 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>g=<span class="s2">EZNumber</span>(<span class="s2">nil</span>, 170@20,<span class="s7">" freq<span class="Apple-converted-space">  </span>"</span>, <span class="s6">\</span><span class="s8">freq</span>,unitWidth:0, numberWidth:60,layout:<span class="s6">\horz</span>,margin:m);</p>
203 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>g.setColors(<span class="s2">Color</span>.grey,<span class="s2">Color</span>.white,background: <span class="s2">Color</span>.grey(0.7));</p>
204 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>g.window.bounds = g.window.bounds.moveBy(-180, -20);</p>
205 <p class="p10">);</p>
206 <p class="p3"><br></p>
207 <p class="p12"><span class="s5">(<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>// no label, with unit. use window name as label</p>
208 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>g=<span class="s2">EZNumber</span>(<span class="s2">nil</span>, 120@20,<span class="s2">nil</span>, <span class="s6">\</span><span class="s8">freq</span>,unitWidth:30, numberWidth:60,layout:<span class="s6">\horz</span>,margin:m);</p>
209 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>g.setColors(<span class="s2">Color</span>.grey,<span class="s2">Color</span>.white,background: <span class="s2">Color</span>.grey(0.7));</p>
210 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>g.window.bounds = g.window.bounds.moveBy(-180, -90);</p>
211 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>g.window.name=<span class="s7">"Freq"</span>;</p>
212 <p class="p10">);</p>
213 <p class="p3"><br></p>
214 <p class="p3"><br></p>
215 <p class="p12"><span class="s5">(<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>// no units, no label; use window name as label;</p>
216 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>g=<span class="s2">EZNumber</span>(<span class="s2">nil</span>, 120@20, <span class="s2">nil</span>, <span class="s6">\</span><span class="s8">freq</span>,unitWidth:0, numberWidth:60,layout:<span class="s6">\horz</span>,margin:m);</p>
217 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>g.setColors(<span class="s2">Color</span>.grey,<span class="s2">Color</span>.white,background: <span class="s2">Color</span>.grey(0.7));</p>
218 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>g.window.bounds = g.window.bounds.moveBy(-180, -160);</p>
219 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>g.window.name=<span class="s7">"Freq"</span>;</p>
220 <p class="p10">);</p>
221 <p class="p3"><br></p>
222 <p class="p12">/////////////////</p>
223 <p class="p12">/// Layout \line2</p>
224 <p class="p3"><br></p>
225 <p class="p12"><span class="s5">(<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>// all features</p>
226 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>g=<span class="s2">EZNumber</span>(<span class="s2">nil</span>, 120@42,<span class="s7">" freq<span class="Apple-converted-space">  </span>"</span>, <span class="s6">\</span><span class="s8">freq</span>,unitWidth:30, numberWidth:60,layout:<span class="s6">\line2</span>,margin:m);</p>
227 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>g.setColors(<span class="s2">Color</span>.grey,<span class="s2">Color</span>.white,background: <span class="s2">Color</span>.grey(0.7));</p>
228 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>g.window.bounds = g.window.bounds.moveBy(100,50);</p>
229 <p class="p10">);</p>
230 <p class="p3"><br></p>
231 <p class="p12"><span class="s5">(<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>// no unitView, with label</p>
232 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>g=<span class="s2">EZNumber</span>(<span class="s2">nil</span>, 170@42,<span class="s7">" freq<span class="Apple-converted-space">  </span>"</span>, <span class="s6">\</span><span class="s8">freq</span>,unitWidth:0, numberWidth:60,layout:<span class="s6">\line2</span>,margin:m);</p>
233 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>g.setColors(<span class="s2">Color</span>.grey,<span class="s2">Color</span>.white,background: <span class="s2">Color</span>.grey(0.7));</p>
234 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>g.window.bounds = g.window.bounds.moveBy(100, -50);</p>
235 <p class="p10">);</p>
236 <p class="p12"><span class="s5">(<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>// no unitView, no label; use window name as label</p>
237 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>g=<span class="s2">EZNumber</span>(<span class="s2">nil</span>, 170@20,<span class="s2">nil</span>, <span class="s6">\</span><span class="s8">freq</span>,unitWidth:0, numberWidth:60,layout:<span class="s6">\line2</span>,margin:m);</p>
238 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>g.setColors(<span class="s2">Color</span>.grey,<span class="s2">Color</span>.white,background: <span class="s2">Color</span>.grey(0.7));</p>
239 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>g.window.bounds = g.window.bounds.moveBy(100,-150);</p>
240 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>g.window.name=<span class="s7">"Freq"</span>;</p>
241 <p class="p10">);</p>
242 <p class="p3"><br></p>
243 <p class="p3"><br></p>
244 <p class="p10">)<span class="Apple-tab-span"> </span></p>
245 <p class="p3"><span class="Apple-tab-span"> </span></p>
246 <p class="p3"><span class="Apple-tab-span"> </span></p>
247 <p class="p3"><span class="Apple-tab-span"> </span></p>
248 <p class="p12">// Sound example</p>
249 <p class="p10">(</p>
250 <p class="p12">// start server</p>
251 <p class="p10">s.waitForBoot({</p>
252 <p class="p3"><span class="Apple-tab-span"> </span></p>
253 <p class="p10"><span class="Apple-tab-span"> </span><span class="s2">var</span> w, startButton, noteControl, cutoffControl, resonControl;</p>
254 <p class="p10"><span class="Apple-tab-span"> </span><span class="s2">var</span> balanceControl, ampControl;</p>
255 <p class="p10"><span class="Apple-tab-span"> </span><span class="s2">var</span> node, cmdPeriodFunc;</p>
256 <p class="p3"><span class="Apple-tab-span"> </span></p>
257 <p class="p12"><span class="s5"><span class="Apple-tab-span"> </span></span>// define a synth</p>
258 <p class="p10"><span class="Apple-tab-span"> </span><span class="s2">SynthDef</span>(<span class="s7">"window-test"</span>, { <span class="s2">arg</span> note = 36, fc = 1000, rq = 0.25, bal=0, amp=0.4, gate = 1;</p>
259 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s2">var</span> x;</p>
260 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>x = <span class="s2">Mix</span>.fill(4, {</p>
261 <p class="p10"><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="s2">LFSaw</span>.ar((note + {0.1.rand2}.dup).midicps, 0, 0.02)</p>
262 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>});</p>
263 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>x = <span class="s2">RLPF</span>.ar(x, fc, rq).softclip;</p>
264 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>x = <span class="s2">RLPF</span>.ar(x, fc, rq, amp).softclip;</p>
265 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>x = <span class="s2">Balance2</span>.ar(x[0], x[1], bal);</p>
266 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>x = x * <span class="s2">EnvGen</span>.kr(<span class="s2">Env</span>.cutoff, gate, doneAction: 2);</p>
267 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s2">Out</span>.ar(0, x);</p>
268 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>}, [0.1, 0.1, 0.1, 0.1, 0.1, 0]</p>
269 <p class="p10"><span class="Apple-tab-span"> </span>).load(s);</p>
270 <p class="p3"><span class="Apple-tab-span"> </span></p>
271 <p class="p3"><span class="Apple-tab-span"> </span></p>
272 <p class="p3"><span class="Apple-tab-span"> </span></p>
273 <p class="p12"><span class="s5"><span class="Apple-tab-span"> </span></span>// make the window</p>
274 <p class="p10"><span class="Apple-tab-span"> </span>w = <span class="s2">Window</span>(<span class="s7">"another control panel"</span>, <span class="s2">Rect</span>(200, 400, 300, 180));</p>
275 <p class="p12"><span class="s5"><span class="Apple-tab-span"> </span>w.front; </span>// make window visible and front window.</p>
276 <p class="p10"><span class="Apple-tab-span"> </span>w.view.decorator = <span class="s2">FlowLayout</span>(w.view.bounds);</p>
277 <p class="p3"><span class="Apple-tab-span"> </span></p>
278 <p class="p10"><span class="Apple-tab-span"> </span>w.view.background = <span class="s2">Color</span>.rand;</p>
279 <p class="p3"><span class="Apple-tab-span"> </span></p>
280 <p class="p12"><span class="s5"><span class="Apple-tab-span"> </span></span>// add a button to start and stop the sound.</p>
281 <p class="p10"><span class="Apple-tab-span"> </span>startButton = <span class="s2">Button</span>(w, 75 @ 20);</p>
282 <p class="p10"><span class="Apple-tab-span"> </span>startButton.states = [</p>
283 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>[<span class="s7">"Start"</span>, <span class="s2">Color</span>.black, <span class="s2">Color</span>.green],</p>
284 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>[<span class="s7">"Stop"</span>, <span class="s2">Color</span>.white, <span class="s2">Color</span>.red]</p>
285 <p class="p10"><span class="Apple-tab-span"> </span>];</p>
286 <p class="p10"><span class="Apple-tab-span"> </span>startButton.action = {<span class="s2">|view|</span></p>
287 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>if (view.value == 1) {</p>
288 <p class="p12"><span class="s5"><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>// start sound</p>
289 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>node = <span class="s2">Synth</span>( <span class="s7">"window-test"</span>, [</p>
290 <p class="p10"><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="s7">"note"</span>, noteControl.value,</p>
291 <p class="p10"><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="s7">"fc"</span>, cutoffControl.value,</p>
292 <p class="p10"><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="s7">"rq"</span>, resonControl.value,</p>
293 <p class="p10"><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="s7">"bal"</span>, balanceControl.value,</p>
294 <p class="p10"><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="s7">"amp"</span>, ampControl.value.dbamp ]);</p>
295 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>} {</p>
296 <p class="p12"><span class="s5"><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>// set gate to zero to cause envelope to release</p>
297 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>node.release; node = <span class="s2">nil</span>;</p>
298 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>};</p>
299 <p class="p10"><span class="Apple-tab-span"> </span>};</p>
300 <p class="p3"><span class="Apple-tab-span"> </span></p>
301 <p class="p12"><span class="s5"><span class="Apple-tab-span"> </span></span>// create controls for all parameters</p>
302 <p class="p10"><span class="Apple-tab-span"> </span>w.view.decorator.nextLine;</p>
303 <p class="p10"><span class="Apple-tab-span"> </span>noteControl = <span class="s2">EZNumber</span>(w, 160 @ 20, <span class="s7">"Note "</span>, <span class="s2">ControlSpec</span>(24, 60, <span class="s6">\lin</span>, 1),</p>
304 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>{<span class="s2">|ez|</span> node.set( <span class="s7">"note"</span>, ez.value )}, 36);</p>
305 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
306 <p class="p10"><span class="Apple-tab-span"> </span>w.view.decorator.nextLine;</p>
307 <p class="p10"><span class="Apple-tab-span"> </span>cutoffControl = <span class="s2">EZNumber</span>(w, 160 @ 20, <span class="s7">"Cutoff "</span>, <span class="s2">ControlSpec</span>(200, 5000, <span class="s6">\exp</span>),</p>
308 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>{<span class="s2">|ez|</span> node.set( <span class="s7">"fc"</span>, ez.value )}, 1000);</p>
309 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
310 <p class="p10"><span class="Apple-tab-span"> </span>w.view.decorator.nextLine;</p>
311 <p class="p10"><span class="Apple-tab-span"> </span>resonControl = <span class="s2">EZNumber</span>(w, 160 @ 20, <span class="s7">"Reson"</span>, <span class="s2">ControlSpec</span>(0.1, 0.7),</p>
312 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>{<span class="s2">|ez|</span> node.set( <span class="s7">"rq"</span>, ez.value )}, 0.2);</p>
313 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
314 <p class="p10"><span class="Apple-tab-span"> </span>w.view.decorator.nextLine;</p>
315 <p class="p10"><span class="Apple-tab-span"> </span>balanceControl = <span class="s2">EZNumber</span>(w, 160 @ 20, <span class="s7">"Balance "</span>, <span class="s6">\bipolar</span>,</p>
316 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>{<span class="s2">|ez|</span> node.set( <span class="s7">"bal"</span>, ez.value )}, 0);</p>
317 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
318 <p class="p10"><span class="Apple-tab-span"> </span>w.view.decorator.nextLine;</p>
319 <p class="p10"><span class="Apple-tab-span"> </span>ampControl = <span class="s2">EZNumber</span>(w, 160 @ 20, <span class="s7">"Amp "</span>, <span class="s6">\db</span>,</p>
320 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>{<span class="s2">|ez|</span> node.set( <span class="s7">"amp"</span>, ez.value.dbamp )}, -6);</p>
321 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
322 <p class="p3"><span class="Apple-tab-span"> </span></p>
323 <p class="p12"><span class="s5"><span class="Apple-tab-span"> </span></span>// set start button to zero upon a cmd-period</p>
324 <p class="p10"><span class="Apple-tab-span"> </span>cmdPeriodFunc = { startButton.value = 0; };</p>
325 <p class="p10"><span class="Apple-tab-span"> </span><span class="s2">CmdPeriod</span>.add(cmdPeriodFunc);</p>
326 <p class="p3"><span class="Apple-tab-span"> </span></p>
327 <p class="p12"><span class="s5"><span class="Apple-tab-span"> </span></span>// stop the sound when window closes and remove cmdPeriodFunc.</p>
328 <p class="p10"><span class="Apple-tab-span"> </span>w.onClose = {</p>
329 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>node.free; node = <span class="s2">nil</span>;</p>
330 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s2">CmdPeriod</span>.remove(cmdPeriodFunc);</p>
331 <p class="p10"><span class="Apple-tab-span"> </span>};</p>
332 <p class="p10">});</p>
333 <p class="p10">)</p>
334 <p class="p3"><span class="Apple-tab-span"> </span></p>
335 </body>
336 </html>