factor/library/ui/menus.factor

37 lines
1.2 KiB
Factor
Raw Normal View History

! Copyright (C) 2005, 2006 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
IN: gadgets-menus
USING: gadgets gadgets-borders gadgets-buttons gadgets-layouts
2005-09-28 23:29:00 -04:00
gadgets-labels gadgets-theme generic kernel lists math
namespaces sequences ;
2005-03-01 22:11:08 -05:00
: retarget-click ( gadget -- )
2006-03-19 00:57:47 -05:00
find-world dup hide-glass update-hand update-clicked ;
2005-11-14 01:54:40 -05:00
2005-08-26 22:22:00 -04:00
: menu-actions ( glass -- )
[ retarget-click ] [ button-down ] set-action ;
2005-08-26 22:22:00 -04:00
: menu-loc ( loc menu world -- loc )
[ rect-dim ] 2apply swap |v-| vmin ;
2005-08-26 22:22:00 -04:00
: show-menu ( loc menu gadget -- )
find-world 2dup show-glass
2006-03-19 18:43:47 -05:00
dup world-glass menu-actions
over >r menu-loc r> set-rect-loc ;
2005-08-26 22:22:00 -04:00
: show-hand-menu ( menu gadget -- )
2006-03-19 00:57:47 -05:00
hand-click-loc get-global -rot show-menu ;
2005-03-01 22:11:08 -05:00
: menu-item-quot ( quot -- quot )
[ keep find-world hide-glass ] curry ;
2005-10-01 01:44:49 -04:00
2005-08-26 21:42:43 -04:00
: menu-items ( assoc -- pile )
2005-03-02 21:26:11 -05:00
#! Given an association list mapping labels to quotations.
#! Prepend a call to hide-menu to each quotation.
[ first2 menu-item-quot >r <label> r> <roll-button> ] map
2005-09-27 00:24:42 -04:00
make-pile 1 over set-pack-fill ;
2005-03-01 22:11:08 -05:00
2005-08-26 21:42:43 -04:00
: <menu> ( assoc -- gadget )
2005-03-01 22:11:08 -05:00
#! Given an association list mapping labels to quotations.
2005-12-17 20:03:41 -05:00
menu-items <default-border> dup menu-theme ;