twentefp-eventloop-graphics-0.1.0.3: Used as Lab Assignments Environment at Univeriteit Twente

Copyright(c) Sebastiaan la Fleur, 2014
LicenseBSD3
Maintainersebastiaan.la.fleur@gmail.com
Stabilityexperimental
PortabilityAll
Safe HaskellNone
LanguageHaskell98

EventLoop

Description

Complete import of all the exposed features of this library. The Eventloop package is used to express the communication between a Haskell server and a program modelling an 'IO Device'. This package contains an example implementation of how such a server would like when a browser is used as a graphical IO device also containing a mouse and keyboard. The InputEvent models the possible mouse and keyboard events. The OutputEvent models the possible graphical output events. There are also input and output systemmessages to communicate metadata between the Haskell server and the graphical IO browser. The starting point for this example implementation is start.

Synopsis

Documentation

start Source

Arguments

:: (a -> InputEvent -> ([OutputEvent], a))

Eventhandler from InputEvent to a list of OutputEvent. Also takes a variable of type a that holds the current state of information. Returns a changed variable of type a that will be called with next handler call.

-> a

The begin state of variable a.

-> IO () 

High-level function to start an eventloop. The eventloop takes an InputEvent and outputs an OutputEvent. Starting place for the example implementation of the eventloop. It takes a variable of type a to hold information in between handler calls.

type Pos = (Float, Float) Source

Type to express a position on the screen. It uses the format (x,y). As Canvas is used in the example implementation, remember that the lefttop corner is (0,0) and the leftbottom corner is (0, height of screen).

type Dimension = (Float, Float) Source

Type to express the dimension of an element. It uses the format (w,h).

type Element = [Char] Source

The name of a graphical element. It is used for Mouse to express the name of which element is clicked on.

data Keyboard Source

Datatype to express the different Keyboard events.

Constructors

KeyPress KeyboardButton 

type KeyboardButton = [Char] Source

Type to express how a KeyboardButton is modelled.

data Mouse Source

Datatype to express the different Mouse events. The Pos expresses where on the screen the event happened. The Element expresses on which top element on screen the event happened. The Element value is the name of the GObject.

Constructors

MouseClick MouseButton Pos Element

Expresses a complete MouseClick consisting of a MouseUp and a MouseDown.

MouseUp MouseButton Pos Element

Expresses when a MouseButton moves upward.

MouseDown MouseButton Pos Element

Expresses when a MouseButton is pushed down.

Instances

data MouseButton Source

The MouseButton on the mouse.

Constructors

MLeft 
MRight 
MMiddle 

Instances

data SystemMessageIn Source

The different possible SystemMessageIns.

Constructors

Setup

A request for the Setup. This should be generated when the connection to a client is made. The answer should be a CanvasSetup message.

Background

A request for the Background. This should be generated when the connection to a client is made. The answer could be the background of the graphical application.

Time

When a timer has been spawn, each 'tick' a Time is generated by the client to let the server know it is time.

data SystemMessageOut Source

The different possible SystemMessageOuts.

Constructors

CanvasSetup Dimension

Answer to the Setup containing the dimensions of the canvas that will be used.

Timer Bool

Request to create a timer at the clientside that will generate a Time message each 'tick'.

Close

A request for the client to completely close the connection to the server.

data Graphical Source

Graphical Responses Out

Constructors

Draw GObject Groupname

Draw the graphical object with the given groupname.

MoveGroup Groupname Pos Relative

Move an entire group to a new position possibly relative to the old position.

MoveElement Name Pos Relative

Move a single element to a new position possibly relative to the old position.

RemoveGroup Groupname

Remove a group

RemoveElement Name

Remove an element.

data GObject Source

A general graphical object containing the common attributes of each Primitive.

Constructors

GObject

Graphical Object

Fields

name :: Name

Name of the graphical object/element

prim :: Primitive

The graphical primitive that should be drawn

children :: [GObject]

Children of the graphical primitive. Can be used to create composited graphical components containing multiple GObjects.

Container

A container for Graphical Objects

Fields

children :: [GObject]

Children of the graphical primitive. Can be used to create composited graphical components containing multiple GObjects.

Instances

data Primitive Source

Primitive graphical structures

Constructors

Text

The text graphical primitive

Fields

edgeColor :: Color

Color of the edges of the text

edgeThickness :: Float

The edge thickness of the text (Should be 1 most of the time)

color :: Color

The Color of the fill of the text

position :: Pos

The position on the screen of the text

size :: Float

The height of the text in pixels

font :: Font

Which font to be used

text :: [Char]

The actual text to be displayed

fromCenter :: Bool

Is the position the topleft corner of the text or the center of the text

Line

The line graphical primitive

Fields

edgeColor :: Color

Color of the edges of the text

edgeThickness :: Float

The edge thickness of the text (Should be 1 most of the time)

positions :: [Pos]

The list of positions the line should go through. A line will be drawn from point 1 to point 2 to point...

Rect

The rectangle graphical primitive

Fields

edgeColor :: Color

Color of the edges of the text

edgeThickness :: Float

The edge thickness of the text (Should be 1 most of the time)

color :: Color

The Color of the fill of the text

position :: Pos

The position on the screen of the text

dimensions :: Dimension

The dimensions of the rectangle

Arc

The arc graphical primitive. This is the part of a circle. When startAng=0 and endAng=360 you get a full circle.

Fields

edgeColor :: Color

Color of the edges of the text

edgeThickness :: Float

The edge thickness of the text (Should be 1 most of the time)

color :: Color

The Color of the fill of the text

position :: Pos

The position on the screen of the text

radius :: Float

The radius of the arc

startAng :: Float

The starting angle of the arc in degrees.

endAng :: Float

The ending angle of the arc in degrees.

type Name = [Char] Source

The name of a graphical object. Another synonym in the package used for this is Element.

type Groupname = [Char] Source

The groupname of a set of graphical objects.

type Color = (Float, Float, Float) Source

The color expressed in (red, green, blue) code where each value is between 0 <= 255.

type Font = [Char] Source

The font associated with a Text primitive.

type Relative = Bool Source

A boolean expressing if an event should be carried out relative to the old situation or to the absolute situation Example of this is when moving an element. Should the move be relative to the old Pos or to the absolute Pos on the screen.

outSingle :: OutputEvent -> IO () Source

Outputs a single OutputEvent. Right now only Draw events are implemented. The server automatically determines the maximum Dimensions of the picture and sends a Setup containing those Dimensions.