| Safe Haskell | None | 
|---|---|
| Language | Haskell2010 | 
Data.Component.Basic
Description
The package provides the basics for all components in the library.
A component should have the followings (those can be omitted):
- position: 
{x: int, y: int} - size: 
{width: int, height: int} - color: 
int[4] - font: 
{family: string, bold: bool, italic: bool, size: int} 
Synopsis
- data Config = Config {}
 - class HasConfig c where
 - defConfig :: Config
 - wrapConfig :: (Config -> a -> Parser r) -> (Object -> Parser a) -> Value -> Parser r
 - areaRectangle :: Config -> Rectangle Int
 - data Signal where
- MousePressed :: V2 Int -> Signal
 - MouseReleased :: V2 Int -> Signal
 - MouseOver :: V2 Int -> Signal
 - SetVisibility :: Bool -> Signal
 
 - wrapFigures :: Config -> [Figure] -> [Figure]
 - 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
 - emitBasicSignal :: (HasLightEnv env, HasLoopEnv env, HasComponentEnv env, MonadIO m) => Event -> Config -> LightT env m ()
 - 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
 
Documentation
class HasConfig c where Source #
Minimal complete definition
Methods
config :: Lens' c Config Source #
_position :: Lens' c (V2 Int) Source #
wrapConfig :: (Config -> a -> Parser r) -> (Object -> Parser a) -> Value -> Parser r Source #
This wrapper function is useful when you write your component config parser.
Basic signal type.
Constructors
| MousePressed | |
| MouseReleased | |
| MouseOver | |
| SetVisibility :: Bool -> Signal | |
Instances
| EventType Signal Source # | |
Defined in Data.Component.Basic  | |
wrapFigures :: Config -> [Figure] -> [Figure] Source #
This automatically applies basic configuration such as: position.
Arguments
| :: (HasLightEnv env, HasLoopEnv env, HasComponentEnv env, MonadIO m, ComponentUnit c) | |
| => Lens' c Config | lens to   | 
| -> (Event -> c -> LightT env m c) | custom   | 
| -> Event -> c -> LightT env m c | 
This wrapper function is useful when you write your own onSignal component.
emitBasicSignal :: (HasLightEnv env, HasLoopEnv env, HasComponentEnv env, MonadIO m) => Event -> Config -> LightT env m () Source #
Basic signaling function. Signals are emitted towards the source component.
handleBasicSignal :: (HasLightEnv env, HasLoopEnv env, HasComponentEnv env, MonadIO m) => Event -> Config -> LightT env m Config Source #
handle basic signals