sclang: ServerShmInterface - try to avoid multiple destructor calls
[supercollider.git] / HelpSource / Classes / FlowView.schelp
blobbdedd353658e9d820fcf94fa7053794a0556c57d
1 CLASS:: FlowView
2 summary:: CompositeView with a FlowLayout as decorator
3 categories:: GUI
4 related:: Classes/FlowLayout, Classes/CompositeView
6 DESCRIPTION::
7 In the simplest respect this is a lazy contraction of this:
8 code::
9 w = GUI.window.new;
10 w.view.decorator = FlowLayout.new(w.bounds);
11 w.front;
14 link::Classes/FlowView:: add some features to this setup.
15 code::
17 f = FlowView.new;
19 GUI.slider.new(f, Rect(0,0,100,100));
20 GUI.slider.new(f, Rect(0,0,100,100));
22 // the StartRow will be fixed at this point in the children array
23 f.startRow;
25 GUI.slider.new(f, Rect(0,0,100,100));
26 f.startRow;
28 GUI.slider.new(f, Rect(0,0,100,100));
33 CLASSMETHODS::
35 METHOD:: new
37 argument:: parent
38 Parent widget.
40 argument:: bounds
41 An instance of link::Classes/Rect::, or a link::Classes/Point:: indicating width@height.
43 argument:: margin
45 argument:: gap
47 argument:: windowTitle
48 Title of the window.
51 INSTANCEMETHODS::
53 METHOD:: startRow
54 Start a new row.
56 METHOD:: indentedRemaining
57 The maximum space that is left, starting at the current cursor position.
58 code::
60 f = FlowView.new;
62 GUI.slider.new(f, Rect(0,0,100,100));
63 GUI.slider.new(f, Rect(0,0,100,100));
65 GUI.slider.new(f, f.indentedRemaining)
66         .background = Color.blue(alpha:0.2)
70 f = FlowView.new;
72 GUI.slider.new(f, Rect(0,0,100,100));
73 GUI.slider.new(f, Rect(0,0,100,100));
75 f.startRow; // new row
77 GUI.slider.new(f, f.indentedRemaining)
78         .background = Color.blue(alpha:0.2)
82 f = FlowView.new;
84 GUI.slider.new(f, Rect(0,0,100,100));
85 GUI.slider.new(f, Rect(0,0,100,100));
86 GUI.slider.new(f, Rect(0,0,100,100));
87 GUI.slider.new(f, Rect(0,0,100,100));
89 GUI.slider.new(f, f.indentedRemaining)
90         .background = Color.blue(alpha:0.2)
94 METHOD:: used
95 The area used so far, rounded up to the nearest rectangle plus margin.
96 code::
98 w = GUI.window.new;
99 w.front;
100 f = FlowView.new(w);
101 f.background = Color.blue(alpha:0.1);
103 GUI.slider.new(f, Rect(0,0,100,100));
104 GUI.slider.new(f, Rect(0,0,100,100));
106 f.used.postln;
108 // overlaid
109 GUI.compositeView.new(w,f.used)
110         .background = Color.red(alpha: 0.1);
114 w = GUI.window.new;
115 w.front;
116 f = FlowView.new(w);
117 f.background = Color.blue(alpha:0.1);
119 GUI.slider.new(f, Rect(0,0,100,100));
120 GUI.slider.new(f, Rect(0,0,100,100));
122 f.startRow; // new row
124 GUI.slider.new(f, Rect(0,0,100,100));
126 f.used.postln;
128 // overlaid
129 GUI.compositeView.new(w,f.used)
130         .background = Color.red(alpha: 0.1);
134 METHOD:: flow
135 Insert a sub flow view into the current view.
136 code::
138 f = FlowView.new;
140 GUI.slider.new(f, Rect(0,0,100,100));
142 // flow within a flow
143 g = f.flow({ arg g;
144         ActionButton(g,"a");
145         GUI.slider.new(g,Rect(0,0,100,100)).background_(Color.rand);
146 }).background_(Color.black); // shrinks to fit the contents afterwards
150 argument:: func
151 (describe argument here)
153 argument:: bounds
154 (describe argument here)
156 METHOD:: comp
157 Insert a sub composite view into the current view.
158 code::
160 f = FlowView.new;
162 GUI.slider.new(f, Rect(0,0,100,100));
164 // sc composite view
165 g = f.comp({ arg g;
166         GUI.slider.new(g, Rect(50,30,50,100)).background_(Color.rand);
167         GUI.slider.new(g, Rect(120,30,50,100)).background_(Color.rand);
168 },Rect(0, 0, 200, 200)).background_(Color.black);
170 f.startRow;
171 "Back to flowing".gui(f);
175 argument:: func
176 (describe argument here)
178 argument:: bounds
179 (describe argument here)
182 EXAMPLES::
184 code::
185 // note: some of the following examples use ActionButton from the crucialib
187 // tests
189 FlowView.new.flow({ arg f;
190 //      b = ActionButton(f,"hi",minWidth:140)
191 }).background_(Color.grey)
196 FlowView.new.flow({ arg f;
197         b = ActionButton(f,"hi",minWidth:140);
198 }).background_(Color.grey)
203 FlowView.new.flow({ arg f;
204         b = GUI.slider.new(f,Rect(0,0,100,100));
205 }).background_(Color.grey)
210 FlowView.new.flow({ arg f;
211         g = f;
212         f.flow({ arg f;
213                 //b = ActionButton(f,"hi",minWidth:140)
214         }).background_(Color.white)
215 }).background_(Color.grey)
220 FlowView.new.flow({ arg f;
221         g = f;
222         f.flow({ arg f;
223                 b = ActionButton(f,"hi",minWidth:140)
224         }).background_(Color.white)
225 }).background_(Color.grey)
230 FlowView.new.flow({ arg f;
231         g = f;
232         f.flow({ arg f;
233                 f.flow({ arg f;
234                         ActionButton(f,"hello",minWidth:100);
235                 }).background_(Color.blue);
236                 b = ActionButton(f,"hi",minWidth:140);
237         }).background_(Color.white)
238 }).background_(Color.grey)
243 FlowView.new.flow({ arg f;
244         g = f;
245         f.flow({ arg f;
246                 f.flow({ arg f;
247                         ActionButton(f,"hello",minWidth:100);
248                 }).background_(Color.blue);
249                 b = ActionButton(f,"hi",minWidth:140);
250         }).background_(Color.white)
251 }).background_(Color.grey)
256 FlowView.new.flow({ arg f;
257         g = f;
258         f.flow({ arg f;
259                 b = ActionButton(f,"hi",minWidth:140);
260                 f.flow({ arg f;
261                         ActionButton(f,"hello",minWidth:100);
262                 }).background_(Color.blue);
263         }).background_(Color.white)
264 }).background_(Color.grey)
268 FlowView.new.flow({ arg f;
269         g = f;
270         f.flow({ arg f;
271                 b = GUI.slider.new(f,Rect(0,0,140,20));
272                 f.flow({ arg f;
273                         ActionButton(f,"hello",minWidth:100);
274                 }).background_(Color.blue);
275         }).background_(Color.white)
276 }).background_(Color.grey)
281 FlowView.new.flow({ arg f;
282                 b = GUI.slider.new(f,Rect(0,0,140,20));
283                 f.flow({ arg f;
284                         ActionButton(f,"hello",minWidth:100);
285                 }).background_(Color.blue);
286 }).background_(Color.grey)
291 a = FlowView.new.flow({ arg f;
292         g = f;
293         w = f.flow({ arg f;
294                 b = f.flow({ arg f;
295                         ActionButton(f,"hello",minWidth:100);
296                 }).background_(Color.blue);
297                 ActionButton(f,"hi",minWidth:140);
298         }).background_(Color.white)
299 }).background_(Color.grey)
303 b.remove(true);
304 w.resizeToFit(true,true);
307 // add something big back in
308 ActionButton(w,"i'm back",minWidth: 200);
309 w.resizeToFit(true,true);
310 // slightly wrong size at the bottom