1 ! Copyright (C) 2005, 2006 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
4 USING: arrays errors freetype gadgets-frames generic hashtables
5 kernel math models namespaces opengl sequences ;
7 : menu-loc ( world menu -- loc )
8 >r rect-dim r> pref-dim [v-] hand-loc get-global vmin ;
12 C: menu-glass ( menu world -- glass )
14 >r over menu-loc over set-rect-loc r>
17 M: menu-glass layout* gadget-child prefer ;
19 : retarget-drag ( gadget -- )
20 hand-gadget get-global hand-clicked get-global eq? [
23 hand-loc get-global swap find-world move-hand
27 find-world hide-glass f menu-mode? set-global ;
30 { T{ button-up } [ hide-menu ] }
31 { T{ drag } [ retarget-drag ] }
34 : show-menu ( gadget owner -- )
35 find-world [ <menu-glass> ] keep [ show-glass ] keep
36 t menu-mode? set-global ;