added resize-handler, made event-code not as wide
This commit is contained in:
parent
a038139677
commit
0d887354d5
49
src/Main.hs
49
src/Main.hs
@ -371,49 +371,67 @@ processEvent e = do
|
||||
case eventData e of
|
||||
Window _ winEvent ->
|
||||
case winEvent of
|
||||
Closing -> modify $ \s -> s {
|
||||
Closing ->
|
||||
modify $ \s -> s {
|
||||
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
|
||||
-- need modifiers? use "keyModifiers key" to get them
|
||||
case keyScancode key of
|
||||
Escape -> modify $ \s -> s {
|
||||
Escape ->
|
||||
modify $ \s -> s {
|
||||
stateWinClose = True
|
||||
}
|
||||
SDL.Left -> modify $ \s -> s {
|
||||
SDL.Left ->
|
||||
modify $ \s -> s {
|
||||
stateArrowsPressed = (stateArrowsPressed s) {
|
||||
arrowLeft = movement == KeyDown
|
||||
}
|
||||
}
|
||||
SDL.Right -> modify $ \s -> s {
|
||||
SDL.Right ->
|
||||
modify $ \s -> s {
|
||||
stateArrowsPressed = (stateArrowsPressed s) {
|
||||
arrowRight = movement == KeyDown
|
||||
}
|
||||
}
|
||||
SDL.Up -> modify $ \s -> s {
|
||||
SDL.Up ->
|
||||
modify $ \s -> s {
|
||||
stateArrowsPressed = (stateArrowsPressed s) {
|
||||
arrowUp = movement == KeyDown
|
||||
}
|
||||
}
|
||||
SDL.Down -> modify $ \s -> s {
|
||||
SDL.Down ->
|
||||
modify $ \s -> s {
|
||||
stateArrowsPressed = (stateArrowsPressed s) {
|
||||
arrowDown = movement == KeyDown
|
||||
}
|
||||
}
|
||||
SDL.KeypadPlus -> when (movement == KeyDown) $ do
|
||||
SDL.KeypadPlus ->
|
||||
when (movement == KeyDown) $ do
|
||||
modify $ \s -> s {
|
||||
stateTessellationFactor = min ((stateTessellationFactor s)+1) 5
|
||||
}
|
||||
state <- get
|
||||
liftIO $ putStrLn $ unwords ["Tessellation at: ", show $ stateTessellationFactor state]
|
||||
SDL.KeypadMinus -> when (movement == KeyDown) $ do
|
||||
SDL.KeypadMinus ->
|
||||
when (movement == KeyDown) $ do
|
||||
modify $ \s -> s {
|
||||
stateTessellationFactor = max ((stateTessellationFactor s)-1) 1
|
||||
}
|
||||
state <- get
|
||||
liftIO $ putStrLn $ unwords ["Tessellation at: ", show $ stateTessellationFactor state]
|
||||
_ -> return ()
|
||||
_ ->
|
||||
return ()
|
||||
MouseMotion _ id st (Position x y) xrel yrel -> do
|
||||
state <- get
|
||||
when (stateMouseDown state && not (stateDragging state)) $
|
||||
@ -432,14 +450,15 @@ processEvent e = do
|
||||
case button of
|
||||
LeftButton -> do
|
||||
let pressed = state == Pressed
|
||||
modify $ \s -> s
|
||||
{ stateMouseDown = pressed
|
||||
modify $ \s -> s {
|
||||
stateMouseDown = pressed
|
||||
}
|
||||
unless pressed $
|
||||
modify $ \s -> s
|
||||
{ stateDragging = False
|
||||
modify $ \s -> s {
|
||||
stateDragging = False
|
||||
}
|
||||
_ -> return ()
|
||||
_ ->
|
||||
return ()
|
||||
MouseWheel _ id hscroll vscroll -> do
|
||||
env <- ask
|
||||
modify $ \s -> s
|
||||
|
Loading…
Reference in New Issue
Block a user