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);
52 left = bounds.left + margin.x;
53 top = top + maxHeight + gap.y;
61 ^bounds.insetBy(margin.x * 2,margin.y * 2)
65 left = left + ( d = (b.left - bounds.left));
66 maxRight = maxRight + (d);
67 top = top + (d = (b.top - bounds.top));
68 maxHeight = maxHeight + (d);
70 // and then you need to re-place all views
71 // but nextLine will be broken, see FlowView
75 currentBounds = bounds;
76 currentBounds.height = top + maxHeight;
79 // rounded out to the nearest rect + margin
81 ^Rect(bounds.left,bounds.top,
82 maxRight + margin.x - bounds.left,
83 (top + maxHeight + margin.y ) - bounds.top)
85 // largest allocatable rect starting in the current row
86 // going down as far as possible
89 inb = this.innerBounds;
91 inb.width - (left - inb.left - margin.x),
92 inb.height - (top - inb.top - margin.y))