flaw-ui-0.1.0.0

LicenseMIT
Safe HaskellNone
LanguageHaskell2010

Flaw.UI

Description

 
Synopsis

Documentation

type Metric = Int Source #

Base type for length values.

type Position = Vec2 Metric Source #

Base type for two-dimensional position values.

type Size = Vec2 Metric Source #

Base type for two-dimensional length values.

type Rect = Vec4 Metric Source #

Base type for rectangle (left, top, right, bottom).

class Visual a where Source #

Visual is a paintable thing with layout.

Methods

renderVisual :: Context c d => a -> Drawer d -> Position -> Size -> Style -> STM (Render c ()) Source #

Render visual. Style is set by parent element, so visual may react on mouse or pressed state.

Instances
Visual Label Source # 
Instance details

Defined in Flaw.UI.Label

Methods

renderVisual :: Context c d => Label -> Drawer d -> Position -> Size -> Style -> STM (Render c ()) Source #

data SomeVisual where Source #

Any visual.

Constructors

SomeVisual :: Visual a => !a -> SomeVisual 

class Element a where Source #

Element is a content able to react to input events.

Methods

layoutElement :: a -> Size -> STM () Source #

Set size of element. If (and only if) size has changed, element should re-calculate layout and call this method for nested visuals/elements.

dabElement :: a -> Position -> STM Bool Source #

Check that point is in element. Visual can return False for "holes".

elementMouseCursor :: a -> STM MouseCursor Source #

Get mouse cursor element wants to show over.

renderElement :: Context c d => a -> Drawer d -> Position -> STM (Render c ()) Source #

Render element. Size is set by previous call to layout. It's parent element's responsibility to correctly constrain viewport.

processInputEvent :: a -> InputEvent -> InputState -> STM Bool Source #

Process input event addressed to the content. Element may return False which means it wants to return event back to container. It should be used for passing mouse events in transparent areas, and for skipping non-processed keyboard events, so container has chance to implement focus control with keys.

focusElement :: a -> STM Bool Source #

Container gives child keyboard focus. Child returns True if it accepts focus; in case of False container may try to give focus to another element.

unfocusElement :: a -> STM () Source #

Container takes keyboard focus back. Element has to release focus.

Instances
Element EditBox Source # 
Instance details

Defined in Flaw.UI.EditBox

Element CheckBox Source # 
Instance details

Defined in Flaw.UI.CheckBox

Element Button Source # 
Instance details

Defined in Flaw.UI.Button

Element Panel Source # 
Instance details

Defined in Flaw.UI.Panel

Element Frame Source # 
Instance details

Defined in Flaw.UI.Frame

Element PileBoxItem Source # 
Instance details

Defined in Flaw.UI.PileBox

Element PileBox Source # 
Instance details

Defined in Flaw.UI.PileBox

Element ScrollBar Source # 
Instance details

Defined in Flaw.UI.ScrollBox

Element ScrollBox Source # 
Instance details

Defined in Flaw.UI.ScrollBox

Element Slider Source # 
Instance details

Defined in Flaw.UI.Slider

Element VisualElement Source # 
Instance details

Defined in Flaw.UI.VisualElement

Element (ListBoxColumn v) Source # 
Instance details

Defined in Flaw.UI.ListBox

Element (ListBox v) Source # 
Instance details

Defined in Flaw.UI.ListBox

data InputEvent Source #

Input events. State of keyboard/mouse is provided before applying event.

Constructors

KeyboardInputEvent !KeyboardEvent

Keyboard event. Sent to focused control.

MouseInputEvent !MouseEvent

Mouse event. CursorMoveEvent is adjusted to element's coordinates.

MouseLeaveEvent

Mouse left the element.

data InputState Source #

Input state.

Constructors

InputState 

Fields

data SomeElement where Source #

Any element.

Constructors

SomeElement :: Element a => !a -> SomeElement 

class HasText a where Source #

Methods

setText :: a -> Text -> STM () Source #

setTextScript :: a -> FontScript -> STM () Source #

getText :: a -> STM Text Source #

Instances
HasText Label Source # 
Instance details

Defined in Flaw.UI.Label

HasText EditBox Source # 
Instance details

Defined in Flaw.UI.EditBox

HasText Frame Source # 
Instance details

Defined in Flaw.UI.Frame

class HasAlignment a where Source #

Methods

setAlignment :: a -> AlignX -> AlignY -> STM () Source #

class HasText a => HasPassword a where Source #

Methods

setPasswordMode :: a -> Bool -> STM () Source #

Instances
HasPassword EditBox Source # 
Instance details

Defined in Flaw.UI.EditBox

Methods

setPasswordMode :: EditBox -> Bool -> STM () Source #

class HasActionHandler a where Source #

Class of elements having action handler. Action means click for buttons, double click for listboxes and so on.

Methods

setActionHandler :: a -> STM () -> STM () Source #

