annotate modules/ui.tp @ 335:79a14e41b79a

Add image element and placeholder text element to ui module
author Michael Pavone <pavone@retrodev.com>
date Mon, 30 Mar 2015 19:12:51 -0700
parents ead24192ed45
children b8f721bde066
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
332
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
1 {
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
2 _visibleWindows <- []
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
3 _needsInit <- true
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
4 _initRes <- 0
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
5 _checkInitSDL <- {
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
6 if: _needsInit {
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
7 _initRes <- (sdl init: ((sdl subsystems) video)) = 0
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
8 _needsInit <- true
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
9 }
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
10 _initRes
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
11 }
335
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
12
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
13 _applyProps <- :base properties {
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
14 foreach: (object propertiesOf: base) :_ name {
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
15 if: (object does: properties understand?: name) {
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
16 object setProperty: name on: base to: (object sendMessage: name to: properties)
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
17 }
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
18 }
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
19 base
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
20 }
332
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
21 #{
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
22 import: [
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
23 r:g:b
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
24 r:g:b:a
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
25 ] from: sdl
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
26 _styles <- []
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
27 window <- :properties {
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
28 _wind <- option none
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
29 _renderer <- option none
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
30 base <- #{
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
31 title <- "Window"
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
32 width <- 640
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
33 height <- 480
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
34 x <- 0
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
35 y <- 0
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
36 color <- (ui r: 255u8 g: 255u8 b: 255u8)
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
37 children <- #[]
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
38
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
39 show <- {
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
40 if: (_checkInitSDL: ) {
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
41 _wind <- sdl createWindow: title pos: x y size: width height flags: 0u32
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
42 _wind value: :window {
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
43 _renderer <- window createRenderer: -1 flags: ((window renderOpts) accelerated)
335
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
44 layout:
332
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
45 draw:
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
46 } none: {
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
47 false
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
48 }
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
49 }
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
50 }
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
51
335
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
52 layout <- {
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
53 yPos <- 0
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
54 xPos <- 0
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
55 rowMaxHeight <- 0
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
56 foreach: children :_ child {
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
57 softMax <- (width - xPos)
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
58 child softMaxWidth: softMax maxWidth: width maxHeight: (height - yPos) renderer: _renderer
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
59 if: (child width) > softMax {
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
60 yPos <- yPos + rowMaxHeight
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
61 xPos <- 0
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
62 rowMaxHeight <- 0
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
63 }
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
64 child x!: xPos
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
65 child y!: yPos
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
66 xPos <- xPos + (child width)
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
67 if: (child height) > rowMaxHeight {
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
68 rowMaxHeight <- (child height)
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
69 }
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
70 if: xPos >= width {
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
71 yPos <- yPos + rowMaxHeight
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
72 xPos <- 0
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
73 rowMaxHeight <- 0
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
74 }
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
75 }
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
76 }
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
77
332
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
78 draw <- {
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
79 print: "Draw!\n"
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
80 _renderer value: :renderer {
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
81 print: "Rendering!\n"
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
82 renderer drawColor!: color
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
83 renderer clear
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
84
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
85 foreach: children :_ child {
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
86 child draw: renderer
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
87 }
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
88 renderer present
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
89 true
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
90 } none: { false }
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
91 }
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
92
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
93 styles <- { _styles }
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
94
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
95 styles! <- :newstyles{
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
96 //TODO: apply styles
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
97 _styles <- newstyles
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
98 }
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
99 }
335
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
100 _applyProps: base properties
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
101 }
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
102
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
103 text <- :properties {
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
104 #{
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
105 text <- ""
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
106 //TODO: replace this with font family and style once fontconfig is hooked up
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
107 font <- "/usr/share/fonts/truetype/droid/DroidSans.ttf"
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
108 fontSize <- 12.0
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
109 width <- -1
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
110 height <- -1
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
111 x <- 0
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
112 y <- 0
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
113
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
114 softMaxWidth:maxWidth:maxHeight <- :softMax :maxWidth :maxHeight {
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
115
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
116 }
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
117 }
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
118 }
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
119
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
120 image <- :properties {
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
121 _texture <- option none
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
122 _applyProps: #{
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
123 source <- ""
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
124 width <- -1
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
125 height <- -1
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
126 x <- 0
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
127 y <- 0
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
128
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
129 softMaxWidth:maxWidth:maxHeight:renderer <- :softMax :maxWidth :maxHeight :_renderer {
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
130 _renderer value: :renderer {
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
131 (sdl loadBMP: source) value: :surface {
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
132 (surface asTexture: renderer) value: :texture {
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
133 _texture <- option value: texture
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
134 width <- texture width
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
135 height <- texture height
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
136 if: (width > maxWidth) {
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
137 width <- maxWidth
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
138 }
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
139 if: (height > maxHeight) {
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
140 height <- maxHeight
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
141 }
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
142 } none: {
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
143 width <- 0
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
144 height <- 0
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
145 }
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
146 } none: {
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
147 print: "Failed to load " . source . "\n"
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
148 //Should this have some kind of placeholder as a fallback?
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
149 width <- 0
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
150 height <- 0
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
151 }
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
152 } none: {
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
153 }
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
154 }
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
155
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
156 draw <- :_ {
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
157 _texture value: :texture {
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
158 print: "Rendering bitmap to " . x . ", " . y . ", size: " . width . ", " . height . "\n"
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
159 texture copyTo: (sdl rect: x y size: width height)
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
160 } none: {
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
161 }
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
162 }
79a14e41b79a Add image element and placeholder text element to ui module
Michael Pavone <pavone@retrodev.com>
parents: 332
diff changeset
163 } properties
332
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
164 }
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
165
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
166 enterEventLoop <- {
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
167 continue? <- true
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
168
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
169 _handlers <- dict hash
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
170 _handlers set: ((sdl eventTypes) quit) :event {
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
171 continue? <- false
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
172 }
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
173 _handlers set: ((sdl eventTypes) window) :event {
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
174 if: (event event) = ((sdl windowEventTypes) exposed) {
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
175 foreach: _visibleWindows :_ wind {
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
176 print: "Redrawing window\n"
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
177 wind draw
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
178 }
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
179 }
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
180 }
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
181 while: { continue? } do: {
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
182 (sdl waitEvent) value: :event {
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
183 _handlers ifget: (event type) :handler {
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
184 handler: event
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
185 } else: {
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
186 print: "Unhandled event type: " . (event type) . "\n"
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
187 }
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
188 } none: {}
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
189 }
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
190 }
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
191 }
ead24192ed45 Initial work on a UI module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
192 }