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

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

Documentation

data Config Source #

Basic config type

Constructors

Config 

Fields

Instances

Instances details
Show Config Source # 
Instance details

Defined in Data.Component.Basic

FromJSON Config Source # 
Instance details

Defined in Data.Component.Basic

HasConfig Config Source # 
Instance details

Defined in Data.Component.Basic

wrapConfig :: (Config -> a -> Parser r) -> (Object -> Parser a) -> Value -> Parser r Source #

This wrapper function is useful when you write your component config parser.

areaRectangle :: Config -> Rectangle Int Source #

The rectangle region of the component.

data Signal where Source #

Basic signal type.

Constructors

MousePressed 

Fields

  • :: V2 Int

    The relative position of the mouse pointer

  • -> Signal
     
MouseReleased 

Fields

  • :: V2 Int

    The relative position of the mouse pointer

  • -> Signal
     
MouseOver 

Fields

  • :: V2 Int

    The relative position of the mouse pointer

  • -> Signal
     
SetVisibility :: Bool -> Signal 

Instances

Instances details
EventType Signal Source # 
Instance details

Defined in Data.Component.Basic

wrapFigures :: Config -> [Figure] -> [Figure] Source #

This automatically applies basic configuration such as: position.

wrapSignal Source #

Arguments

:: (HasLightEnv env, HasLoopEnv env, HasComponentEnv env, MonadIO m, ComponentUnit c) 
=> Lens' c Config

lens to Config

-> (Event -> c -> LightT env m c)

custom onSignal function

-> 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

contains :: (Ord a, Num a) => Rectangle a -> V2 a -> Bool Source #