| 
									
										
										
										
											2009-01-07 21:56:09 -05:00
										 |  |  | ! Copyright (C) 2006, 2009 Slava Pestov. | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | ! See http://factorcode.org/license.txt for BSD license. | 
					
						
							| 
									
										
										
										
											2009-02-01 21:31:42 -05:00
										 |  |  | USING: arrays assocs io kernel math models namespaces make dlists | 
					
						
							| 
									
										
										
										
											2009-05-14 17:54:16 -04:00
										 |  |  | deques sequences threads words continuations init | 
					
						
							| 
									
										
										
										
											2009-04-07 23:30:13 -04:00
										 |  |  | combinators combinators.short-circuit hashtables concurrency.flags | 
					
						
							|  |  |  | sets accessors calendar fry destructors ui.gadgets ui.gadgets.private | 
					
						
							| 
									
										
										
										
											2009-05-03 16:52:26 -04:00
										 |  |  | ui.gadgets.worlds ui.gadgets.tracks ui.gestures ui.backend ui.render | 
					
						
							| 
									
										
										
										
											2010-01-15 19:55:43 -05:00
										 |  |  | strings classes.tuple classes.tuple.parser lexer vocabs.parser parser ;
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | IN: ui | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-19 17:54:27 -05:00
										 |  |  | <PRIVATE
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | ! Assoc mapping aliens to gadgets | 
					
						
							|  |  |  | SYMBOL: windows | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-10 13:29:07 -04:00
										 |  |  | : window ( handle -- world ) windows get-global at ;
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | : window-focus ( handle -- gadget ) window world-focus ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : register-window ( world handle -- )
 | 
					
						
							|  |  |  |     #! Add the new window just below the topmost window. Why? | 
					
						
							|  |  |  |     #! So that if the new window doesn't actually receive focus | 
					
						
							|  |  |  |     #! (eg, we're using focus follows mouse and the mouse is not | 
					
						
							|  |  |  |     #! in the new window when it appears) Factor doesn't get | 
					
						
							|  |  |  |     #! confused and send workspace operations to the new window, | 
					
						
							|  |  |  |     #! etc. | 
					
						
							|  |  |  |     swap 2array windows get-global push
 | 
					
						
							|  |  |  |     windows get-global dup length 1 >
 | 
					
						
							| 
									
										
										
										
											2009-08-13 20:21:44 -04:00
										 |  |  |     [ [ length 1 - dup 1 - ] keep exchange ] [ drop ] if ;
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | : unregister-window ( handle -- )
 | 
					
						
							| 
									
										
										
										
											2009-04-30 22:38:14 -04:00
										 |  |  |     windows [ [ first = not ] with filter ] change-global ;
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | : raised-window ( world -- )
 | 
					
						
							| 
									
										
										
										
											2008-05-06 10:16:48 -04:00
										 |  |  |     windows get-global
 | 
					
						
							|  |  |  |     [ [ second eq? ] with find drop ] keep
 | 
					
						
							| 
									
										
										
										
											2009-10-28 00:41:57 -04:00
										 |  |  |     [ nth ] [ remove-nth! drop ] [ nip ] 2tri push ;
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-11-22 01:40:17 -05:00
										 |  |  | : focus-gestures ( new old -- )
 | 
					
						
							|  |  |  |     drop-prefix <reversed>
 | 
					
						
							| 
									
										
										
										
											2009-01-28 01:30:57 -05:00
										 |  |  |     lose-focus swap each-gesture | 
					
						
							|  |  |  |     gain-focus swap each-gesture ;
 | 
					
						
							| 
									
										
										
										
											2007-11-22 01:40:17 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-08 16:07:15 -04:00
										 |  |  | : ?grab-input ( world -- )
 | 
					
						
							|  |  |  |     dup grab-input?>> [ handle>> (grab-input) ] [ drop ] if ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : ?ungrab-input ( world -- )
 | 
					
						
							|  |  |  |     dup grab-input?>> [ handle>> (ungrab-input) ] [ drop ] if ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | : focus-world ( world -- )
 | 
					
						
							| 
									
										
										
										
											2008-09-27 15:36:04 -04:00
										 |  |  |     t >>focused? | 
					
						
							| 
									
										
										
										
											2009-05-08 16:07:15 -04:00
										 |  |  |     [ ?grab-input ] [ | 
					
						
							|  |  |  |         dup raised-window | 
					
						
							|  |  |  |         focus-path f focus-gestures | 
					
						
							|  |  |  |     ] bi ;
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | : unfocus-world ( world -- )
 | 
					
						
							| 
									
										
										
										
											2008-09-27 15:36:04 -04:00
										 |  |  |     f >>focused? | 
					
						
							| 
									
										
										
										
											2009-05-08 16:07:15 -04:00
										 |  |  |     [ ?ungrab-input ] | 
					
						
							|  |  |  |     [ focus-path f swap focus-gestures ] bi ;
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-11 13:35:41 -04:00
										 |  |  | : set-up-window ( world -- )
 | 
					
						
							| 
									
										
										
										
											2009-05-03 23:01:35 -04:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2009-07-01 18:57:21 -04:00
										 |  |  |         [ set-gl-context ] | 
					
						
							| 
									
										
										
										
											2009-05-11 13:35:41 -04:00
										 |  |  |         [ [ title>> ] keep set-title ] | 
					
						
							|  |  |  |         [ begin-world ] | 
					
						
							| 
									
										
										
										
											2009-05-03 23:01:35 -04:00
										 |  |  |         [ resize-world ] | 
					
						
							| 
									
										
										
										
											2009-05-11 13:35:41 -04:00
										 |  |  |         [ t >>active? drop ] | 
					
						
							|  |  |  |         [ request-focus ] | 
					
						
							| 
									
										
										
										
											2009-05-03 23:01:35 -04:00
										 |  |  |     } cleave ;
 | 
					
						
							| 
									
										
										
										
											2009-05-03 16:52:26 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-11 13:35:41 -04:00
										 |  |  | : clean-up-broken-window ( world -- )
 | 
					
						
							|  |  |  |     [ | 
					
						
							|  |  |  |         dup { [ focused?>> ] [ grab-input?>> ] } 1&& | 
					
						
							|  |  |  |         [ handle>> (ungrab-input) ] [ drop ] if
 | 
					
						
							|  |  |  |     ] [ handle>> (close-window) ] bi ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-03 16:52:26 -04:00
										 |  |  | M: world graft* | 
					
						
							| 
									
										
										
										
											2009-05-11 13:35:41 -04:00
										 |  |  |     [ (open-window) ] | 
					
						
							|  |  |  |     [ | 
					
						
							|  |  |  |         [ set-up-window ] | 
					
						
							|  |  |  |         [ [ clean-up-broken-window ] [ ui-error ] bi* ] recover
 | 
					
						
							|  |  |  |     ] bi ;
 | 
					
						
							| 
									
										
										
										
											2007-11-22 01:40:17 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | : reset-world ( world -- )
 | 
					
						
							| 
									
										
										
										
											2007-11-22 01:40:17 -05:00
										 |  |  |     #! This is used when a window is being closed, but also | 
					
						
							|  |  |  |     #! when restoring saved worlds on image startup. | 
					
						
							| 
									
										
										
										
											2009-02-10 03:45:43 -05:00
										 |  |  |     f >>handle unfocus-world ;
 | 
					
						
							| 
									
										
										
										
											2008-12-09 12:22:23 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | : (ungraft-world) ( world -- )
 | 
					
						
							| 
									
										
										
										
											2009-01-21 00:06:23 -05:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2009-07-01 18:57:21 -04:00
										 |  |  |         [ set-gl-context ] | 
					
						
							| 
									
										
										
										
											2009-04-01 00:44:38 -04:00
										 |  |  |         [ text-handle>> [ dispose ] when* ] | 
					
						
							| 
									
										
										
										
											2009-02-10 19:47:34 -05:00
										 |  |  |         [ images>> [ dispose ] when* ] | 
					
						
							| 
									
										
										
										
											2009-01-21 00:06:23 -05:00
										 |  |  |         [ hand-clicked close-global ] | 
					
						
							|  |  |  |         [ hand-gadget close-global ] | 
					
						
							| 
									
										
										
										
											2009-05-03 16:52:26 -04:00
										 |  |  |         [ end-world ] | 
					
						
							| 
									
										
										
										
											2009-07-04 20:13:53 -04:00
										 |  |  |         [ [ <reversed> [ [ dispose ] when* ] each V{ } clone ] change-window-resources drop ] | 
					
						
							| 
									
										
										
										
											2009-01-21 00:06:23 -05:00
										 |  |  |     } cleave ;
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-11-22 01:40:17 -05:00
										 |  |  | M: world ungraft* | 
					
						
							| 
									
										
										
										
											2008-12-09 12:22:23 -05:00
										 |  |  |     [ (ungraft-world) ] | 
					
						
							|  |  |  |     [ handle>> (close-window) ] | 
					
						
							|  |  |  |     [ reset-world ] tri ;
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-11-22 01:40:17 -05:00
										 |  |  | : init-ui ( -- )
 | 
					
						
							|  |  |  |     <dlist> \ graft-queue set-global
 | 
					
						
							|  |  |  |     <dlist> \ layout-queue set-global
 | 
					
						
							| 
									
										
										
										
											2008-11-22 00:01:20 -05:00
										 |  |  |     <dlist> \ gesture-queue set-global
 | 
					
						
							| 
									
										
										
										
											2007-11-22 01:40:17 -05:00
										 |  |  |     V{ } clone windows set-global ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : restore-gadget-later ( gadget -- )
 | 
					
						
							| 
									
										
										
										
											2008-08-29 19:44:19 -04:00
										 |  |  |     dup graft-state>> { | 
					
						
							| 
									
										
										
										
											2007-11-22 01:40:17 -05:00
										 |  |  |         { { f f } [ ] } | 
					
						
							|  |  |  |         { { f t } [ ] } | 
					
						
							| 
									
										
										
										
											2008-09-27 15:36:04 -04:00
										 |  |  |         { { t t } [ { f f } >>graft-state ] } | 
					
						
							|  |  |  |         { { t f } [ dup unqueue-graft { f f } >>graft-state ] } | 
					
						
							| 
									
										
										
										
											2007-11-22 01:40:17 -05:00
										 |  |  |     } case graft-later ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : restore-gadget ( gadget -- )
 | 
					
						
							|  |  |  |     dup restore-gadget-later | 
					
						
							| 
									
										
										
										
											2008-08-29 19:44:19 -04:00
										 |  |  |     children>> [ restore-gadget ] each ;
 | 
					
						
							| 
									
										
										
										
											2007-11-22 01:40:17 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | : restore-world ( world -- )
 | 
					
						
							| 
									
										
										
										
											2009-02-12 10:48:05 -05:00
										 |  |  |     { | 
					
						
							|  |  |  |         [ reset-world ] | 
					
						
							| 
									
										
										
										
											2009-04-01 00:44:38 -04:00
										 |  |  |         [ f >>text-handle f >>images drop ] | 
					
						
							| 
									
										
										
										
											2009-02-12 10:48:05 -05:00
										 |  |  |         [ restore-gadget ] | 
					
						
							|  |  |  |     } cleave ;
 | 
					
						
							| 
									
										
										
										
											2007-11-22 01:40:17 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | : update-hand ( world -- )
 | 
					
						
							|  |  |  |     dup hand-world get-global eq?
 | 
					
						
							|  |  |  |     [ hand-loc get-global swap move-hand ] [ drop ] if ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-10-21 18:10:27 -04:00
										 |  |  | : layout-queued ( -- seq )
 | 
					
						
							|  |  |  |     [ | 
					
						
							| 
									
										
										
										
											2007-11-16 01:19:13 -05:00
										 |  |  |         in-layout? on
 | 
					
						
							|  |  |  |         layout-queue [ | 
					
						
							| 
									
										
										
										
											2007-10-21 18:10:27 -04:00
										 |  |  |             dup layout find-world [ , ] when*
 | 
					
						
							| 
									
										
										
										
											2008-08-19 15:06:20 -04:00
										 |  |  |         ] slurp-deque | 
					
						
							| 
									
										
										
										
											2010-02-27 14:52:24 -05:00
										 |  |  |     ] { } make members ;
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-10-21 18:10:27 -04:00
										 |  |  | : redraw-worlds ( seq -- )
 | 
					
						
							| 
									
										
										
										
											2007-11-23 17:23:53 -05:00
										 |  |  |     [ dup update-hand draw-world ] each ;
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-11-22 00:01:20 -05:00
										 |  |  | : send-queued-gestures ( -- )
 | 
					
						
							| 
									
										
										
										
											2008-12-10 17:40:05 -05:00
										 |  |  |     gesture-queue [ send-queued-gesture notify-queued ] slurp-deque ;
 | 
					
						
							| 
									
										
										
										
											2008-11-22 00:01:20 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-02-25 17:48:11 -05:00
										 |  |  | : update-ui ( -- )
 | 
					
						
							| 
									
										
										
										
											2009-04-07 23:30:13 -04:00
										 |  |  |     notify-queued | 
					
						
							|  |  |  |     layout-queued | 
					
						
							|  |  |  |     redraw-worlds | 
					
						
							|  |  |  |     send-queued-gestures ;
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-02-25 20:37:43 -05:00
										 |  |  | SYMBOL: ui-thread | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-02-25 17:48:11 -05:00
										 |  |  | : ui-running ( quot -- )
 | 
					
						
							|  |  |  |     t \ ui-running set-global
 | 
					
						
							|  |  |  |     [ f \ ui-running set-global ] [ ] cleanup ; inline
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-19 17:54:27 -05:00
										 |  |  | PRIVATE>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : find-window ( quot -- world )
 | 
					
						
							| 
									
										
										
										
											2009-05-07 00:40:27 -04:00
										 |  |  |     [ windows get values ] dip
 | 
					
						
							|  |  |  |     '[ dup children>> [ ] [ nip first ] if-empty @ ] | 
					
						
							|  |  |  |     find-last nip ; inline
 | 
					
						
							| 
									
										
										
										
											2009-02-19 17:54:27 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-02-25 20:37:43 -05:00
										 |  |  | : ui-running? ( -- ? )
 | 
					
						
							|  |  |  |     \ ui-running get-global ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-19 17:54:27 -05:00
										 |  |  | <PRIVATE
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-02-25 17:48:11 -05:00
										 |  |  | : update-ui-loop ( -- )
 | 
					
						
							| 
									
										
										
										
											2009-04-07 23:30:13 -04:00
										 |  |  |     #! Note the logic: if update-ui fails, we open an error window | 
					
						
							|  |  |  |     #! and run one iteration of update-ui. If that also fails, well, | 
					
						
							|  |  |  |     #! the whole UI subsystem is broken so we exit out of the | 
					
						
							|  |  |  |     #! update-ui-loop. | 
					
						
							|  |  |  |     [ { [ ui-running? ] [ ui-thread get-global self eq? ] } 0&& ] | 
					
						
							|  |  |  |     [ | 
					
						
							|  |  |  |         ui-notify-flag get lower-flag | 
					
						
							|  |  |  |         [ update-ui ] [ ui-error update-ui ] recover
 | 
					
						
							|  |  |  |     ] while ;
 | 
					
						
							| 
									
										
										
										
											2008-02-25 17:48:11 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | : start-ui-thread ( -- )
 | 
					
						
							| 
									
										
										
										
											2008-02-25 20:37:43 -05:00
										 |  |  |     [ self ui-thread set-global update-ui-loop ] | 
					
						
							|  |  |  |     "UI update" spawn drop ;
 | 
					
						
							| 
									
										
										
										
											2008-02-25 17:48:11 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-19 17:54:27 -05:00
										 |  |  | : start-ui ( quot -- )
 | 
					
						
							| 
									
										
										
										
											2009-03-16 04:01:47 -04:00
										 |  |  |     call( -- ) notify-ui-thread start-ui-thread ;
 | 
					
						
							| 
									
										
										
										
											2009-02-19 17:54:27 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | : restore-windows ( -- )
 | 
					
						
							|  |  |  |     [ | 
					
						
							|  |  |  |         windows get [ values ] [ delete-all ] bi
 | 
					
						
							|  |  |  |         [ restore-world ] each
 | 
					
						
							|  |  |  |         forget-rollover | 
					
						
							|  |  |  |     ] (with-ui) ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : restore-windows? ( -- ? )
 | 
					
						
							|  |  |  |     windows get empty? not ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-03 16:52:26 -04:00
										 |  |  | : ?attributes ( gadget title/attributes -- attributes )
 | 
					
						
							| 
									
										
										
										
											2009-06-18 23:01:31 -04:00
										 |  |  |     dup string? [ world-attributes new swap >>title ] [ clone ] if
 | 
					
						
							| 
									
										
										
										
											2009-05-03 16:52:26 -04:00
										 |  |  |     swap [ [ [ 1array ] [ f ] if* ] curry unless* ] curry change-gadgets ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-19 17:54:27 -05:00
										 |  |  | PRIVATE>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-11-24 22:09:40 -05:00
										 |  |  | : open-world-window ( world -- )
 | 
					
						
							| 
									
										
										
										
											2008-09-27 15:36:04 -04:00
										 |  |  |     dup pref-dim >>dim dup relayout graft ;
 | 
					
						
							| 
									
										
										
										
											2007-11-24 22:09:40 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-03 12:03:34 -04:00
										 |  |  | : open-window* ( gadget title/attributes -- window )
 | 
					
						
							|  |  |  |     ?attributes <world> [ open-world-window ] keep ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-03 16:52:26 -04:00
										 |  |  | : open-window ( gadget title/attributes -- )
 | 
					
						
							| 
									
										
										
										
											2009-06-03 12:03:34 -04:00
										 |  |  |     open-window* drop ;
 | 
					
						
							| 
									
										
										
										
											2007-11-24 22:09:40 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-13 23:28:33 -04:00
										 |  |  | : set-fullscreen ( gadget ? -- )
 | 
					
						
							|  |  |  |     [ find-world ] dip (set-fullscreen) ;
 | 
					
						
							| 
									
										
										
										
											2008-02-11 02:53:20 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | : fullscreen? ( gadget -- ? )
 | 
					
						
							| 
									
										
										
										
											2009-05-13 23:28:33 -04:00
										 |  |  |     find-world (fullscreen?) ;
 | 
					
						
							| 
									
										
										
										
											2008-02-11 02:53:20 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-13 21:05:22 -04:00
										 |  |  | : toggle-fullscreen ( gadget -- )
 | 
					
						
							| 
									
										
										
										
											2009-05-13 23:28:33 -04:00
										 |  |  |     dup fullscreen? not set-fullscreen ;
 | 
					
						
							| 
									
										
										
										
											2009-05-13 21:05:22 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-02-21 00:13:31 -05:00
										 |  |  | : raise-window ( gadget -- )
 | 
					
						
							|  |  |  |     find-world raise-window* ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-22 20:01:50 -04:00
										 |  |  | : topmost-window ( -- world )
 | 
					
						
							|  |  |  |     windows get last second ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-11-24 22:09:40 -05:00
										 |  |  | HOOK: close-window ui-backend ( gadget -- )
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | M: object close-window | 
					
						
							|  |  |  |     find-world [ ungraft ] when* ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-02-25 20:37:43 -05:00
										 |  |  | [ | 
					
						
							|  |  |  |     f \ ui-running set-global
 | 
					
						
							|  |  |  |     <flag> ui-notify-flag set-global
 | 
					
						
							| 
									
										
										
										
											2009-10-19 22:17:02 -04:00
										 |  |  | ] "ui" add-startup-hook | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | : with-ui ( quot -- )
 | 
					
						
							| 
									
										
										
										
											2009-03-16 04:01:47 -04:00
										 |  |  |     ui-running? [ call( -- ) ] [ '[ init-ui @ ] (with-ui) ] if ;
 | 
					
						
							| 
									
										
										
										
											2009-01-08 18:02:54 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-10 13:29:07 -04:00
										 |  |  | HOOK: beep ui-backend ( -- )
 | 
					
						
							| 
									
										
										
										
											2010-01-15 19:55:43 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-23 22:28:57 -05:00
										 |  |  | HOOK: system-alert ui-backend ( caption text -- )
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-16 15:18:50 -05:00
										 |  |  | : parse-main-window-attributes ( class -- attributes )
 | 
					
						
							|  |  |  |     "{" expect dup all-slots parse-tuple-literal-slots ;
 | 
					
						
							| 
									
										
										
										
											2010-01-15 19:55:43 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | : define-main-window ( word attributes quot -- )
 | 
					
						
							|  |  |  |     [ | 
					
						
							| 
									
										
										
										
											2010-01-15 20:06:50 -05:00
										 |  |  |         '[ [ f _ clone @ open-window ] with-ui ] (( -- )) define-declared | 
					
						
							| 
									
										
										
										
											2010-01-15 19:55:43 -05:00
										 |  |  |     ] [ 2drop current-vocab (>>main) ] 3bi ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | SYNTAX: MAIN-WINDOW: | 
					
						
							| 
									
										
										
										
											2010-01-16 15:18:50 -05:00
										 |  |  |     CREATE | 
					
						
							|  |  |  |     world-attributes parse-main-window-attributes | 
					
						
							|  |  |  |     parse-definition | 
					
						
							|  |  |  |     define-main-window ;
 |