1 ! Copyright (C) 2005, 2009 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: colors.constants kernel locals math.rectangles
4 namespaces sequences ui.commands ui.gadgets ui.gadgets.borders
5 ui.gadgets.buttons ui.gadgets.glass ui.gadgets.packs
6 ui.gadgets.worlds ui.gestures ui.operations ui.pens ui.pens.solid
7 opengl math.vectors words accessors math math.order sorting ;
10 : show-menu ( owner menu -- )
11 [ find-world ] dip hand-loc get { 0 0 } <rect> show-glass ;
13 GENERIC: <menu-item> ( target hook command -- button )
15 M:: object <menu-item> ( target hook command -- button )
16 command command-name [
18 target command command-button-quot call
24 TUPLE: separator-pen color ;
26 C: <separator-pen> separator-pen
28 M: separator-pen draw-interior
30 dim>> [ { 0 0.5 } v* ] [ { 1 0.5 } v* ] bi
31 [ [ >integer ] map ] bi@ gl-line ;
41 COLOR: black <separator-pen> >>interior ;
43 : menu-theme ( gadget -- gadget )
44 COLOR: light-gray <solid> >>interior ;
46 : <commands-menu> ( target hook commands -- menu )
47 [ <filled-pile> ] 3dip
48 [ <menu-item> add-gadget ] with with each
49 { 5 5 } <border> menu-theme ;
51 : show-commands-menu ( target commands -- )
52 [ dup [ ] ] dip <commands-menu> show-menu ;
54 : <operations-menu> ( target hook -- menu )
55 over object-operations
56 [ primary-operation? ] partition
57 [ reverse ] [ [ [ command-name ] compare ] sort ] bi*
58 { ---- } glue <commands-menu> ;
60 : show-operations-menu ( gadget target hook -- )
61 <operations-menu> show-menu ;