minilight-0.5.0: A SDL2-based graphics library, batteries-included.
Safe HaskellNone
LanguageHaskell2010

MiniLight.Component

Synopsis

Documentation

data ComponentEnv Source #

Environmental information, which are passed for each component

Constructors

ComponentEnv 

Fields

emit Source #

Arguments

:: (HasLoopEnv env, HasComponentEnv env, MonadIO m, EventType et) 
=> Maybe Text

target component ID

-> et 
-> LightT env m () 

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

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

Emit a signal globally.

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

Instances details
ComponentUnit Component Source # 
Instance details

Defined in MiniLight.Component

Methods

update :: forall env (m :: Type -> Type). (HasLightEnv env, HasLoopEnv env, HasComponentEnv env, MonadIO m, MonadMask m) => Component -> LightT env m Component Source #

figures :: forall env (m :: Type -> Type). (HasLightEnv env, MonadIO m, MonadMask m) => Component -> LightT env m [Figure] Source #

draw :: forall env (m :: Type -> Type). (HasLightEnv env, MonadIO m, MonadMask m) => Component -> LightT env m () Source #

onSignal :: forall env (m :: Type -> Type). (HasLightEnv env, HasLoopEnv env, HasComponentEnv env, MonadIO m, MonadMask m) => Event -> Component -> LightT env m Component Source #

useCache :: Component -> Component -> Bool Source #

beforeClearCache :: forall env (m :: Type -> Type). (HasLightEnv env, MonadIO m, MonadMask m) => Component -> [Figure] -> LightT env m () Source #

ComponentUnit MessageEngine Source # 
Instance details

Defined in Data.Component.MessageEngine

Methods

update :: forall env (m :: Type -> Type). (HasLightEnv env, HasLoopEnv env, HasComponentEnv env, MonadIO m, MonadMask m) => MessageEngine -> LightT env m MessageEngine Source #

figures :: forall env (m :: Type -> Type). (HasLightEnv env, MonadIO m, MonadMask m) => MessageEngine -> LightT env m [Figure] Source #

draw :: forall env (m :: Type -> Type). (HasLightEnv env, MonadIO m, MonadMask m) => MessageEngine -> LightT env m () Source #

onSignal :: forall env (m :: Type -> Type). (HasLightEnv env, HasLoopEnv env, HasComponentEnv env, MonadIO m, MonadMask m) => Event -> MessageEngine -> LightT env m MessageEngine Source #

useCache :: MessageEngine -> MessageEngine -> Bool Source #

beforeClearCache :: forall env (m :: Type -> Type). (HasLightEnv env, MonadIO m, MonadMask m) => MessageEngine -> [Figure] -> LightT env m () Source #

ComponentUnit Button Source # 
Instance details

Defined in Data.Component.Button

Methods

update :: forall env (m :: Type -> Type). (HasLightEnv env, HasLoopEnv env, HasComponentEnv env, MonadIO m, MonadMask m) => Button -> LightT env m Button Source #

figures :: forall env (m :: Type -> Type). (HasLightEnv env, MonadIO m, MonadMask m) => Button -> LightT env m [Figure] Source #

draw :: forall env (m :: Type -> Type). (HasLightEnv env, MonadIO m, MonadMask m) => Button -> LightT env m () Source #

onSignal :: forall env (m :: Type -> Type). (HasLightEnv env, HasLoopEnv env, HasComponentEnv env, MonadIO m, MonadMask m) => Event -> Button -> LightT env m Button Source #

useCache :: Button -> Button -> Bool Source #

beforeClearCache :: forall env (m :: Type -> Type). (HasLightEnv env, MonadIO m, MonadMask m) => Button -> [Figure] -> LightT env m () Source #

ComponentUnit Layer Source # 
Instance details

Defined in Data.Component.Layer

Methods

update :: forall env (m :: Type -> Type). (HasLightEnv env, HasLoopEnv env, HasComponentEnv env, MonadIO m, MonadMask m) => Layer -> LightT env m Layer Source #

figures :: forall env (m :: Type -> Type). (HasLightEnv env, MonadIO m, MonadMask m) => Layer -> LightT env m [Figure] Source #

draw :: forall env (m :: Type -> Type). (HasLightEnv env, MonadIO m, MonadMask m) => Layer -> LightT env m () Source #

onSignal :: forall env (m :: Type -> Type). (HasLightEnv env, HasLoopEnv env, HasComponentEnv env, MonadIO m, MonadMask m) => Event -> Layer -> LightT env m Layer Source #

useCache :: Layer -> Layer -> Bool Source #

beforeClearCache :: forall env (m :: Type -> Type). (HasLightEnv env, MonadIO m, MonadMask m) => Layer -> [Figure] -> LightT env m () Source #

