 
 : prefer ( gadget -- ) dup pref-dim swap set-layout-dim ;
 
-: validate ( gadget -- ) f swap set-gadget-layout-state ;
+: validate ( gadget -- ) f swap (>>layout-state) ;
 
 : layout ( gadget -- )
-    dup gadget-layout-state [
+    dup layout-state>> [
         dup validate
         dup layout*
         dup [ layout ] each-child


: (clear-gadget) ( gadget -- )
    dup [ (unparent) ] each-child
    f over set-gadget-focus
    f swap (>>children) ;

: clear-gadget ( gadget -- )

: dim-sum ( seq -- dim ) { 0 0 } [ v+ ] reduce ;

: orient ( gadget seq1 seq2 -- seq )
    >r >r orientation>> r> r> [ pick set-axis ] 2map nip ;

: each-child ( gadget quot -- )
    >r children>> r> each ; inline
