[ window-controls>> >>window-controls ]
[ initial-background-color >>background-color ]
[ grab-input?>> >>grab-input? ]
- [ gadgets>> [ 1 track-add ] each ]
+ [ gadgets>> dup sequence? [ [ 1 track-add ] each ] [ 1 track-add ] if ]
[ pref-dim>> >>pref-dim ]
} cleave ;
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
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 ;
[ geom>> ] [ get-draw ] bi draw-bunny
] if ;
-M: bunny-world pref-dim* ( gadget -- dim )
- drop { 640 480 } ;
-
bunny-world H{
{ T{ key-down f f "TAB" } [ next-draw ] }
} set-gestures
-: bunny-window ( -- )
- [
- f T{ world-attributes
- { world-class bunny-world }
- { title "Bunny" }
- { pixel-format-attributes {
- windowed
- double-buffered
- T{ depth-bits { value 16 } }
- } }
- } open-window
- ] with-ui ;
-
-MAIN: bunny-window
+MAIN-WINDOW: bunny-window
+ {
+ { world-class bunny-world }
+ { title "Bunny" }
+ { pixel-format-attributes {
+ windowed
+ double-buffered
+ T{ depth-bits { value 16 } }
+ } }
+ { pref-dim { 640 480 } }
+ } ;
! Copyright (C) 2006, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
-USING: kernel math math.functions math.parser models
+USING: arrays kernel math math.functions math.parser models
models.arrow models.range models.product sequences ui
ui.gadgets ui.gadgets.tracks ui.gadgets.labels ui.gadgets.packs
ui.gadgets.sliders ui.pens.solid ui.render math.rectangles accessors
] bi
] bi* ;
-: color-picker-window ( -- )
- [ <color-picker> "Color Picker" open-window ] with-ui ;
-
-MAIN: color-picker-window
+MAIN-WINDOW: color-picker-window { { title "Color Picker" } }
+ <color-picker> >>gadgets ;
10 >>min-rows
10 >>max-rows ;
-: color-table-demo ( -- )
- [ <color-table> <scroller> "Colors" open-window ] with-ui ;
-
-MAIN: color-table-demo
+MAIN-WINDOW: color-table-demo { { title "Colors" } }
+ <color-table> <scroller> >>gadgets ;
: <demo-runner> ( -- gadget )
<pile> 1 >>fill { 2 2 } >>gap demo-vocabs [ <run-vocab-button> add-gadget ] each ;
-: demos ( -- ) [ <demo-runner> { 2 2 } <border> <scroller> "Demos" open-window ] with-ui ;
-
-MAIN: demos
\ No newline at end of file
+MAIN-WINDOW: demos { { title "Demos" } }
+ <demo-runner> { 2 2 } <border> <scroller> >>gadgets ;
-USING: ui ui.gadgets.labels ;
+USING: accessors ui ui.gadgets.labels ;
IN: hello-ui
-: hello ( -- )
- [ "Hello world" <label> "Hi" open-window ] with-ui ;
-
-MAIN: hello
+MAIN-WINDOW: hello { { title "Hi" } }
+ "Hello world" <label> >>gadgets ;
! Copyright (C) 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
-USING: ui.gadgets.panes ui.gadgets.borders ui io io.styles ;
+USING: accessors ui.gadgets.panes ui.gadgets.borders ui io io.styles ;
IN: hello-unicode
: <hello-gadget> ( -- gadget )
] with-style
] make-pane { 10 10 } <border> ;
-: hello-unicode ( -- ) [ <hello-gadget> "გამარჯობა" open-window ] with-ui ;
-
-MAIN: hello-unicode
\ No newline at end of file
+MAIN-WINDOW: hello-unicode { { title "გამარჯობა" } }
+ <hello-gadget> >>gadgets ;
{ mouse-scroll [ handle-mouse-scroll ] }
} set-gestures
-: jamshred-window ( -- )
- [ <jamshred> <jamshred-gadget> "Jamshred" open-window ] with-ui ;
-
-MAIN: jamshred-window
+MAIN-WINDOW: jamshred-window { { title "Jamshred" } }
+ <jamshred> <jamshred-gadget> >>gadgets ;
"99:99:99" lcd >>string
monospace-font >>font ;
-: time-window ( -- )
- [ time get <time-display> "Time" open-window ] with-ui ;
-
-MAIN: time-window
+MAIN-WINDOW: time-window { { title "Time" } }
+ time get <time-display> >>gadgets ;
M: maze pref-dim* drop { 400 400 } ;
-: maze-window ( -- )
- [ <maze> "Maze" open-window ] with-ui ;
+MAIN-WINDOW: maze-window { { title "Maze" } }
+ <maze> >>gadgets ;
MAIN: maze-window
ui.gadgets.tracks ui.gadgets.labels ui.gadgets.glass
math.rectangles cocoa.dialogs ;
IN: merger
-: main ( -- ) [
+
+MAIN-WINDOW: merger-window {
+ { title "Merging" }
+ { pref-dim { 300 220 } }
+ }
vertical <track>
{ "From:" "To:" } f <model> f <model> 2array
[
] with-directory
] keep hide-glass
] [ drop ] if ]
- "merge" swap <border-button> 0.4 track-add { 300 220 } >>pref-dim "Merging" open-window
-] with-ui ;
-
-MAIN: main
\ No newline at end of file
+ "merge" swap <border-button> 0.4 track-add
+ >>gadgets ;
USING: arrays kernel math opengl opengl.gl opengl.glu
-opengl.demo-support ui ui.gadgets ui.render ;
+opengl.demo-support ui ui.gadgets ui.render literals accessors ;
IN: nehe.2
TUPLE: nehe2-gadget < gadget ;
: <nehe2-gadget> ( -- gadget )
nehe2-gadget new ;
-M: nehe2-gadget pref-dim* ( gadget -- dim )
- drop width height 2array ;
-
M: nehe2-gadget draw-gadget* ( gadget -- )
drop
GL_PROJECTION glMatrixMode
-1.0 -1.0 0.0 glVertex3f
] do-state ;
-: run2 ( -- )
- <nehe2-gadget> "NeHe Tutorial 2" open-window ;
+MAIN-WINDOW: run2 { { title "NeHe Tutorial 2" } { pref-dim { $ width $ height } } }
+ <nehe2-gadget> >>gadgets ;
USING: arrays kernel math opengl opengl.gl opengl.glu
-opengl.demo-support ui ui.gadgets ui.render ;
+opengl.demo-support ui ui.gadgets ui.render literals accessors ;
IN: nehe.3
TUPLE: nehe3-gadget < gadget ;
: <nehe3-gadget> ( -- gadget )
nehe3-gadget new ;
-M: nehe3-gadget pref-dim* ( gadget -- dim )
- drop width height 2array ;
-
M: nehe3-gadget draw-gadget* ( gadget -- )
drop
GL_PROJECTION glMatrixMode
-1.0 -1.0 0.0 glVertex3f
] do-state ;
-: run3 ( -- )
- <nehe3-gadget> "NeHe Tutorial 3" open-window ;
+MAIN-WINDOW: run3 { { title "NeHe Tutorial 3" } { pref-dim { $ width $ height } } }
+ <nehe3-gadget> >>gadgets ;
USING: arrays kernel math opengl opengl.gl opengl.glu
opengl.demo-support ui ui.gadgets ui.render threads accessors
-calendar ;
+calendar literals ;
IN: nehe.4
TUPLE: nehe4-gadget < gadget rtri rquad thread quit? ;
0.0 >>rtri
0.0 >>rquad ;
-M: nehe4-gadget pref-dim* ( gadget -- dim )
- drop width height 2array ;
-
M: nehe4-gadget draw-gadget* ( gadget -- )
GL_PROJECTION glMatrixMode
glLoadIdentity
M: nehe4-gadget ungraft* ( gadget -- )
t >>quit? drop ;
-: run4 ( -- )
- <nehe4-gadget> "NeHe Tutorial 4" open-window ;
+MAIN-WINDOW: run4 { { title "NeHe Tutorial 4" } { pref-dim { $ width $ height } } }
+ <nehe4-gadget> >>gadgets ;
USING: arrays kernel math opengl opengl.gl opengl.glu\r
opengl.demo-support ui ui.gadgets ui.render threads accessors\r
-calendar ;\r
+calendar literals ;\r
IN: nehe.5\r
\r
TUPLE: nehe5-gadget < gadget rtri rquad thread quit? ;\r
0.0 >>rtri\r
0.0 >>rquad ;\r
\r
-M: nehe5-gadget pref-dim* ( gadget -- dim )\r
- drop width height 2array ;\r
-\r
M: nehe5-gadget draw-gadget* ( gadget -- )\r
GL_PROJECTION glMatrixMode\r
glLoadIdentity\r
M: nehe5-gadget ungraft* ( gadget -- )\r
t >>quit? drop ;\r
\r
-\r
-: run5 ( -- )\r
- <nehe5-gadget> "NeHe Tutorial 5" open-window ;\r
+MAIN-WINDOW: run5 { { title "NeHe Tutorial 5" } { pref-dim { $ width $ height } } }\r
+ <nehe5-gadget> >>gadgets ;\r
USING: ui.gadgets.buttons ui.gadgets.packs ui.gadgets ui
-nehe.2 nehe.3 nehe.4 nehe.5 kernel ;
+nehe.2 nehe.3 nehe.4 nehe.5 kernel accessors ;
IN: nehe
-: nehe-window ( -- )
- [
- <filled-pile>
- "Nehe 2" [ drop run2 ] <border-button> add-gadget
- "Nehe 3" [ drop run3 ] <border-button> add-gadget
- "Nehe 4" [ drop run4 ] <border-button> add-gadget
- "Nehe 5" [ drop run5 ] <border-button> add-gadget
- "Nehe examples" open-window
- ] with-ui ;
+MAIN-WINDOW: nehe-window { { title "Nehe Examples" } }
+ <filled-pile>
+ "Nehe 2" [ drop run2 ] <border-button> add-gadget
+ "Nehe 3" [ drop run3 ] <border-button> add-gadget
+ "Nehe 4" [ drop run4 ] <border-button> add-gadget
+ "Nehe 5" [ drop run5 ] <border-button> add-gadget
+ >>gadgets ;
MAIN: nehe-window