! Copyright (C) 2005, 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: accessors kernel locals math.rectangles math.vectors namespaces opengl sequences sorting ui.commands ui.gadgets ui.gadgets.buttons ui.gadgets.glass ui.gadgets.packs ui.gadgets.worlds ui.gestures ui.operations ui.pens ui.pens.solid ui.theme ui.tools.common ; IN: ui.gadgets.menus : show-menu ( owner menu -- ) [ find-world ] dip hand-loc get-global { 0 0 } show-glass ; GENERIC: ( target hook command -- button ) M:: object ( target hook command -- button ) command command-name [ hook call target command command-button-quot call hide-glass ] ; separator-pen M: separator-pen draw-interior color>> gl-color dim>> [ { 0 0.5 } v* ] [ { 1 0.5 } v* ] bi [ v>integer ] bi@ gl-line ; : ( items -- gadget ) [ ] dip add-gadgets ; PRIVATE> SINGLETON: ---- M: ---- 3drop { 0 5 } >>dim menu-border-color >>interior ; : ( gadgets -- menu ) { 0 3 } >>gap margins menu-border-color >>boundary menu-background >>interior ; : ( target hook commands -- menu ) [ ] 2with map ; : show-commands-menu ( target commands -- ) [ dup [ ] ] dip show-menu ; : ( target hook -- menu ) over object-operations [ primary-operation? ] partition [ reverse ] [ [ command-name ] sort-with ] bi* { ---- } glue ; : show-operations-menu ( gadget target hook -- ) show-menu ;