2018-09-25 05:02:33 +00:00
|
|
|
module Affection.MessageBus.Message.WindowMessage
|
|
|
|
( WindowMessage(..)
|
|
|
|
-- | SDL reexports
|
|
|
|
, SDL.Window
|
|
|
|
) where
|
2017-11-29 16:49:56 +00:00
|
|
|
|
|
|
|
import Affection.MessageBus.Message.Class
|
|
|
|
|
2018-09-25 14:10:36 +00:00
|
|
|
import Data.Int (Int32)
|
2017-11-29 16:49:56 +00:00
|
|
|
|
|
|
|
import qualified SDL
|
|
|
|
|
|
|
|
import Linear (V2(..))
|
|
|
|
|
2018-09-25 05:02:33 +00:00
|
|
|
-- | Datatype for handling Window events handed down rom SDL2
|
2017-12-06 05:36:25 +00:00
|
|
|
data WindowMessage
|
2018-09-25 05:02:33 +00:00
|
|
|
= MsgWindowShow -- ^ Window show event
|
|
|
|
{ msgWSWhen :: Double -- ^ Message time
|
|
|
|
, msgWSWindow :: SDL.Window -- ^ Window identifier
|
2017-11-29 16:49:56 +00:00
|
|
|
}
|
2018-09-25 05:02:33 +00:00
|
|
|
| MsgWindowHide -- ^ Window hide event
|
|
|
|
{ msgWHWhen :: Double -- ^ Message time
|
|
|
|
, msgWHWindow :: SDL.Window -- ^ Window identifier
|
2017-11-29 16:49:56 +00:00
|
|
|
}
|
2018-09-25 05:02:33 +00:00
|
|
|
| MsgWindowExpose -- ^ Window expose event
|
|
|
|
{ msgWEWhen :: Double -- ^ Message time
|
|
|
|
, msgWEWindow :: SDL.Window -- ^ Window identifier
|
2017-11-29 16:49:56 +00:00
|
|
|
}
|
2018-09-25 05:02:33 +00:00
|
|
|
| MsgWindowMove -- ^ Window move event
|
|
|
|
{ msgWMWhen :: Double -- ^ Message time
|
|
|
|
, msgWMWindow :: SDL.Window -- ^ Window identifier
|
|
|
|
, msgWMNewPos :: V2 Int32 -- ^ New absolute window position
|
2017-11-29 16:49:56 +00:00
|
|
|
}
|
2018-09-25 05:02:33 +00:00
|
|
|
| MsgWindowResize -- ^ Window resize event
|
|
|
|
{ msgWRWhen :: Double -- ^ Message time
|
|
|
|
, msgWRWindow :: SDL.Window -- ^ Window identifier
|
|
|
|
, msgWRNewSize :: V2 Int32 -- ^ New absolute window size
|
2017-11-29 16:49:56 +00:00
|
|
|
}
|
2018-09-25 05:02:33 +00:00
|
|
|
| MsgWindowSizeChange -- ^ Window size change event
|
|
|
|
{ msgWSCWhen :: Double -- ^ Message time
|
|
|
|
, msgWSCWindow :: SDL.Window -- ^ Window identifier
|
|
|
|
, msgWSCNewSize :: V2 Int32 -- ^ New absolute window size
|
2017-11-29 16:49:56 +00:00
|
|
|
}
|
2018-09-25 05:02:33 +00:00
|
|
|
| MsgWindowMinimize -- ^ Window minimize event
|
|
|
|
{ msgWMinWhen :: Double -- ^ Message time
|
|
|
|
, msgWMinWindow :: SDL.Window -- ^ Window identifier
|
2017-11-29 16:49:56 +00:00
|
|
|
}
|
2018-09-25 05:02:33 +00:00
|
|
|
| MsgWindowMaximize -- ^ Window maximize event
|
|
|
|
{ msgWMaxWhen :: Double -- ^ Message time
|
|
|
|
, msgWMaxWindow :: SDL.Window -- ^ Window identifier
|
2017-11-29 16:49:56 +00:00
|
|
|
}
|
2018-09-25 05:02:33 +00:00
|
|
|
| MsgWindowRestore -- ^ Window restore event
|
|
|
|
{ msgWRestWhen :: Double -- ^ Message time
|
|
|
|
, msgWRestWindow :: SDL.Window -- ^ Window identifier
|
2017-11-29 16:49:56 +00:00
|
|
|
}
|
2018-09-25 05:02:33 +00:00
|
|
|
| MsgWindowGainMouseFocus -- ^ Window gain mouse focus event
|
|
|
|
{ msgWGMFWhen :: Double -- ^ Message Time
|
|
|
|
, msgWGMFWindow :: SDL.Window -- ^ Window identifier
|
2017-11-29 16:49:56 +00:00
|
|
|
}
|
2018-09-25 05:02:33 +00:00
|
|
|
| MsgWindowLoseMouseFocus -- ^ Window lose mouse focus event
|
|
|
|
{ msgWLMFWhen :: Double -- ^ Message Time
|
|
|
|
, msgWLMFWindow :: SDL.Window -- ^ Window identifier
|
2017-11-29 16:49:56 +00:00
|
|
|
}
|
2018-09-25 05:02:33 +00:00
|
|
|
| MsgWindowGainKeyboardFocus -- ^ Window gain keyboard focus event
|
|
|
|
{ msgWGKFWhen :: Double -- ^ Message time
|
|
|
|
, msgWGKFWindow :: SDL.Window -- ^ Window identifier
|
2017-11-29 16:49:56 +00:00
|
|
|
}
|
2018-09-25 05:02:33 +00:00
|
|
|
| MsgWindowLoseKeyboardFocus -- ^ Window lose keyboard focus event
|
|
|
|
{ msgWLKFWhen :: Double -- ^ Message time
|
|
|
|
, msgWLKFWindow :: SDL.Window -- ^ Window identifier
|
2017-11-29 16:49:56 +00:00
|
|
|
}
|
2018-09-25 05:02:33 +00:00
|
|
|
| MsgWindowClose -- ^ Window close event
|
|
|
|
{ msgWCWhen :: Double -- ^ Message time
|
|
|
|
, msgWCWindow :: SDL.Window -- ^ Window identifier
|
2017-11-29 16:49:56 +00:00
|
|
|
}
|
2017-12-13 03:37:16 +00:00
|
|
|
deriving (Show)
|
2017-11-29 16:49:56 +00:00
|
|
|
|
2017-12-06 05:36:25 +00:00
|
|
|
instance Message WindowMessage where
|
2017-12-12 12:12:47 +00:00
|
|
|
-- msgTime (MsgEngineReady t) = t
|
|
|
|
msgTime (MsgWindowShow t _) = t
|
|
|
|
msgTime (MsgWindowHide t _) = t
|
|
|
|
msgTime (MsgWindowExpose t _) = t
|
|
|
|
msgTime (MsgWindowMove t _ _) = t
|
|
|
|
msgTime (MsgWindowResize t _ _) = t
|
2018-03-17 01:49:16 +00:00
|
|
|
msgTime (MsgWindowSizeChange t _ _) = t
|
2017-12-12 12:12:47 +00:00
|
|
|
msgTime (MsgWindowMinimize t _) = t
|
|
|
|
msgTime (MsgWindowMaximize t _) = t
|
|
|
|
msgTime (MsgWindowRestore t _) = t
|
|
|
|
msgTime (MsgWindowGainMouseFocus t _) = t
|
|
|
|
msgTime (MsgWindowLoseMouseFocus t _) = t
|
|
|
|
msgTime (MsgWindowGainKeyboardFocus t _) = t
|
|
|
|
msgTime (MsgWindowLoseKeyboardFocus t _) = t
|
|
|
|
msgTime (MsgWindowClose t _) = t
|