2006-09-14 16:15:39 -04:00
|
|
|
! Copyright (C) 2006 Slava Pestov.
|
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
|
|
|
IN: gadgets-workspace
|
|
|
|
USING: gadgets gadgets-books gadgets-controls gadgets-workspace
|
|
|
|
generic kernel models scratchpad sequences syntax ;
|
|
|
|
|
|
|
|
DEFER: workspace-window
|
|
|
|
|
|
|
|
GENERIC: call-tool* ( arg tool -- )
|
|
|
|
|
2006-09-20 03:22:26 -04:00
|
|
|
GENERIC: tool-scroller ( tool -- scroller )
|
|
|
|
|
|
|
|
M: gadget tool-scroller drop f ;
|
|
|
|
|
|
|
|
GENERIC: tool-help ( tool -- topic )
|
|
|
|
|
|
|
|
M: gadget tool-help drop f ;
|
|
|
|
|
2006-09-14 16:15:39 -04:00
|
|
|
TUPLE: workspace ;
|
|
|
|
|
|
|
|
TUPLE: tool gadget ;
|
|
|
|
|
|
|
|
: show-tool ( class workspace -- tool )
|
2006-09-16 16:31:40 -04:00
|
|
|
[
|
|
|
|
gadget-children [ tool-gadget class eq? ] find-with swap
|
|
|
|
] keep control-model set-model* ;
|
2006-09-14 16:15:39 -04:00
|
|
|
|
|
|
|
: select-tool ( workspace class -- ) swap show-tool drop ;
|
|
|
|
|
|
|
|
: find-workspace ( -- workspace )
|
|
|
|
[ workspace? ] find-window
|
|
|
|
[ world-gadget ] [ workspace-window find-workspace ] if* ;
|
|
|
|
|
|
|
|
: call-tool ( arg class -- )
|
|
|
|
find-workspace show-tool call-tool* ;
|