 
     "simulation" COLOR: gray <framed-labeled-gadget> ;
 
-:: create-gadgets ( -- gadgets )
+TUPLE: boids-frame < pack ;
+
+:: <boids-frame> ( -- boids-frame )
+    boids-frame new horizontal >>orientation
     <boids-gadget> :> boids-gadget
     boids-gadget [ start-boids-thread ] keep
+    add-gadget
 
     <pile> { 5 5 } >>gap 1.0 >>fill
 

        [ neg random-boids append ] if
    ] change-boids drop ;

: com-pause ( boids-gadget -- )
    dup paused>> not [ >>paused ] keep
    [ drop ] [ start-boids-thread ] if ;

: com-randomize ( boids-gadget -- )
    [ length random-boids ] change-boids relayout-1 ;

:: simulation-panel ( boids-gadget -- gadget )

    boids-gadget behaviours>>
    [ behavior-panel add-gadget ] each

    { 5 5 } <border> add-gadget ;

boids-frame "touchbar" f {
    { f com-pause }
    { f com-randomize }
} define-command-map

MAIN-WINDOW: boids { { title "Boids" } }
    <boids-frame> >>gadgets ;
