2 place { arg view; this.subclassResponsibility(\place); }
4 remove { arg view; this.subclassResponsibility(\remove); }
6 clear { this.subclassResponsibility(\clear); }
8 bounds { this.subclassResponsibility(\bounds); }
10 bounds_ { arg bounds; this.subclassResponsibility(\bounds_); }
12 gap { this.subclassResponsibility(\gap); }
13 gap_ { arg gap; this.subclassResponsibility(\gap_); }
15 margin { this.subclassResponsibility(\margin); }
16 margin_ { arg margin; this.subclassResponsibility(\margin_); }
19 FlowLayout : Decorator {
20 var <bounds, <>margin, <>gap;
21 var <>left, <>top, <>maxHeight,<>maxRight;
24 *new { arg bounds, margin, gap;
25 ^super.newCopyArgs(bounds, margin, gap).init
28 gap = gap ? Point(4,4);
29 margin = margin ? Point(4,4);
34 maxRight = left = bounds.left + margin.x;
35 top = bounds.top + margin.y;
39 var height, width,vbounds;
40 vbounds = view.bounds;
41 width = vbounds.width;
42 height = vbounds.height;
43 if ((left + width) > (bounds.right - margin.x), { this.nextLine; });
45 view.bounds = Rect(left, top, width, height);
47 maxRight = max(maxRight,left + width);
48 left = left + width + gap.x;
49 maxHeight = max(maxHeight, height);
53 left = bounds.left + margin.x;
54 top = top + maxHeight + gap.y;
62 ^bounds.insetBy(margin.x * 2,margin.y * 2)
66 left = left + ( d = (b.left - bounds.left));
67 maxRight = maxRight + (d);
68 top = top + (d = (b.top - bounds.top));
69 maxHeight = maxHeight + (d);
71 // and then you need to re-place all views
72 // but nextLine will be broken, see FlowView
76 currentBounds = bounds;
77 currentBounds.height = top + maxHeight;
80 // rounded out to the nearest rect + margin
82 ^Rect(bounds.left,bounds.top,
83 maxRight + margin.x - bounds.left,
84 (top + maxHeight + margin.y ) - bounds.top)
86 // largest allocatable rect starting in the current row
87 // going down as far as possible
90 inb = this.innerBounds;
92 inb.width - (left - inb.left - margin.x),
93 inb.height - (top - inb.top - margin.y))