gloss-examples 1.7.3.1 → 1.7.3.2
raw patch · 2 files changed
+38/−20 lines, 2 files
Files
- gloss-examples.cabal +1/−1
- raster/Fluid/UserEvent.hs +37/−19
gloss-examples.cabal view
@@ -1,5 +1,5 @@ Name: gloss-examples-Version: 1.7.3.1+Version: 1.7.3.2 License: MIT License-file: LICENSE Author: Ben Lippmeier
raster/Fluid/UserEvent.hs view
@@ -10,34 +10,26 @@ -- | Handle user events for the Gloss `playIO` wrapper. userEvent :: Config -> Event -> Model -> Model userEvent config- (EventKey key keyState _mods (x, y)) + (EventKey key keyState mods (x, y)) (Model df ds vf vs cl sp _cb) - | MouseButton G.LeftButton <- key+ -- Add velocity ---------------------------------------------+ | MouseButton G.RightButton <- key , Down <- keyState- , (x',y') <- windowToModel config (x, y) - = Model { densityField = df- , densitySource = Just (Source (Z:.y':.x') 1)- , velocityField = vf- , velocitySource = vs- , clickLoc = cl- , stepsPassed = sp- , currButton = M.LeftButton- }-- | MouseButton G.LeftButton <- key- , Up <- keyState+ , (x',y') <- windowToModel config (x,y) = Model { densityField = df , densitySource = ds , velocityField = vf , velocitySource = vs- , clickLoc = cl+ , clickLoc = Just (x',y') , stepsPassed = sp- , currButton = M.None+ , currButton = M.RightButton } - | MouseButton G.RightButton <- key+ -- Accept shift-leftbutton for people with trackpads+ | MouseButton G.LeftButton <- key , Down <- keyState+ , Down <- shift mods , (x',y') <- windowToModel config (x,y) = Model { densityField = df , densitySource = ds@@ -62,13 +54,39 @@ , currButton = M.None } - -- Reset model++ -- Add density ----------------------------------------------+ | MouseButton G.LeftButton <- key+ , Down <- keyState+ , (x',y') <- windowToModel config (x, y) + = Model { densityField = df+ , densitySource = Just (Source (Z:.y':.x') 1)+ , velocityField = vf+ , velocitySource = vs+ , clickLoc = cl+ , stepsPassed = sp+ , currButton = M.LeftButton+ }++ | MouseButton G.LeftButton <- key+ , Up <- keyState+ = Model { densityField = df+ , densitySource = ds+ , velocityField = vf+ , velocitySource = vs+ , clickLoc = cl+ , stepsPassed = sp+ , currButton = M.None+ }+++ -- Reset model ---------------------------------------------- | Char 'r' <- key , Down <- keyState = initModel (configInitialDensity config) (configInitialVelocity config) - -- Quit program+ -- Quit program --------------------------------------------- | Char 'q' <- key , Down <- keyState = error "Quitting"