! Copyright (C) 2005 Slava Pestov. ! See http://factor.sf.net/license.txt for BSD license. IN: gadgets USING: generic kernel math namespaces ; ! A tile is a gadget with a caption. Dragging the caption ! moves the gadget. The title bar also has buttons for ! performing various actions. : click-rel ( gadget -- point ) screen-pos hand [ hand-clicked screen-pos - ] keep hand-click-rel - ; : drag-tile ( tile -- ) dup click-rel hand screen-pos + >rect rot move-gadget ; : raise ( gadget -- ) dup gadget-parent >r dup unparent r> add-gadget ; : caption-actions ( caption -- ) dup [ [ raise ] swap handle-gesture drop ] [ button-down 1 ] set-action dup [ drop ] [ button-up 1 ] set-action [ [ drag-tile ] swap handle-gesture drop ] [ drag 1 ] set-action ; : close-tile [ close-tile ] swap handle-gesture drop ; : ( -- gadget ) line-border dup [ close-tile ] button-actions ; : caption-content ( text -- gadget ) 1/2 10 0 [ swap add-gadget ] keep [ >r