! 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. TUPLE: tile original ; : click-rel ( gadget -- point ) screen-pos hand [ hand-clicked screen-pos - ] keep hand-click-rel - ; : move-tile ( tile -- ) dup click-rel hand screen-pos + >rect rot move-gadget ; : start-resizing ( tile -- ) dup shape-size rect> swap set-tile-original ; : resize-tile ( tile -- ) dup screen-pos hand hand-click-pos - over tile-original + over hand relative + >rect rot resize-gadget ; : raise ( gadget -- ) dup gadget-parent >r dup unparent r> add-gadget ; : caption-actions ( caption -- ) dup [ raise ] [ button-down 1 ] link-action dup [ drop ] [ button-up 1 ] set-action [ move-tile ] [ drag 1 ] link-action ; : close-tile [ close-tile ] swap handle-gesture drop ; : ( -- gadget ) line-border dup [ close-tile ] button-gestures ; : caption-content ( text -- gadget ) 1/2 10 0 [ swap add-gadget ] keep [ >r