Ticket #25: AllowEventCallbacksToBeIOActions.patch

File AllowEventCallbacksToBeIOActions.patch, 10.8 KB (added by Thomas DuBuisson, 11 years ago)

Fix the event callback to be an IO action

Line 
11 patch for repository http://code.ouroborus.net/gloss/gloss-head:
2
3Sun Jan 22 18:36:14 PST 2012  Thomas.DuBuisson@gmail.com
4  * AllowEventCallbacksToBeIOActions
5
6New patches:
7
8[AllowEventCallbacksToBeIOActions
9Thomas.DuBuisson@gmail.com**20120123023614
10 Ignore-this: 174dfa598d26cda626cad101efbddcde
11] hunk ./gloss/Graphics/Gloss/Interface/IO/Game.hs 26
12         -> Int                          -- ^ Number of simulation steps to take for each second of real time.
13         -> world                        -- ^ The initial world.
14         -> (world -> IO Picture)        -- ^ An action to convert the world a picture.
15-        -> (Event -> world -> world)    -- ^ A function to handle input events.
16+        -> (Event -> world -> IO world) -- ^ A function to handle input events.
17         -> (Float -> world -> IO world) -- ^ A function to step the world one iteration.
18                                         --   It is passed the period of time (in seconds) needing to be advanced.
19         -> IO ()
20hunk ./gloss/Graphics/Gloss/Interface/Pure/Game.hs 41
21         display backColor simResolution
22         worldStart
23         (return . worldToPicture)
24-        (\event world -> worldHandleEvent event world)
25+        (\event world -> return $ worldHandleEvent event world)
26         (\time  world -> return $ worldAdvance     time  world)
27hunk ./gloss/Graphics/Gloss/Internals/Interface/Game.hs 41
28        -> Int                          -- ^ Number of simulation steps to take for each second of real time.
29        -> world                        -- ^ The initial world.
30        -> (world -> IO Picture)        -- ^ A function to convert the world to a picture.
31-       -> (Event -> world -> world)    -- ^ A function to handle input events.
32+       -> (Event -> world -> IO world) -- ^ A function to handle input events.
33        -> (Float -> world -> IO world) -- ^ A function to step the world one iteration.
34                                        --   It is passed the period of time (in seconds) needing to be advanced.
35        -> IO ()
36hunk ./gloss/Graphics/Gloss/Internals/Interface/Game.hs 109
37 callback_keyMouse
38        :: IORef world                  -- ^ ref to world state
39        -> IORef ViewPort
40-       -> (Event -> world -> world)    -- ^ fn to handle input events
41+       -> (Event -> world -> IO world) -- ^ fn to handle input events
42        -> Callback
43 
44 callback_keyMouse worldRef viewRef eventFn
45hunk ./gloss/Graphics/Gloss/Internals/Interface/Game.hs 119
46 handle_keyMouse
47        :: IORef a
48        -> t
49-       -> (Event -> a -> a)
50+       -> (Event -> a -> IO a)
51        -> KeyboardMouseCallback
52 
53 handle_keyMouse worldRef _ eventFn backendRef key keyState keyMods pos
54hunk ./gloss/Graphics/Gloss/Internals/Interface/Game.hs 123
55- = do  pos' <- convertPoint backendRef pos
56-       worldRef `modifyIORef` \world -> eventFn (EventKey key keyState keyMods pos') world
57-
58+ = do  pos'   <- convertPoint backendRef pos
59+       world  <- readIORef worldRef
60+        world' <- eventFn (EventKey key keyState keyMods pos') world
61+        writeIORef worldRef world'
62 
63 -- | Callback for Motion events.
64 callback_motion
65hunk ./gloss/Graphics/Gloss/Internals/Interface/Game.hs 131
66        :: IORef world                  -- ^ ref to world state
67-       -> (Event -> world -> world)    -- ^ fn to handle input events
68+       -> (Event -> world -> IO world) -- ^ fn to handle input events
69        -> Callback
70 
71 callback_motion worldRef eventFn
72hunk ./gloss/Graphics/Gloss/Internals/Interface/Game.hs 140
73 
74 handle_motion
75        :: IORef a
76-       -> (Event -> a -> a)
77+       -> (Event -> a -> IO a)
78        -> MotionCallback
79 
80 handle_motion worldRef eventFn backendRef pos
81hunk ./gloss/Graphics/Gloss/Internals/Interface/Game.hs 145
82  = do pos' <- convertPoint backendRef pos
83-      worldRef `modifyIORef` \world -> eventFn (EventMotion pos') world
84+      world  <- readIORef worldRef
85+      world' <- eventFn (EventMotion pos') world
86+      writeIORef worldRef world'
87 
88 
89 convertPoint ::
90
91Context:
92
93[Follow API changes in gloss-examples and add -threaded when compiling
94Ben Lippmeier <benl@ouroborus.net>**20120123021212
95 Ignore-this: 322e7ff9a30930cada5a1647c6bf6a59
96]
97[Update release notes
98Ben Lippmeier <benl@ouroborus.net>**20120123015105
99 Ignore-this: 99455efa881e08e7553b808145ca313a
100]
101[Exit cleanly when uncaught exceptions hit the main loop.
102Thomas.DuBuisson@gmail.com**20120122205536
103 Ignore-this: 6b8451e03a360e0890cc9647a4f44285
104]
105[Export IO wrappers in from their own modules
106Ben Lippmeier <benl@ouroborus.net>**20120123013310
107 Ignore-this: d6aaabbaf8c321efd2fbdb97a3fac3b1
108]
109[Further generalize the monadic varients
110Thomas.DuBuisson@gmail.com**20120119042910
111 Ignore-this: f9548fd6776df7e679dc338feb99e3b2
112 
113 The reasoning here is:
114 1) World-stepping should be permitted to be IO because there might be
115 outside influences on the world state (ex: a networked game).
116 2) Rendering the world should be permitted to be IO because there
117 might be outside information needed (texture loading, map tile retrieving, etc)
118]
119[Add IO derivitives of simulate, play and animate.
120Thomas.DuBuisson@gmail.com**20120119035433
121 Ignore-this: 34cffe309cd1259296f20e5774af3154
122]
123[Update release notes
124Ben Lippmeier <benl@ouroborus.net>**20120106072543
125 Ignore-this: 6e8351f8588132f72afc8eb7f0f49572
126]
127[Fix bug in timing code and increase framerate cap to 100Hz
128Ben Lippmeier <benl@ouroborus.net>**20120106070131
129 Ignore-this: 7ff67c1a9c1763f9558868e0363ac92
130]
131[Tweak circle LOD code
132Ben Lippmeier <benl@ouroborus.net>**20120106061025
133 Ignore-this: 49e960e8210872f717ce6c4256c1ab0d
134]
135[Don't continually postRedisplay in display mode
136Ben Lippmeier <benl@ouroborus.net>**20120106051912
137 Ignore-this: 2ee4e0e523451c7ddb856c261c274fb1
138]
139[Add fastpaths to render for scales and rotates of circles and arcs
140Ben Lippmeier <benl@ouroborus.net>**20120106051409
141 Ignore-this: 4a379a2ce9f21153283afc40dd43116
142]
143[Take the absolute value of radius when drawing sectors
144Ben Lippmeier <benl@ouroborus.net>**20120106050034
145 Ignore-this: 1bfdabcd1f27243d86c699d8d52050b5
146]
147[Refine docs to improve information density and make sectorWire a compound shape
148Ben Lippmeier <benl@ouroborus.net>**20120106044620
149 Ignore-this: 935c96925fdd3cbacbd738a15dacb51d
150]
151[Update year in license files
152Ben Lippmeier <benl@ouroborus.net>**20120106033644
153 Ignore-this: 29d5553400f8edaff11868a7caf8243b
154]
155[Bump gloss-examples and gloss-field to 1.7.0
156Ben Lippmeier <benl@ouroborus.net>**20120106033531
157 Ignore-this: 279cec615952e392c0fd5afdb4f6dc6b
158]
159[Bump version to 1.7.0.1 and update readme
160Ben Lippmeier <benl@ouroborus.net>**20120106032623
161 Ignore-this: 3085006663463959f8ec797f9064934f
162]
163[Refactoring and formatting to circle and arc rendering
164Ben Lippmeier <benl@ouroborus.net>**20120106032543
165 Ignore-this: 24fed6ccb0b2939e5afa413a27c36142
166]
167[Use Arcs in the Picture data type instead of the separate arcPath function
168Ben Lippmeier <benl@ouroborus.net>**20120106032133
169 Ignore-this: 277a1212562d393c468ab55d127ef133
170]
171[Docs and formatting
172Ben Lippmeier <benl@ouroborus.net>**20120106031431
173 Ignore-this: 8e373faf915830dc7e7c92c25aa21b5a
174]
175[Commented out potential optimization for rotated arc/sector
176Douglas Burke <dburke@cfa.harvard.edu>**20111231032503
177 Ignore-this: 2e1ba4099beda1ab18d87cd79adc46d1
178]
179[Add arcPath
180Douglas Burke <dburke@cfa.harvard.edu>**20111231031239
181 Ignore-this: 59366b6804e01305f359139ee65502f8
182 
183 An alternative to adding Arc/Sector constructors is to provide
184 functions that create paths in these shapes, which can then be
185 used as a polygon or line. Unfortunately this means that we don't
186 have access to useful information such as the scale factor, which
187 makes calculating an acceptable number of steps hard, so it
188 is included as an argument.
189]
190[Minor hlint changes
191Douglas Burke <dburke@cfa.harvard.edu>**20111230212033
192 Ignore-this: 341b8ae2b9dac8732175f8045b094430
193]
194[Initial support for Arc, ThickArc, and Sector.
195Douglas Burke <dburke@cfa.harvard.edu>**20111230183500
196 Ignore-this: 9fbf2adf3aac770afc143e46a356c4fb
197 
198 Arc draws an arc between two angles at the given radius, and
199 Sector is an Arc with lines drawn to the origin of the circle.
200]
201[Removal of Control.Monad
202Douglas Burke <dburke@cfa.harvard.edu>**20111230183321
203 Ignore-this: 2e6ffecb3a03a91cfae32179d70748e0
204]
205[Haddock updates for Graphics.Gloss.Data.Picture
206Douglas Burke <dburke@cfa.harvard.edu>**20111230182918
207 Ignore-this: 63049c1abaa07aa84ae02cc855bd2497
208 
209 Added documentation for the Picture constructor aliases
210 and a few other places.
211]
212[ray: tweak material parameters
213Ben Lippmeier <benl@ouroborus.net>**20120102050142
214 Ignore-this: d5e324c609587b91a318a8dd52782f35
215]
216[ray: doc wibble
217benl@ouroborus.net**20120101173235
218 Ignore-this: f12cfcb2e53917b82de40b41def5ae32
219]
220[ray: checkered board looks ok when tilted
221benl@ouroborus.net**20120101173114
222 Ignore-this: caede9d5c66a43cec48740db3af61616
223]
224[ray: blackbar top and bottom to get zoom=3 on mac air
225benl@ouroborus.net**20120101164406
226 Ignore-this: 573488cce75cdf5a449fbe974f56cb80
227]
228[ray: change default fov for a nicer picture
229benl@ouroborus.net**20120101162611
230 Ignore-this: 133e684f8e0831807f1b656f477536ff
231]
232[ray: tweak default settings again
233benl@ouroborus.net**20120101160454
234 Ignore-this: 41fdee2ffad36953dfbe783798e1f91d
235]
236[ray: strictify more things
237benl@ouroborus.net**20120101154224
238 Ignore-this: c826b49d4ca98f0e62fce61ea0a6cf97
239]
240[ray: kill unboxings in trace
241benl@ouroborus.net**20120101150603
242 Ignore-this: cc997e7ecb9f0f0dbdb788fc57cab912
243]
244[ray: allow max bounces to be set on command line
245benl@ouroborus.net**20120101141037
246 Ignore-this: 45677dc4947d617ff32dde108ffa36bc
247]
248[ray: faster shadow check
249benl@ouroborus.net**20120101135833
250 Ignore-this: ebb29809addb86f33a7391f3a70a95ce
251]
252[ray: make wasd keys work
253Ben Lippmeier <benl@ouroborus.net>**20120101124346
254 Ignore-this: ca37d64aa87bd484c5057410d242d09
255]
256[ray: tweak starting values for mac air
257Ben Lippmeier <benl@ouroborus.net>**20120101121506
258 Ignore-this: f146bacc60a8c8e1a62e3f935d4a97b4
259]
260[ray: use fullscreen mode
261Ben Lippmeier <benl@ouroborus.net>**20120101121151
262 Ignore-this: e79c86714cf5fbe6840a6e0c800a8c79
263]
264[ray: allow translation of world
265Ben Lippmeier <benl@ouroborus.net>**20120101120303
266 Ignore-this: 37e1444eb8d3c4a1938c206048649fb6
267]
268[gloss-field: refactor animate interface
269Ben Lippmeier <benl@ouroborus.net>**20120101105103
270 Ignore-this: e0274835ba22c1bbed2bf200a76db9cd
271]
272[ray: tweak starting values
273Ben Lippmeier <benl@ouroborus.net>**20120101103613
274 Ignore-this: 6b9db1ca825a464280857fc043b0cb33
275]
276[ray: tweaks and use sphere for ground instead of plane
277Ben Lippmeier <benl@ouroborus.net>**20120101100652
278 Ignore-this: 543814ee6560cdc35c13edb1e13a7746
279]
280[ray: refactor lighting code
281Ben Lippmeier <benl@ouroborus.net>**20120101092048
282 Ignore-this: eeadf0486cb425b94d8e0ff6e4a386e1
283]
284[examples: refactor findNearest in ray
285Ben Lippmeier <benl@ouroborus.net>**20120101085057
286 Ignore-this: 93899595a1c882238b4bbfdab2f6f8e7
287]
288[examples: first version of ray tracer works
289Ben Lippmeier <benl@ouroborus.net>**20120101072308
290 Ignore-this: e08dbe347f79b0f9c7f70eddb78f784c
291]
292[TAG Release 1.6.0.1
293Ben Lippmeier <benl@ouroborus.net>**20111228020857
294 Ignore-this: 8b11cdc5e55cbaf6ecd6dddc346eed61
295]
296Patch bundle hash:
2978d9bb92495ad5e006b142359ef7cee1cfd1ee70c