ComponentUnit Selection Source # 
Instance details

Defined in Data.Component.Selection

Methods

update :: forall env (m :: Type -> Type). (HasLightEnv env, HasLoopEnv env, HasComponentEnv env, MonadIO m, MonadMask m) => Selection -> LightT env m Selection Source #

figures :: forall env (m :: Type -> Type). (HasLightEnv env, MonadIO m, MonadMask m) => Selection -> LightT env m [Figure] Source #

draw :: forall env (m :: Type -> Type). (HasLightEnv env, MonadIO m, MonadMask m) => Selection -> LightT env m () Source #

onSignal :: forall env (m :: Type -> Type). (HasLightEnv env, HasLoopEnv env, HasComponentEnv env, MonadIO m, MonadMask m) => Event -> Selection -> LightT env m Selection Source #

useCache :: Selection -> Selection -> Bool Source #

beforeClearCache :: forall env (m :: Type -> Type). (HasLightEnv env, MonadIO m, MonadMask m) => Selection -> [Figure] -> LightT env m () Source #

ComponentUnit AnimationLayer Source # 
Instance details

Defined in Data.Component.AnimationLayer

Methods

update :: forall env (m :: Type -> Type). (HasLightEnv env, HasLoopEnv env, HasComponentEnv env, MonadIO m, MonadMask m) => AnimationLayer -> LightT env m AnimationLayer Source #

figures :: forall env (m :: Type -> Type). (HasLightEnv env, MonadIO m, MonadMask m) => AnimationLayer -> LightT env m [Figure] Source #

draw :: forall env (m :: Type -> Type). (HasLightEnv env, MonadIO m, MonadMask m) => AnimationLayer -> LightT env m () Source #

onSignal :: forall env (m :: Type -> Type). (HasLightEnv env, HasLoopEnv env, HasComponentEnv env, MonadIO m, MonadMask m) => Event -> AnimationLayer -> LightT env m AnimationLayer Source #

useCache :: AnimationLayer -> AnimationLayer -> Bool Source #

beforeClearCache :: forall env (m :: Type -> Type). (HasLightEnv env, MonadIO m, MonadMask m) => AnimationLayer -> [Figure] -> LightT env m () Source #

ComponentUnit MessageLayer Source # 
Instance details

Defined in Data.Component.MessageLayer

Methods

update :: forall env (m :: Type -> Type). (HasLightEnv env, HasLoopEnv env, HasComponentEnv env, MonadIO m, MonadMask m) => MessageLayer -> LightT env m MessageLayer Source #

figures :: forall env (m :: Type -> Type). (HasLightEnv env, MonadIO m, MonadMask m) => MessageLayer -> LightT env m [Figure] Source #

draw :: forall env (m :: Type -> Type). (HasLightEnv env, MonadIO m, MonadMask m) => MessageLayer -> LightT env m () Source #

onSignal :: forall env (m :: Type -> Type). (HasLightEnv env, HasLoopEnv env, HasComponentEnv env, MonadIO m, MonadMask m) => Event -> MessageLayer -> LightT env m MessageLayer Source #

useCache :: MessageLayer -> MessageLayer -> Bool Source #

beforeClearCache :: forall env (m :: Type -> Type). (HasLightEnv env, MonadIO m, MonadMask m) => MessageLayer -> [Figure] -> LightT env m () Source #

data Component Source #

A wrapper for ComponentUnit instances.

Instances

Instances details
ComponentUnit Component Source # 
Instance details

Defined in MiniLight.Component

Methods

update :: forall env (m :: Type -> Type). (HasLightEnv env, HasLoopEnv env, HasComponentEnv env, MonadIO m, MonadMask m) => Component -> LightT env m Component Source #

figures :: forall env (m :: Type -> Type). (HasLightEnv env, MonadIO m, MonadMask m) => Component -> LightT env m [Figure] Source #

draw :: forall env (m :: Type -> Type). (HasLightEnv env, MonadIO m, MonadMask m) => Component -> LightT env m () Source #

onSignal :: forall env (m :: Type -> Type). (HasLightEnv env, HasLoopEnv env, HasComponentEnv env, MonadIO m, MonadMask m) => Event -> Component -> LightT env m Component Source #

useCache :: Component -> Component -> Bool Source #

beforeClearCache :: forall env (m :: Type -> Type). (HasLightEnv env, MonadIO m, MonadMask m) => Component -> [Figure] -> LightT env m () Source #

_unsafeAs :: ComponentUnit c => Lens' Component c Source #

Unsafe coercing the component

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.

getHooks :: Component -> Maybe HookMap Source #

Get the hooks

propagate :: Component -> Component Source #

Clear the previous model cache and reflect the current model.