2009-01-09 00:50:56 -05:00
|
|
|
! Copyright (C) 2005, 2009 Slava Pestov.
|
2007-09-20 18:09:08 -04:00
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
2009-02-13 01:59:28 -05:00
|
|
|
USING: colors.constants kernel locals math.rectangles
|
|
|
|
namespaces sequences ui.commands ui.gadgets ui.gadgets.borders
|
|
|
|
ui.gadgets.buttons ui.gadgets.glass ui.gadgets.packs
|
2009-02-18 22:00:53 -05:00
|
|
|
ui.gadgets.worlds ui.gestures ui.operations ui.pens ui.pens.solid
|
|
|
|
opengl math.vectors words accessors math math.order sorting ;
|
2007-09-20 18:09:08 -04:00
|
|
|
IN: ui.gadgets.menus
|
|
|
|
|
2008-11-30 16:03:05 -05:00
|
|
|
: show-menu ( owner menu -- )
|
2009-02-13 01:59:28 -05:00
|
|
|
[ find-world ] dip hand-loc get { 0 0 } <rect> show-glass ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2009-02-18 22:00:53 -05:00
|
|
|
GENERIC: <menu-item> ( target hook command -- button )
|
|
|
|
|
|
|
|
M:: object <menu-item> ( target hook command -- button )
|
2008-11-30 16:03:05 -05:00
|
|
|
command command-name [
|
|
|
|
hook call
|
|
|
|
target command command-button-quot call
|
2009-02-18 22:00:53 -05:00
|
|
|
hide-glass
|
2008-11-30 16:03:05 -05:00
|
|
|
] <roll-button> ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2009-02-18 22:00:53 -05:00
|
|
|
<PRIVATE
|
|
|
|
|
|
|
|
TUPLE: separator-pen color ;
|
|
|
|
|
|
|
|
C: <separator-pen> separator-pen
|
|
|
|
|
|
|
|
M: separator-pen draw-interior
|
|
|
|
color>> gl-color
|
|
|
|
dim>> [ { 0 0.5 } v* ] [ { 1 0.5 } v* ] bi
|
|
|
|
[ [ >integer ] map ] bi@ gl-line ;
|
|
|
|
|
|
|
|
PRIVATE>
|
|
|
|
|
|
|
|
SINGLETON: ----
|
|
|
|
|
|
|
|
M: ---- <menu-item>
|
|
|
|
3drop
|
|
|
|
<gadget>
|
|
|
|
{ 0 5 } >>dim
|
|
|
|
COLOR: black <separator-pen> >>interior ;
|
|
|
|
|
2008-06-18 23:30:54 -04:00
|
|
|
: menu-theme ( gadget -- gadget )
|
2009-02-14 20:50:22 -05:00
|
|
|
COLOR: light-gray <solid> >>interior ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2008-11-30 16:03:05 -05:00
|
|
|
: <commands-menu> ( target hook commands -- menu )
|
2008-11-26 00:04:34 -05:00
|
|
|
[ <filled-pile> ] 3dip
|
2008-11-30 16:03:05 -05:00
|
|
|
[ <menu-item> add-gadget ] with with each
|
2009-02-02 01:00:45 -05:00
|
|
|
{ 5 5 } <border> menu-theme ;
|
2008-11-30 16:03:05 -05:00
|
|
|
|
|
|
|
: show-commands-menu ( target commands -- )
|
|
|
|
[ dup [ ] ] dip <commands-menu> show-menu ;
|
2008-12-19 00:56:41 -05:00
|
|
|
|
|
|
|
: <operations-menu> ( target hook -- menu )
|
2009-02-18 22:00:53 -05:00
|
|
|
over object-operations
|
|
|
|
[ primary-operation? ] partition
|
|
|
|
[ reverse ] [ [ [ command-name ] compare ] sort ] bi*
|
|
|
|
{ ---- } glue <commands-menu> ;
|
2008-12-19 00:56:41 -05:00
|
|
|
|
2009-01-16 17:39:32 -05:00
|
|
|
: show-operations-menu ( gadget target hook -- )
|
|
|
|
<operations-menu> show-menu ;
|