minilight-0.3.0: A SDL2-based graphics library, batteries-included.

Safe HaskellNone
LanguageHaskell2010

MiniLight.Component.Types

Synopsis

Documentation

class HasComponentEnv env where Source #

Methods

uidL :: Lens' env Text Source #

Lens to the unique id, which is provided for each component.

Instances
HasComponentEnv (Text, env) Source # 
Instance details

Defined in MiniLight

Methods

uidL :: Lens' (Text, env) Text Source #

emit :: (HasLoopEnv env, HasComponentEnv env, MonadIO m, EventType et) => et -> LightT env m () Source #

Emit a signal, which will be catched at the next frame.

class ComponentUnit c where Source #

CompoonentUnit typeclass provides a way to define a new component. Any ComponentUnit instance can be embedded into Component type.

Minimal complete definition

figures

Methods

update :: (HasLightEnv env, HasLoopEnv env, HasComponentEnv env, MonadIO m, MonadMask m) => c -> LightT env m c Source #

Updating a model.

figures :: (HasLightEnv env, MonadIO m, MonadMask m) => c -> LightT env m [Figure] Source #

Descirbes a view. The figures here would be cached. See also useCache for the cache configuration.

draw :: (HasLightEnv env, MonadIO m, MonadMask m) => c -> LightT env m () Source #

Drawing a figures.

onSignal :: (HasLightEnv env, HasLoopEnv env, HasComponentEnv env, MonadIO m, MonadMask m) => Event -> c -> LightT env m c Source #

Event handlers

useCache Source #

Arguments

:: c

A model value in the previous frame

-> c

A model value in the current frame

-> Bool 

Return True if a cache stored in the previous frame should be used.

beforeClearCache :: (HasLightEnv env, MonadIO m, MonadMask m) => c -> [Figure] -> LightT env m () Source #

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.

Instances
ComponentUnit Component Source # 
Instance details

Defined in MiniLight.Component.Types

ComponentUnit MessageEngine Source # 
Instance details

Defined in Data.Component.MessageEngine

ComponentUnit Button Source # 
Instance details

Defined in Data.Component.Button

ComponentUnit Layer Source # 
Instance details

Defined in Data.Component.Layer

ComponentUnit Selection Source # 
Instance details

Defined in Data.Component.Selection

ComponentUnit AnimationLayer Source # 
Instance details

Defined in Data.Component.AnimationLayer

ComponentUnit MessageLayer Source # 
Instance details

Defined in Data.Component.MessageLayer

newComponent :: (ComponentUnit c, HasLightEnv env, MonadIO m, MonadMask m) => Text -> c -> LightT env m Component Source #

Create a new component.

getComponentSize :: (ComponentUnit c, HasLightEnv env, MonadIO m, MonadMask m) => c -> LightT env m (Rectangle Int) Source #

Get the size of a component.

getUID :: Component -> Text Source #

Get its unique id.

propagate :: Component -> Component Source #

Clear the previous model cache and reflect the current model.