 DEFER: relayout
 
 : invalidate* ( gadget -- )
-    \ invalidate* over set-gadget-layout-state
+    \ invalidate* over (>>layout-state)
     dup forget-pref-dim
     dup gadget-root?
     [ layout-later ] [ parent>> [ relayout ] when* ] if ;
 
 : relayout ( gadget -- )
-    dup gadget-layout-state \ invalidate* eq?
+    dup layout-state>> \ invalidate* eq?
     [ drop ] [ invalidate* ] if ;
 
 : relayout-1 ( gadget -- )
-    dup gadget-layout-state
+    dup layout-state>>
     [ drop ] [ dup invalidate layout-later ] if ;
 
-: show-gadget ( gadget -- ) t swap set-gadget-visible? ;
-
-: hide-gadget ( gadget -- ) f swap set-gadget-visible? ;
+: show-gadget ( gadget -- ) t swap (>>visible?) ;
+
+: hide-gadget ( gadget -- ) f swap (>>visible?) ;
 
 : (set-rect-dim) ( dim gadget quot -- )
     >r 2dup rect-dim =

    f swap (>>parent) ;

: unfocus-gadget ( child gadget -- )
    tuck gadget-focus eq?
    [ f swap set-gadget-focus ] [ drop ] if ;

SYMBOL: in-layout?



: prefer ( gadget -- ) dup pref-dim swap set-layout-dim ;

: validate ( gadget -- ) f swap (>>layout-state) ;

: layout ( gadget -- )
    dup layout-state>> [
        dup validate
        dup layout*
        dup [ layout ] each-child
