// title: Collapsible Views // author: codepool // description: // Migration from the old SourceForge wiki. // code: // 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