«Collapsible Views» by codepool
on 27 Apr'17 22:14 inMigration from the old SourceForge wiki.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
// Globally: ( w = Window.new; z = w.view.flow{ |view| view.decorator.gap=0@0; Button(view,80@80).states_([["unhide"],["hide"]]) .value_(1) .action_{ |but| if(but.value.booleanValue) {a[0..7].do(_.bounds= Rect(0,0,80,80)); z.reflowAll; //w.bounds = Rect(w.bounds.left, w.bounds.top,z.used.width,z.used.height) } {a[0..7].do(_.bounds= Rect(0,0,0,0)); z.reflowAll; //w.bounds = Rect(w.bounds.left, w.bounds.top,z.used.width,z.used.height) } }; a = 15.collect{ var c = CompositeView(view,80@80); Slider2D( c,80@80 ).background_( Color.rand ).resize_(5); c }; }; w.front; w.bounds = Rect(w.bounds.left, w.bounds.top,z.used.width,z.used.height) ) // or individually: ( w = Window.new; //change the gaps and margins to see how they work z = w.view.flow{ |view| view.decorator.gap=0@0; a = 16.collect{ var c = CompositeView(view,80@100), sl; sl= Slider2D( c,Rect(0,20,80,80) ).background_( Color.rand ); b=SCButton(c,20@20).states_("x").action_{ (c.bounds.width==20).if{ c.bounds=c.bounds.width_(80); sl.visible_(true)} {c.bounds=c.bounds.width_(20); sl.visible_(false)}; z.reflowAll; }; }; }; z.reflowAll; w.front; ) // Issues: gap is set to 0@0 therefore the views will have no spacing. This can be solved by making a margin with the CompositeView
reception
comments