Instances
HasActionHandler Button Source # 
Instance details

Defined in Flaw.UI.Button

Methods

setActionHandler :: Button -> STM () -> STM () Source #

class HasChangeHandler a where Source #

Methods

setChangeHandler :: a -> STM () -> STM () Source #

Instances
HasChangeHandler CheckBox Source # 
Instance details

Defined in Flaw.UI.CheckBox

Methods

setChangeHandler :: CheckBox -> STM () -> STM () Source #

HasChangeHandler Slider Source # 
Instance details

Defined in Flaw.UI.Slider

Methods

setChangeHandler :: Slider -> STM () -> STM () Source #

HasChangeHandler (ListBox v) Source # 
Instance details

Defined in Flaw.UI.ListBox

Methods

setChangeHandler :: ListBox v -> STM () -> STM () Source #

class HasChecked a where Source #

Methods

setChecked :: a -> Bool -> STM () Source #

getChecked :: a -> STM Bool Source #

Instances
HasChecked CheckBox Source # 
Instance details

Defined in Flaw.UI.CheckBox

class HasFloatValue a where Source #

Instances
HasFloatValue Slider Source # 
Instance details

Defined in Flaw.UI.Slider

class HasProgress a where Source #

Methods

setProgress :: a -> Progress -> STM () Source #

class Element a => FreeContainer a where Source #

Free container is an element able to place other elements freely with explicit positions.

Associated Types

type FreeContainerChild a :: * Source #

Handle of child element added to free container.

Methods

setLayoutHandler :: a -> (Size -> STM ()) -> STM () Source #

Set free container handler of layout method.

addFreeChild :: Element e => a -> e -> STM (FreeContainerChild a) Source #

Add child element to free container.

removeFreeChild :: a -> FreeContainerChild a -> STM () Source #

Remove child element from free container.

placeFreeChild :: a -> FreeContainerChild a -> Position -> STM () Source #

Set position of child element in free container.

placeFreeChildRelatively :: a -> FreeContainerChild a -> Int2 -> STM () Source #

Move child element relatively its current position.

bringFreeChildOnTop :: a -> FreeContainerChild a -> STM () Source #

Bring element to the end of render list (in order to render on top of everything).

focusFreeChild :: a -> FreeContainerChild a -> STM () Source #

Focus child element.

class Element a => DraggableInFreeContainer a where Source #

Class of element which could be moved by mouse.

Methods

setSelfFreeChild Source #

Arguments

:: FreeContainer fc 
=> a

Element.

-> fc

Container.

-> FreeContainerChild fc

Free child in container.

-> Bool

Resizable?

-> STM () 

Tell element a "free child" object used for placement this element. After that element becomes movable and resizable (if flag is set).

Instances
DraggableInFreeContainer Frame Source # 
Instance details

Defined in Flaw.UI.Frame

Methods

setSelfFreeChild :: FreeContainer fc => Frame -> fc -> FreeContainerChild fc -> Bool -> STM () Source #

class Element a => DefaultActionRedirector a where Source #

Methods

setDefaultElement :: Element e => a -> e -> STM () Source #

setCancelElement :: Element e => a -> e -> STM () Source #

Instances
DefaultActionRedirector Panel Source # 
Instance details

Defined in Flaw.UI.Panel

Methods

setDefaultElement :: Element e => Panel -> e -> STM () Source #

setCancelElement :: Element e => Panel -> e -> STM () Source #

class Element a => HasCommitHandler a where Source #

Class of element which has commit handler. Commit handler is a handler called when change made in elements must be commited or cancelled.

Methods

setCommitHandler :: a -> (CommitReason -> STM Bool) -> STM () Source #

Instances
HasCommitHandler Panel Source # 
Instance details

Defined in Flaw.UI.Panel

data CommitReason Source #

Reason for commit handler.

Constructors

CommitAccept

User pressed Enter key.

CommitCancel

User pressed Esc key.

CommitLostFocus

Element lost focus.

Instances
Eq CommitReason Source # 
Instance details

Defined in Flaw.UI

class Element a => Focusable a where Source #

Methods

isFocused :: a -> STM Bool Source #

class Element a => Scrollable a where Source #

Class of scrollable elements. Scrollable element can render only part of itself. It does accept call to layoutElement with size of visible area, but then it must return real size via scrollableElementSize.

Methods

renderScrollableElement Source #

Arguments

:: Context c d 
=> a

Scrollable element.

-> Drawer d

Drawer. | Position of left-top corner (possible invisible or out-of-screen because of scrolling) of the element in render coordinates.

-> Position 
-> Rect

Part of element to render, in element's coordinates.

-> STM (Render c ()) 

Render specified part of element.

scrollableElementSize :: a -> STM Size Source #

Return real total size of the element.

data SomeScrollable where Source #

Constructors

SomeScrollable :: Scrollable a => !a -> SomeScrollable