-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A SDL2-based graphics library, batteries-included. -- -- This package provides the wheel for a graphical application or a game. -- -- Basic concepts and features: -- -- @package minilight @version 0.4.2 module Control.Lens.TH.Rules -- | Custom rules of the lens. All lens are prefixed by '_'. lensRules_ :: LensRules -- | A simple logger class for LightT monad module Control.Monad.Caster class MonadLogger m getLogger :: (MonadLogger m, MonadIO m) => m LogQueue debug :: (MonadLogger m, MonadIO m, ToBuilder s) => s -> m () info :: (MonadLogger m, MonadIO m, ToBuilder s) => s -> m () warn :: (MonadLogger m, MonadIO m, ToBuilder s) => s -> m () err :: (MonadLogger m, MonadIO m, ToBuilder s) => s -> m () -- | Types which are able to be converted into Builder -- Builder toBuilde encodes String and -- Text as utf-8. class ToBuilder a toBuilder :: ToBuilder a => a -> Builder -- | Log levels. These are matched to syslog. data LogLevel LogDebug :: LogLevel LogInfo :: LogLevel LogNotice :: LogLevel LogWarn :: LogLevel LogError :: LogLevel LogCritical :: LogLevel LogAlert :: LogLevel LogEmergency :: LogLevel -- | Queue of LogMsg. data LogQueue stdoutLogger :: LogLevel -> IO LogQueue iohandleLogger :: Handle -> LogLevel -> IO LogQueue module Data.Registry.Class -- | IRegistry typeclass presents a registry interface. The -- complexity O(1) in the operations can be "amortized" -- complexity. class IRegistry reg -- | O(1) Checking if the specified key exists has :: (IRegistry reg, MonadIO m) => reg v -> Text -> m Bool -- | O(1) Indexing (!) :: (IRegistry reg, MonadIO m) => reg v -> Text -> m v -- | O(1) Safe indexing (!?) :: (IRegistry reg, MonadIO m) => reg v -> Text -> m (Maybe v) -- | O(1) Update, raise an exception if the key does not exist. update :: (IRegistry reg, MonadIO m) => reg v -> Text -> (v -> m v) -> m () -- | O(1) Write, raise an exception if the key does not exist. write :: (IRegistry reg, MonadIO m) => reg v -> Text -> v -> m () -- | O(1) Adding a new value to the last position register :: (IRegistry reg, MonadIO m) => reg v -> Text -> v -> m () -- | O(n) Inserting a new value to the specified position (in the -- underlying vector) insert :: (IRegistry reg, MonadIO m) => reg v -> Int -> Text -> v -> m () -- | O(n) Deleting the specified value (this is a slow operation). delete :: (IRegistry reg, MonadIO m) => reg v -> Text -> m () -- | O(1) Get the underlying vector. Be careful: modifying the -- vector might cause a problem. asVec :: IRegistry reg => reg v -> IOVector v infixl 9 !? infixl 9 ! -- | For-loop over the registry, ignoring the key order. forV_ :: (MonadIO m, IRegistry reg) => reg v -> (v -> m ()) -> m () -- | For-loop over the registry with the index, ignoring the key order. iforV_ :: (MonadIO m, IRegistry reg) => reg v -> (Int -> v -> m ()) -> m () -- | Modifying the item one by one, ignoring the key order. modifyV_ :: (MonadIO m, IRegistry reg) => reg v -> (v -> m v) -> m () -- | This module provides a variant of the vector, equipped with -- push_back operation. IOVector here are supposed to be used in -- single thread situation. module Data.Vector.Mutable.PushBack -- | IOVector consists of (1) pointer to the underlying vector (2) -- length While Vector has the underlying array itself, this type -- only has the pointer. This means read/write should be slower than the -- original vector. data IOVector a IOVector :: !IORef (IOVector a) -> !IOVector Int -> IOVector a new :: Int -> IO (IOVector a) read :: IOVector a -> Int -> IO a -- | Get the position of the last cell in the IOVector. This -- operation is not safe because of the unsafePerformIO. safeLength :: IOVector a -> IO Int length :: IOVector a -> Int safeCapacity :: IOVector a -> IO Int -- | Get the capacity of the IOVector. This operation is not safe -- because of the unsafePerformIO. capacity :: IOVector a -> Int write :: IOVector a -> Int -> a -> IO () -- | O(n) Insert a value into any place. This is a slow operation. insert :: IOVector a -> Int -> a -> IO () -- | O(n) This is a slow operation. This also throws an exception if -- the specified index does not exist. delete :: IOVector a -> Int -> IO () push :: IOVector a -> a -> IO () fromList :: [a] -> IO (IOVector a) asIOVector :: IOVector a -> IO (IOVector a) asUnsafeIOVector :: IOVector a -> IOVector a -- | Registry implementation using hashtable module Data.Registry.HashTable data HashTableImpl k v HashTableImpl :: BasicHashTable k Int -> IOVector v -> HashTableImpl k v fromListImpl :: MonadIO m => [(Text, v)] -> m (HashTableImpl Text v) instance Data.Registry.Class.IRegistry (Data.Registry.HashTable.HashTableImpl Data.Text.Internal.Text) -- | This module provides a registry for the specific type with the Text -- key. -- -- This module is intended to be imported qualified, like: -- import qualified Data.Registry as R module Data.Registry -- | The Registry type can represents any IRegistry -- instance. data Registry v Registry :: reg v -> Registry v -- | O(n) Create a registry from a list. The current implementation -- uses a hashtable, defined in the module HashTable. fromList :: MonadIO m => [(Text, v)] -> m (Registry v) -- | Create a new empty registry. new :: MonadIO m => m (Registry v) instance Data.Registry.Class.IRegistry Data.Registry.Registry module MiniLight.Event -- | Event type representation data Event Signal :: Text -> Maybe Text -> Dynamic -> Event RawEvent :: Event -> Event NotifyEvent :: Event -> Event -- | EventType says some type can be used as an event type. class Typeable e => EventType e getEventType :: EventType e => e -> Text getEventType :: (EventType e, Show e) => e -> Text getEventProperties :: EventType e => e -> Object -- | Canonical datatype of Event. It consists of event name and -- event data itself. This type is usually used for global events. data EventData EventData :: Text -> Value -> EventData -- | Create a signal event. signal :: EventType a => Text -> Maybe Text -> a -> Event -- | Cast a signal event to some EventType. asSignal :: EventType a => Event -> Maybe a -- | Cast an event to some Event asRawEvent :: Event -> Maybe Event -- | Cast an event to some Event asNotifyEvent :: Event -> Maybe Event -- | Cast a signal event to EventData asEventData :: Event -> Maybe EventData instance GHC.Show.Show MiniLight.Event.EventData instance MiniLight.Event.EventType MiniLight.Event.EventData module MiniLight.Light class HasLightEnv c_aGjj lightEnv :: HasLightEnv c_aGjj => Lens' c_aGjj LightEnv _fontCache :: HasLightEnv c_aGjj => Lens' c_aGjj FontMap _logger :: HasLightEnv c_aGjj => Lens' c_aGjj LogQueue _renderer :: HasLightEnv c_aGjj => Lens' c_aGjj (Maybe Renderer) newtype LightT env m a LightT :: ReaderT env m a -> LightT env m a [runLightT'] :: LightT env m a -> ReaderT env m a -- | The environment for LightT monad. data LightEnv LightEnv :: Maybe Renderer -> FontMap -> LogQueue -> LightEnv -- | Renderer for SDL2 [renderer] :: LightEnv -> Maybe Renderer -- | System font information [fontCache] :: LightEnv -> FontMap -- | Logger connected stdout [logger] :: LightEnv -> LogQueue type MiniLight = LightT LightEnv IO liftMiniLight :: (HasLightEnv env, MonadIO m) => MiniLight a -> LightT env m a envLightT :: (env' -> env) -> LightT env m a -> LightT env' m a mapLightT :: (m a -> n a) -> LightT env m a -> LightT env n a class HasLoopEnv c_aGoj loopEnv :: HasLoopEnv c_aGoj => Lens' c_aGoj LoopEnv _events :: HasLoopEnv c_aGoj => Lens' c_aGoj (MVar [Event]) _keyStates :: HasLoopEnv c_aGoj => Lens' c_aGoj (HashMap Scancode Int) _signalQueue :: HasLoopEnv c_aGoj => Lens' c_aGoj (IORef [Event]) data LoopEnv LoopEnv :: HashMap Scancode Int -> MVar [Event] -> IORef [Event] -> LoopEnv -- | Current state of keys, represents how many frames the key down has -- been down [keyStates] :: LoopEnv -> HashMap Scancode Int -- | Event queue [events] :: LoopEnv -> MVar [Event] -- | Signals emitted from components are stored in the queue and poll in -- the next frame. [signalQueue] :: LoopEnv -> IORef [Event] -- | A font descriptor is a key used to find a font in a font cache. data FontDescriptor FontDescriptor :: !Text -> !FontStyle -> FontDescriptor -- | The family name of the font [_descriptorFamilyName] :: FontDescriptor -> !Text -- | The desired style [_descriptorStyle] :: FontDescriptor -> !FontStyle -- | Describe the basic stylistic properties of a font. data FontStyle FontStyle :: !Bool -> !Bool -> FontStyle -- | If the font is bold. [_fontStyleBold] :: FontStyle -> !Bool -- | If the font is italic. [_fontStyleItalic] :: FontStyle -> !Bool loadFontCache :: MonadIO m => m FontMap loadFont :: (HasLightEnv env, MonadIO m) => FontDescriptor -> Int -> LightT env m Font withFont :: (HasLightEnv env, MonadIO m, MonadMask m) => FontDescriptor -> Int -> (Font -> LightT env m a) -> LightT env m a -- | Monads in which IO computations may be embedded. Any monad -- built by applying a sequence of monad transformers to the IO -- monad will be an instance of this class. -- -- Instances should satisfy the following laws, which state that -- liftIO is a transformer of monads: -- -- class Monad m => MonadIO (m :: Type -> Type) -- | Lift a computation from the IO monad. liftIO :: MonadIO m => IO a -> m a instance Control.Monad.Catch.MonadCatch m => Control.Monad.Catch.MonadCatch (MiniLight.Light.LightT env m) instance Control.Monad.Catch.MonadMask m => Control.Monad.Catch.MonadMask (MiniLight.Light.LightT env m) instance Control.Monad.Catch.MonadThrow m => Control.Monad.Catch.MonadThrow (MiniLight.Light.LightT env m) instance Control.Monad.IO.Class.MonadIO m => Control.Monad.IO.Class.MonadIO (MiniLight.Light.LightT env m) instance GHC.Base.Monad m => GHC.Base.Monad (MiniLight.Light.LightT env m) instance GHC.Base.Applicative m => GHC.Base.Applicative (MiniLight.Light.LightT env m) instance GHC.Base.Functor m => GHC.Base.Functor (MiniLight.Light.LightT env m) instance GHC.Base.Monad m => Control.Monad.Reader.Class.MonadReader env (MiniLight.Light.LightT env m) instance (GHC.Base.Monad m, MiniLight.Light.HasLightEnv env) => Control.Monad.Caster.MonadLogger (MiniLight.Light.LightT env m) instance MiniLight.Light.HasLoopEnv MiniLight.Light.LoopEnv instance MiniLight.Light.HasLightEnv MiniLight.Light.LightEnv instance Data.Hashable.Class.Hashable Graphics.Text.TrueType.FontFolders.FontDescriptor -- | This module provides many convenient operations for textures. module MiniLight.Figure -- | Lens for the center of a rectangle. centerL :: Lens' (Rectangle a) (V2 a) -- | Lens for the size of a rectangle. sizeL :: Lens' (Rectangle a) (V2 a) -- | Figure type carries a texture, sizing information and rotation -- information. data Figure Figure :: Maybe Texture -> Rectangle Int -> Rectangle Int -> Double -> Figure -- | Texture can be Nothing in headless mode [texture] :: Figure -> Maybe Texture [sourceArea] :: Figure -> Rectangle Int [targetArea] :: Figure -> Rectangle Int [rotation] :: Figure -> Double -- | A figure which has no texture. You can render it but do nothing. emptyFigure :: Figure getFigureSize :: Figure -> V2 Int freeFigure :: MonadIO m => Figure -> m () union :: Rectangle Int -> Rectangle Int -> Rectangle Int -- | Render a figure. render :: (HasLightEnv env, MonadIO m, MonadMask m) => Figure -> LightT env m () -- | Render figures. renders :: (HasLightEnv env, MonadIO m, MonadMask m) => [Figure] -> LightT env m () withBlendedText :: (MonadIO m, MonadMask m) => Font -> Text -> Color -> (Surface -> m a) -> m a -- | Rendering typeclass provides basic operations for figures. class Rendering r m | r -> m -- | Change the place to be rendered. translate :: Rendering r m => V2 Int -> r -> r -- | Specify some area and clip the figure into the region. clip :: Rendering r m => Rectangle Int -> r -> r -- | Rotate a figure. rotate :: Rendering r m => Double -> r -> r -- | Create a text texture. Be careful: this is a slow operation, -- use cache as long as you can. text :: Rendering r m => Font -> V4 Word8 -> Text -> m r -- | Create a texture from a png file. Be careful: this is a slow -- operation, use cache as long as you can. picture :: Rendering r m => FilePath -> m r -- | Create a texture from a raw SDL texture. fromTexture :: Rendering r m => Texture -> m r -- | Create an outlined rectangle. Be careful: this is a slow -- operation, use cache as long as you can. rectangleOutline :: Rendering r m => V4 Word8 -> V2 Int -> m r -- | Create a filled texture. Be careful: this is a slow operation, -- use cache as long as you can. rectangleFilled :: Rendering r m => V4 Word8 -> V2 Int -> m r -- | Create an outlined triangle. Be careful: this is a slow -- operation, use cache as long as you can. triangleOutline :: Rendering r m => V4 Word8 -> V2 Int -> m r instance MiniLight.Figure.Rendering MiniLight.Figure.Figure MiniLight.Light.MiniLight module MiniLight.Component type HookMap = HashMap Text (Text, Object -> Value) class HasComponentEnv c_aP6G componentEnv :: HasComponentEnv c_aP6G => Lens' c_aP6G ComponentEnv _callbacks :: HasComponentEnv c_aP6G => Lens' c_aP6G (Maybe HookMap) _uid :: HasComponentEnv c_aP6G => Lens' c_aP6G Text -- | Environmental information, which are passed for each component data ComponentEnv ComponentEnv :: Text -> Maybe HookMap -> ComponentEnv -- | The unique id [uid] :: ComponentEnv -> Text -- | The hooks [callbacks] :: ComponentEnv -> Maybe HookMap -- | Emit a signal, which will be catched at the next frame. emit :: (HasLoopEnv env, HasComponentEnv env, MonadIO m, EventType et) => Maybe Text -> et -> LightT env m () -- | Emit a signal globally. emitGlobally :: (HasLoopEnv env, HasComponentEnv env, MonadIO m, EventType et) => et -> LightT env m () -- | CompoonentUnit typeclass provides a way to define a new component. Any -- ComponentUnit instance can be embedded into Component -- type. class ComponentUnit c -- | Updating a model. update :: (ComponentUnit c, HasLightEnv env, HasLoopEnv env, HasComponentEnv env, MonadIO m, MonadMask m) => c -> LightT env m c -- | Descirbes a view. The figures here would be cached. See also -- useCache for the cache configuration. figures :: (ComponentUnit c, HasLightEnv env, MonadIO m, MonadMask m) => c -> LightT env m [Figure] -- | Drawing a figures. draw :: (ComponentUnit c, HasLightEnv env, MonadIO m, MonadMask m) => c -> LightT env m () -- | Event handlers onSignal :: (ComponentUnit c, HasLightEnv env, HasLoopEnv env, HasComponentEnv env, MonadIO m, MonadMask m) => Event -> c -> LightT env m c -- | Return True if a cache stored in the previous frame should be -- used. useCache :: ComponentUnit c => c -> c -> Bool -- | To be called just before clearing caches. If you want to destroy -- cached textures for memory efficiency, override this method. -- -- NB: Freeing SDL textures and figures are not performed -- automatically. You must call freeFigure at your own risk. beforeClearCache :: (ComponentUnit c, HasLightEnv env, MonadIO m, MonadMask m) => c -> [Figure] -> LightT env m () -- | A wrapper for ComponentUnit instances. data Component -- | Unsafe coercing the component _unsafeAs :: ComponentUnit c => Lens' Component c -- | Create a new component. newComponent :: (ComponentUnit c, HasLightEnv env, MonadIO m, MonadMask m) => Text -> c -> LightT env m Component -- | Get the size of a component. getComponentSize :: (ComponentUnit c, HasLightEnv env, MonadIO m, MonadMask m) => c -> LightT env m (Rectangle Int) -- | Get its unique id. getUID :: Component -> Text -- | Get the hooks getHooks :: Component -> Maybe HookMap -- | Get the hooks setHooks :: Component -> Maybe HookMap -> Component -- | Clear the previous model cache and reflect the current model. propagate :: Component -> Component instance MiniLight.Component.ComponentUnit MiniLight.Component.Component instance MiniLight.Component.HasComponentEnv MiniLight.Component.ComponentEnv module MiniLight.Loader.Internal.Types data Hook Hook :: Text -> Value -> Hook [signalName] :: Hook -> Text [parameter] :: Hook -> Value toHook :: Value -> Either Text Hook -- | A configuration for a component data ComponentConfig ComponentConfig :: Text -> Maybe Text -> Value -> Maybe (HashMap Text Hook) -> ComponentConfig [componentType] :: ComponentConfig -> Text [tagID] :: ComponentConfig -> Maybe Text [properties] :: ComponentConfig -> Value [hooks] :: ComponentConfig -> Maybe (HashMap Text Hook) -- | A configuration for the application itself data AppConfig AppConfig :: Vector ComponentConfig -> Vector Text -> AppConfig [app] :: AppConfig -> Vector ComponentConfig [uuid] :: AppConfig -> Vector Text -- | The type for component resolver type Resolver = Text " Component Type" -> Text " UID" -> Value " Component Property" -> MiniLight (Either String Component) -- | Generate an unique id. newUID :: MonadIO m => m Text instance GHC.Generics.Generic MiniLight.Loader.Internal.Types.Hook instance GHC.Show.Show MiniLight.Loader.Internal.Types.Hook instance Data.Aeson.Types.FromJSON.FromJSON MiniLight.Loader.Internal.Types.AppConfig instance Data.Aeson.Types.ToJSON.ToJSON MiniLight.Loader.Internal.Types.ComponentConfig instance Data.Aeson.Types.FromJSON.FromJSON MiniLight.Loader.Internal.Types.ComponentConfig instance Data.Aeson.Types.ToJSON.ToJSON MiniLight.Loader.Internal.Types.Hook instance Data.Aeson.Types.FromJSON.FromJSON MiniLight.Loader.Internal.Types.Hook module MiniLight.Loader.Internal.Resolver data Expr None :: Expr -- | reference syntax: ${ref:...} Ref :: Text -> Expr -- | variable syntax: ${var:...} Var :: Text -> Expr -- | expr operator: +, -, *, / Op :: Text -> Expr -> Expr -> Expr -- | constants (string or number or null) Constant :: Value -> Expr -- | token symbol Symbol :: Text -> Expr -- | function application ($func(a,b,c)) App :: Expr -> [Expr] -> Expr parser :: Parser Expr data Context Context :: Vector (Either Int Text) -> Object -> HashMap Text Value -> Context [path] :: Context -> Vector (Either Int Text) [variables] :: Context -> Object [values] :: Context -> HashMap Text Value emptyContext :: Context getAt :: Value -> [Either Int Text] -> Either Text Value normalize :: Vector (Either Int Text) -> [Either Int Text] -> [Either Int Text] eval :: Context -> Value -> Expr -> Either Text Value convertPath :: Text -> [Either Int Text] convert :: Context -> Value -> Text -> Either Text Value parseText :: Parser a -> Text -> Either Text a resolveWith :: Context -> Value -> Either Text Value -- | Interpret a JSON value, and unsafely apply fromRight resolve :: Value -> Value -- | Create AppConfig value from JSON value parseAppConfig :: Value -> Either Text AppConfig instance GHC.Generics.Generic MiniLight.Loader.Internal.Resolver.Expr instance GHC.Show.Show MiniLight.Loader.Internal.Resolver.Expr instance GHC.Classes.Eq MiniLight.Loader.Internal.Resolver.Expr instance Data.Aeson.Types.ToJSON.ToJSON MiniLight.Loader.Internal.Resolver.Expr instance Data.Aeson.Types.FromJSON.FromJSON MiniLight.Loader.Internal.Resolver.Expr -- | The package provides the configuration loader. -- -- An configuration example: -- --
--   _vars:
--     window:
--       width: 800
--       height: 600
--   app:
--     - name: message-layer
--       properties:
--         window:
--           image: resources/window-base.png
--           position:
--             x: 0
--             y: ${${var:window.height} - ${ref:..size.height}}
--           size:
--             width: ${var:window.width}
--             height: 150
--   
-- --

