2017-11-27 00:43:43 +00:00
|
|
|
{-# LANGUAGE RankNTypes #-}
|
2017-11-26 21:26:41 +00:00
|
|
|
module Affection.MessageBus.Message where
|
|
|
|
|
2017-11-27 04:27:52 +00:00
|
|
|
import Data.Word (Word32(..))
|
|
|
|
import Data.Int (Int32(..))
|
|
|
|
|
|
|
|
import qualified SDL
|
|
|
|
|
|
|
|
import Linear (V2(..))
|
2017-11-27 00:43:43 +00:00
|
|
|
|
2017-11-26 21:26:41 +00:00
|
|
|
class Message msg where
|
2017-11-27 04:27:52 +00:00
|
|
|
msgTime :: msg -> Word32
|
2017-11-27 00:43:43 +00:00
|
|
|
|
2017-11-29 07:29:44 +00:00
|
|
|
data SystemMessage
|
|
|
|
-- = MsgUserMessage
|
|
|
|
-- { msgUMWhen :: Word32
|
|
|
|
-- , msgUMPayload :: m
|
|
|
|
-- } -- ^ Generic user defined message with custom payload
|
|
|
|
= MsgEngineReady Word32
|
2017-11-27 04:27:52 +00:00
|
|
|
| MsgWindowShown
|
|
|
|
{ msgWSWhen :: Word32
|
|
|
|
, msgWSWindow :: SDL.Window
|
|
|
|
}
|
|
|
|
| MsgWindowHidden
|
|
|
|
{ msgWHWhen :: Word32
|
|
|
|
, msgWHWindow :: SDL.Window
|
|
|
|
}
|
|
|
|
| MsgWindowExposed
|
|
|
|
{ msgWEWhen :: Word32
|
|
|
|
, msgWEWindow :: SDL.Window
|
|
|
|
}
|
|
|
|
| MsgWindowMoved
|
|
|
|
{ msgWMWhen :: Word32
|
|
|
|
, msgWMWindow :: SDL.Window
|
|
|
|
, msgWMNewPos :: V2 Int32
|
|
|
|
}
|
|
|
|
| MsgWindowResized
|
|
|
|
{ msgWRWhen :: Word32
|
|
|
|
, msgWRWindow :: SDL.Window
|
|
|
|
, msgWRNewSize :: V2 Int32
|
|
|
|
}
|
|
|
|
| MsgWindowSizeChanged
|
|
|
|
{ msgWSCWhen :: Word32
|
|
|
|
, msgWSCWindow :: SDL.Window
|
|
|
|
}
|
|
|
|
| MsgWindowMinimized
|
|
|
|
{ msgWMinWhen :: Word32
|
|
|
|
, msgWMinWindow :: SDL.Window
|
|
|
|
}
|
|
|
|
| MsgWindowMaximized
|
|
|
|
{ msgWMaxWhen :: Word32
|
|
|
|
, msgWMaxWindow :: SDL.Window
|
|
|
|
}
|
|
|
|
| MsgWindowRestored
|
|
|
|
{ msgWRestWhen :: Word32
|
|
|
|
, msgWRestWindow :: SDL.Window
|
|
|
|
}
|
|
|
|
| MsgWindowGainedMouseFocus
|
|
|
|
{ msgWGMFWhen :: Word32
|
|
|
|
, msgWGMFWindow :: SDL.Window
|
|
|
|
}
|
|
|
|
| MsgWindowLostMouseFocus
|
|
|
|
{ msgWLMFWhen :: Word32
|
|
|
|
, msgWLMFWindow :: SDL.Window
|
|
|
|
}
|
|
|
|
| MsgWindowGainedKeyboardFocus
|
|
|
|
{ msgWGKFWhen :: Word32
|
|
|
|
, msgWGKFWindow :: SDL.Window
|
|
|
|
}
|
|
|
|
| MsgWindowLostKeyboardFocus
|
|
|
|
{ msgWLKFWhen :: Word32
|
|
|
|
, msgWLKFWindow :: SDL.Window
|
|
|
|
}
|
|
|
|
| MsgWindowClosed
|
|
|
|
{ msgWCWhen :: Word32
|
|
|
|
, msgWCWindow :: SDL.Window
|
|
|
|
}
|
2017-11-27 00:43:43 +00:00
|
|
|
|
2017-11-29 07:29:44 +00:00
|
|
|
instance Message SystemMessage where
|
|
|
|
-- msgTime (MsgUserMessage t _) = t
|
2017-11-27 00:43:43 +00:00
|
|
|
msgTime (MsgEngineReady t) = t
|
2017-11-27 04:27:52 +00:00
|
|
|
msgTime (MsgWindowShown t _) = t
|
|
|
|
msgTime (MsgWindowHidden t _) = t
|
|
|
|
msgTime (MsgWindowExposed t _) = t
|
|
|
|
msgTime (MsgWindowMoved t _ _) = t
|
|
|
|
msgTime (MsgWindowResized t _ _) = t
|
|
|
|
msgTime (MsgWindowSizeChanged t _) = t
|
|
|
|
msgTime (MsgWindowMinimized t _) = t
|
|
|
|
msgTime (MsgWindowMaximized t _) = t
|
|
|
|
msgTime (MsgWindowRestored t _) = t
|
|
|
|
msgTime (MsgWindowGainedMouseFocus t _) = t
|
|
|
|
msgTime (MsgWindowLostMouseFocus t _) = t
|
|
|
|
msgTime (MsgWindowGainedKeyboardFocus t _) = t
|
|
|
|
msgTime (MsgWindowLostKeyboardFocus t _) = t
|
|
|
|
msgTime (MsgWindowClosed t _) = t
|