added resize-handler, made event-code not as wide

This commit is contained in:
Nicole Dresselhaus 2014-02-04 13:58:12 +01:00
parent a038139677
commit 0d887354d5

View File

@ -371,49 +371,67 @@ processEvent e = do
case eventData e of case eventData e of
Window _ winEvent -> Window _ winEvent ->
case winEvent of case winEvent of
Closing -> modify $ \s -> s { Closing ->
modify $ \s -> s {
stateWinClose = True stateWinClose = True
} }
_ -> return () Resized {windowResizedTo=size} -> do
modify $ \s -> s {
stateWindowWidth = sizeWidth size
,stateWindowHeight = sizeHeight size
}
adjustWindow
SizeChanged ->
adjustWindow
_ ->
liftIO $ putStrLn $ unwords ["Unhandled Window-Event:",(show e)]
Keyboard movement _ repeat key -> --up/down window(ignored) true/false actualKey Keyboard movement _ repeat key -> --up/down window(ignored) true/false actualKey
-- need modifiers? use "keyModifiers key" to get them -- need modifiers? use "keyModifiers key" to get them
case keyScancode key of case keyScancode key of
Escape -> modify $ \s -> s { Escape ->
modify $ \s -> s {
stateWinClose = True stateWinClose = True
} }
SDL.Left -> modify $ \s -> s { SDL.Left ->
modify $ \s -> s {
stateArrowsPressed = (stateArrowsPressed s) { stateArrowsPressed = (stateArrowsPressed s) {
arrowLeft = movement == KeyDown arrowLeft = movement == KeyDown
} }
} }
SDL.Right -> modify $ \s -> s { SDL.Right ->
modify $ \s -> s {
stateArrowsPressed = (stateArrowsPressed s) { stateArrowsPressed = (stateArrowsPressed s) {
arrowRight = movement == KeyDown arrowRight = movement == KeyDown
} }
} }
SDL.Up -> modify $ \s -> s { SDL.Up ->
modify $ \s -> s {
stateArrowsPressed = (stateArrowsPressed s) { stateArrowsPressed = (stateArrowsPressed s) {
arrowUp = movement == KeyDown arrowUp = movement == KeyDown
} }
} }
SDL.Down -> modify $ \s -> s { SDL.Down ->
modify $ \s -> s {
stateArrowsPressed = (stateArrowsPressed s) { stateArrowsPressed = (stateArrowsPressed s) {
arrowDown = movement == KeyDown arrowDown = movement == KeyDown
} }
} }
SDL.KeypadPlus -> when (movement == KeyDown) $ do SDL.KeypadPlus ->
when (movement == KeyDown) $ do
modify $ \s -> s { modify $ \s -> s {
stateTessellationFactor = min ((stateTessellationFactor s)+1) 5 stateTessellationFactor = min ((stateTessellationFactor s)+1) 5
} }
state <- get state <- get
liftIO $ putStrLn $ unwords ["Tessellation at: ", show $ stateTessellationFactor state] liftIO $ putStrLn $ unwords ["Tessellation at: ", show $ stateTessellationFactor state]
SDL.KeypadMinus -> when (movement == KeyDown) $ do SDL.KeypadMinus ->
when (movement == KeyDown) $ do
modify $ \s -> s { modify $ \s -> s {
stateTessellationFactor = max ((stateTessellationFactor s)-1) 1 stateTessellationFactor = max ((stateTessellationFactor s)-1) 1
} }
state <- get state <- get
liftIO $ putStrLn $ unwords ["Tessellation at: ", show $ stateTessellationFactor state] liftIO $ putStrLn $ unwords ["Tessellation at: ", show $ stateTessellationFactor state]
_ -> return () _ ->
return ()
MouseMotion _ id st (Position x y) xrel yrel -> do MouseMotion _ id st (Position x y) xrel yrel -> do
state <- get state <- get
when (stateMouseDown state && not (stateDragging state)) $ when (stateMouseDown state && not (stateDragging state)) $
@ -432,14 +450,15 @@ processEvent e = do
case button of case button of
LeftButton -> do LeftButton -> do
let pressed = state == Pressed let pressed = state == Pressed
modify $ \s -> s modify $ \s -> s {
{ stateMouseDown = pressed stateMouseDown = pressed
} }
unless pressed $ unless pressed $
modify $ \s -> s modify $ \s -> s {
{ stateDragging = False stateDragging = False
} }
_ -> return () _ ->
return ()
MouseWheel _ id hscroll vscroll -> do MouseWheel _ id hscroll vscroll -> do
env <- ask env <- ask
modify $ \s -> s modify $ \s -> s