Syntax

-- --

_vars

-- -- You can define a new variable. Use object syntax under the -- _vars field. -- -- The variables can be referenced in all siblings and under their -- siblings to the _vars, in the variable syntax -- ${var:_path_}. -- --

Expr

-- -- In each field, you can specify an expression defined in the loader. -- -- module MiniLight.Loader -- | Create a component with given resolver. createComponentBy :: (HasLoaderEnv env, HasLightEnv env, MonadIO m) => Resolver -> Maybe Text -> ComponentConfig -> LightT env m (Either String Component) lookupByTagID :: (HasLightEnv env, HasLoaderEnv env, MonadIO m) => Text -> LightT env m (Maybe Text) -- | The environment for config loader data LoaderEnv LoaderEnv :: Registry Component -> IORef (HashMap Text Text) -> IORef AppConfig -> LoaderEnv [registry] :: LoaderEnv -> Registry Component [tagRegistry] :: LoaderEnv -> IORef (HashMap Text Text) [appConfig] :: LoaderEnv -> IORef AppConfig class HasLoaderEnv c_a16is loaderEnv :: HasLoaderEnv c_a16is => Lens' c_a16is LoaderEnv _appConfig :: HasLoaderEnv c_a16is => Lens' c_a16is (IORef AppConfig) _registry :: HasLoaderEnv c_a16is => Lens' c_a16is (Registry Component) _tagRegistry :: HasLoaderEnv c_a16is => Lens' c_a16is (IORef (HashMap Text Text)) -- | Load an config file and return the resolved AppConfig. resolveConfig :: MonadIO m => FilePath -> m (Either Text AppConfig) -- | Load an config file and set in the environment. Calling this function -- at once, this overrides all values in the environment. This will -- generate an error log and skip the component if the configuration is -- invalid. This function also assign unique IDs for each component, -- using assignUID. loadAppConfig :: (HasLightEnv env, HasLoaderEnv env, MonadIO m, MonadCatch m) => FilePath -> Resolver -> LightT env m () -- | Load the config file again and place the newly loaded components. This -- is used for HCR (hot component replacement). Call loadAppConfig -- first. patchAppConfig :: (HasLightEnv env, HasLoaderEnv env, MonadIO m, MonadCatch m) => FilePath -> Resolver -> LightT env m () -- | Interpret a JSON value, and unsafely apply fromRight resolve :: Value -> Value -- | Create AppConfig value from JSON value parseAppConfig :: Value -> Either Text AppConfig instance MiniLight.Loader.HasLoaderEnv MiniLight.Loader.LoaderEnv -- | MiniLight module exports all basic concepts and oprations except for -- concrete components. module MiniLight -- | Run a light monad with default configuration. runLightT = -- runLightTWith defLightConfig runLightT :: (MonadIO m, MonadMask m) => LightT LightEnv m a -> m a -- | Run a Light monad. runLightTWith :: (MonadIO m, MonadMask m) => LightConfig -> LightT LightEnv m a -> m a -- | Custom configuration for LightT data LightConfig LightConfig :: Bool -> (LogLevel -> IO LogQueue) -> LogLevel -> LightConfig [headless] :: LightConfig -> Bool -- | LogQueue for logger [logQueue] :: LightConfig -> LogLevel -> IO LogQueue -- | LogLevel for logger [logLevel] :: LightConfig -> LogLevel -- | Default configuration for runLightT defLightConfig :: LightConfig -- | The state in the mainloop. data LoopState LoopState :: LightEnv -> LoopEnv -> LoaderEnv -> LoopState [light] :: LoopState -> LightEnv [loop] :: LoopState -> LoopEnv [loader] :: LoopState -> LoaderEnv -- | Use defConfig for a default setting. data LoopConfig LoopConfig :: Maybe [Scancode] -> Maybe FilePath -> Maybe FilePath -> Resolver -> [Component] -> LoopConfig -- | Set Nothing if all keys should be watched. See also -- LoopState. [watchKeys] :: LoopConfig -> Maybe [Scancode] -- | Specify a yaml file which describes component settings. See -- Loader for the yaml syntax. [appConfigFile] :: LoopConfig -> Maybe FilePath -- | The directory path to be watched. If set, the config file modification -- will replace the component dynamically. [hotConfigReplacement] :: LoopConfig -> Maybe FilePath -- | Your custom mappings between a component name and its type. [componentResolver] :: LoopConfig -> Resolver -- | The components here would be added during the initialization. [additionalComponents] :: LoopConfig -> [Component] -- | Default configurations for the mainloop. You need to set -- componentResolver if you use a component. defConfig :: LoopConfig -- | Run a mainloop. In a mainloop, components and events are managed. -- -- Components in a mainloop: draw ~ update ~ (user-defined function) ~ -- event handling runMainloop :: (HasLightEnv env, HasLightEnv env', HasLoopEnv env', HasLoaderEnv env', MonadIO m, MonadMask m) => (env -> LoopEnv -> LoaderEnv -> env') -> LoopConfig -> s -> (s -> LightT env' m s) -> LightT env m () -- | Type synonym to the minimal type of the mainloop type MiniLoop = LightT LoopState IO -- | Same as runMainloop but fixing the type. runMiniloop :: LoopConfig -> s -> (s -> MiniLoop s) -> MiniLight () -- | Run an action over a component. runComponentEnv :: (HasLightEnv env, HasLoopEnv env) => Component -> (forall env'. (HasComponentEnv env', HasLoopEnv env', HasLightEnv env') => LightT env' m ()) -> LightT env m () -- | Emit a signal with a loader-defined target name (!) :: -- EventType et => T.Text -> et -> MiniLoop () (@@!) :: (EventType et, HasLoaderEnv env, HasLoopEnv env, HasLightEnv env, MonadIO m) => Text -> et -> LightT env m () -- | Quit the mainloop and terminate the application. quit :: (MonadIO m, HasLoopEnv env) => LightT env m () instance MiniLight.HasComponentState (MiniLight.ComponentState a) a instance MiniLight.Light.HasLightEnv env => MiniLight.Light.HasLightEnv (MiniLight.ComponentState env) instance MiniLight.Light.HasLoopEnv env => MiniLight.Light.HasLoopEnv (MiniLight.ComponentState env) instance MiniLight.Loader.HasLoaderEnv env => MiniLight.Loader.HasLoaderEnv (MiniLight.ComponentState env) instance MiniLight.Component.HasComponentEnv (MiniLight.ComponentState env) instance MiniLight.HasLoopState MiniLight.LoopState instance MiniLight.Light.HasLightEnv MiniLight.LoopState instance MiniLight.Light.HasLoopEnv MiniLight.LoopState instance MiniLight.Loader.HasLoaderEnv MiniLight.LoopState instance Data.Hashable.Class.Hashable SDL.Input.Keyboard.Codes.Scancode module Data.Config.Font data Config Config :: FontDescriptor -> Int -> V4 Word8 -> Config [descriptor] :: Config -> FontDescriptor [size] :: Config -> Int [color] :: Config -> V4 Word8 class HasConfig c_a1fQ9 config :: HasConfig c_a1fQ9 => Lens' c_a1fQ9 Config _color :: HasConfig c_a1fQ9 => Lens' c_a1fQ9 (V4 Word8) _descriptor :: HasConfig c_a1fQ9 => Lens' c_a1fQ9 FontDescriptor _size :: HasConfig c_a1fQ9 => Lens' c_a1fQ9 Int -- | Load a system font from Config type. loadFontFrom :: Config -> MiniLight Font -- | Create a text texture from the config. **NB** This function is a slow -- operation since it loads the font data every time. textFrom :: Config -> Text -> MiniLight Figure instance Data.Config.Font.HasConfig Data.Config.Font.Config instance Data.Aeson.Types.FromJSON.FromJSON Data.Config.Font.Config module Data.Component.MessageEngine -- | MessageEngine configuration. If static enabled, only -- the first page will be rendered. data Config Config :: Vector Text -> Bool -> Config -> Config -- | paged messages [messages] :: Config -> Vector Text [static] :: Config -> Bool [font] :: Config -> Config _static :: Lens' Config Bool _messages :: Lens' Config (Vector Text) _font :: Lens' Config Config data MessageEngine MessageEngine :: Font -> Int -> Int -> Int -> Figure -> Bool -> Vector Text -> Config -> MessageEngine [fontData] :: MessageEngine -> Font [counter] :: MessageEngine -> Int [page] :: MessageEngine -> Int [textCounter] :: MessageEngine -> Int [textTexture] :: MessageEngine -> Figure [finished] :: MessageEngine -> Bool [currentMessages] :: MessageEngine -> Vector Text [config] :: MessageEngine -> Config _textTexture :: Lens' MessageEngine Figure _textCounter :: Lens' MessageEngine Int _page :: Lens' MessageEngine Int _fontData :: Lens' MessageEngine Font _finished :: Lens' MessageEngine Bool _currentMessages :: Lens' MessageEngine (Vector Text) _counter :: Lens' MessageEngine Int _config :: Lens' MessageEngine Config data EngineEvent [NextPage] :: EngineEvent [SetMessage] :: [Text] -> EngineEvent new :: Config -> MiniLight MessageEngine wrapSignal :: (HasLightEnv env, HasLoopEnv env, HasComponentEnv env, MonadIO m, MonadMask m) => Lens' c MessageEngine -> (Event -> c -> LightT env m c) -> Event -> c -> LightT env m c instance MiniLight.Event.EventType Data.Component.MessageEngine.EngineEvent instance MiniLight.Component.ComponentUnit Data.Component.MessageEngine.MessageEngine instance Data.Aeson.Types.FromJSON.FromJSON Data.Component.MessageEngine.Config module Data.Component.Button data Button Button :: Font -> Config -> Button [font] :: Button -> Font [config] :: Button -> Config data ButtonEvent Click :: ButtonEvent data Config Config :: V2 Int -> Text -> V4 Word8 -> FontDescriptor -> Int -> Config [size] :: Config -> V2 Int [label] :: Config -> Text [color] :: Config -> V4 Word8 [fontConf] :: Config -> FontDescriptor [fontSize] :: Config -> Int new :: Config -> MiniLight Button instance MiniLight.Component.ComponentUnit Data.Component.Button.Button instance Data.Aeson.Types.FromJSON.FromJSON Data.Component.Button.Config instance MiniLight.Event.EventType Data.Component.Button.ButtonEvent -- | The package provides the basics for all components in the library. -- -- A component should have the followings (those can be omitted): -- -- module Data.Component.Basic -- | Basic config type data Config Config :: V2 Int -> V2 Int -> Bool -> Config [size] :: Config -> V2 Int [position] :: Config -> V2 Int [visible] :: Config -> Bool class HasConfig c_a1m7t config :: HasConfig c_a1m7t => Lens' c_a1m7t Config _position :: HasConfig c_a1m7t => Lens' c_a1m7t (V2 Int) _size :: HasConfig c_a1m7t => Lens' c_a1m7t (V2 Int) _visible :: HasConfig c_a1m7t => Lens' c_a1m7t Bool defConfig :: Config -- | This wrapper function is useful when you write your component config -- parser. wrapConfig :: (Config -> a -> Parser r) -> (Object -> Parser a) -> Value -> Parser r -- | The rectangle region of the component. areaRectangle :: Config -> Rectangle Int -- | Basic signal type. data Signal [MousePressed] :: V2 Int -> Signal [MouseReleased] :: V2 Int -> Signal [MouseOver] :: V2 Int -> Signal [SetVisibility] :: Bool -> Signal -- | This automatically applies basic configuration such as: position. wrapFigures :: Config -> [Figure] -> [Figure] -- | This wrapper function is useful when you write your own -- onSignal component. wrapSignal :: (HasLightEnv env, HasLoopEnv env, HasComponentEnv env, MonadIO m, ComponentUnit c) => Lens' c Config -> (Event -> c -> LightT env m c) -> Event -> c -> LightT env m c -- | Basic signaling function. Signals are emitted towards the source -- component. emitBasicSignal :: (HasLightEnv env, HasLoopEnv env, HasComponentEnv env, MonadIO m) => Event -> Config -> LightT env m () -- | handle basic signals handleBasicSignal :: (HasLightEnv env, HasLoopEnv env, HasComponentEnv env, MonadIO m) => Event -> Config -> LightT env m Config contains :: (Ord a, Num a) => Rectangle a -> V2 a -> Bool instance MiniLight.Event.EventType Data.Component.Basic.Signal instance Data.Component.Basic.HasConfig Data.Component.Basic.Config instance Data.Aeson.Types.FromJSON.FromJSON Data.Component.Basic.Config instance GHC.Show.Show Data.Component.Basic.Config module Data.Component.Layer data Config Config :: Config -> FilePath -> Config [basic] :: Config -> Config [image] :: Config -> FilePath data Layer Layer :: Figure -> Config -> Layer [layer] :: Layer -> Figure [config] :: Layer -> Config _image :: Lens' Config FilePath _basic :: Lens' Config Config _layer :: Lens' Layer Figure _config :: Lens' Layer Config new :: Config -> MiniLight Layer newNineTile :: Config -> MiniLight Layer instance Data.Component.Basic.HasConfig Data.Component.Layer.Config instance MiniLight.Component.ComponentUnit Data.Component.Layer.Layer instance Data.Aeson.Types.FromJSON.FromJSON Data.Component.Layer.Config module Data.Component.Selection data Config Config :: Config -> Vector Text -> Config -> FilePath -> Config [basic] :: Config -> Config [labels] :: Config -> Vector Text [fontConfig] :: Config -> Config [image] :: Config -> FilePath data Selection Selection :: Layer -> Font -> Maybe Int -> Config -> Vector Text -> Selection [layer] :: Selection -> Layer [font] :: Selection -> Font [hover] :: Selection -> Maybe Int [config] :: Selection -> Config [currentLabels] :: Selection -> Vector Text _labels :: Lens' Config (Vector Text) _image :: Lens' Config FilePath _fontConfig :: Lens' Config Config _basic :: Lens' Config Config _layer :: Lens' Selection Layer _hover :: Lens' Selection (Maybe Int) _font :: Lens' Selection Font _currentLabels :: Lens' Selection (Vector Text) _config :: Lens' Selection Config data SelectionEvent Select :: Int -> SelectionEvent SetOptions :: [Text] -> SelectionEvent new :: Config -> MiniLight Selection instance MiniLight.Component.ComponentUnit Data.Component.Selection.Selection instance MiniLight.Event.EventType Data.Component.Selection.SelectionEvent instance Data.Component.Basic.HasConfig Data.Component.Selection.Config instance Data.Aeson.Types.FromJSON.FromJSON Data.Component.Selection.Config module Data.Component.AnimationLayer data AnimationLayer AnimationLayer :: Layer -> Int -> V2 Int -> Config -> AnimationLayer [layer] :: AnimationLayer -> Layer [counter] :: AnimationLayer -> Int [tileSize] :: AnimationLayer -> V2 Int [config] :: AnimationLayer -> Config data Config Config :: Config -> V2 Int -> Int -> Config [layerConf] :: Config -> Config [division] :: Config -> V2 Int [interval] :: Config -> Int new :: Config -> MiniLight AnimationLayer instance MiniLight.Component.ComponentUnit Data.Component.AnimationLayer.AnimationLayer instance Data.Aeson.Types.FromJSON.FromJSON Data.Component.AnimationLayer.Config module Data.Component.MessageLayer data Config Config :: Config -> Config -> Config -> Config -> Config [basic] :: Config -> Config [engine] :: Config -> Config [window] :: Config -> Config [next] :: Config -> Config data MessageLayer MessageLayer :: MessageEngine -> Layer -> AnimationLayer -> Config -> MessageLayer [messageEngine] :: MessageLayer -> MessageEngine [layer] :: MessageLayer -> Layer [cursor] :: MessageLayer -> AnimationLayer [config] :: MessageLayer -> Config _window :: Lens' Config Config _next :: Lens' Config Config _engine :: Lens' Config Config _basic :: Lens' Config Config _messageEngine :: Lens' MessageLayer MessageEngine _layer :: Lens' MessageLayer Layer _cursor :: Lens' MessageLayer AnimationLayer _config :: Lens' MessageLayer Config engineL :: Lens' MessageLayer MessageEngine cursorL :: Lens' MessageLayer AnimationLayer data MessageLayerEvent [Finish] :: MessageLayerEvent new :: Config -> MiniLight MessageLayer instance MiniLight.Event.EventType Data.Component.MessageLayer.MessageLayerEvent instance MiniLight.Component.ComponentUnit Data.Component.MessageLayer.MessageLayer instance Data.Component.Basic.HasConfig Data.Component.MessageLayer.Config instance Data.Aeson.Types.FromJSON.FromJSON Data.Component.MessageLayer.Config -- | This module provides the default resolver for pre-defined components. module Data.Component.Resolver -- | Pre-defined resolver supports all components in this library. resolver :: Resolver extendResolver :: (FromJSON a, ComponentUnit c) => Text -> (a -> MiniLight c) -> Resolver -> Resolver