]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/ui/ui.factor
pry off some ui app boilerplate with a MAIN-WINDOW: syntax
[factor.git] / basis / ui / ui.factor
index 8260608cd4cb40ccb492cc1bd464ce5010264945..1bf7617bc975d02c8fa535278ea702a69010a54a 100644 (file)
@@ -5,7 +5,7 @@ deques sequences threads words continuations init
 combinators combinators.short-circuit hashtables concurrency.flags
 sets accessors calendar fry destructors ui.gadgets ui.gadgets.private
 ui.gadgets.worlds ui.gadgets.tracks ui.gestures ui.backend ui.render
-strings ;
+strings classes.tuple classes.tuple.parser lexer vocabs.parser parser ;
 IN: ui
 
 <PRIVATE
@@ -242,3 +242,15 @@ M: object close-window
     ui-running? [ call( -- ) ] [ '[ init-ui @ ] (with-ui) ] if ;
 
 HOOK: beep ui-backend ( -- )
+
+: parse-main-window ( class -- attributes quot )
+    "{" expect dup all-slots parse-tuple-literal-slots
+    parse-definition ;
+
+: define-main-window ( word attributes quot -- )
+    [
+        '[ [ f _ @ open-window ] with-ui ] (( -- )) define-declared
+    ] [ 2drop current-vocab (>>main) ] 3bi ;
+
+SYNTAX: MAIN-WINDOW:
+    CREATE world-attributes parse-main-window define-main-window ;