monomer-1.0.0.1: A GUI library for writing native Haskell applications.
Copyright(c) 2018 Francisco Vallarino
LicenseBSD-3-Clause (see the LICENSE file)
Maintainerfjvallarino@gmail.com
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Monomer.Widgets.Util.Widget

Description

Helper functions for widget lifecycle.

Synopsis

Documentation

defaultWidgetNode :: WidgetType -> Widget s e -> WidgetNode s e Source #

Creates a basic widget node, with the given type, instance and no children.

isWidgetVisible :: WidgetEnv s e -> WidgetNode s e -> Bool Source #

Checks if the node is within the visible viewport, and itself visible.

nodeVisibleChanged :: WidgetNode s e -> WidgetNode s e -> Bool Source #

Checks if the visibility flags changed between the old and new node.

nodeEnabledChanged :: WidgetNode s e -> WidgetNode s e -> Bool Source #

Checks if the enabled flags changed between the old and new node.

nodeFlagsChanged :: WidgetNode s e -> WidgetNode s e -> Bool Source #

Checks if the enabled/visible flags changed between the old and new node.

childrenVisibleChanged :: WidgetNode s e -> WidgetNode s e -> Bool Source #

Checks if the visibility flags changed between the old and new children. A change in count will result in a True result.

childrenEnabledChanged :: WidgetNode s e -> WidgetNode s e -> Bool Source #

Checks if the enabled flags changed between the old and new children. A change in count will result in a True result.

childrenFlagsChanged :: WidgetNode s e -> WidgetNode s e -> Bool Source #

Checks if enabled/visible flags changed between the old and new children. A change in count will result in a True result.

widgetDataGet :: s -> WidgetData s a -> a Source #

Returns the current value associated to the WidgetData.

widgetDataSet :: WidgetData s a -> a -> [WidgetRequest s e] Source #

Generates a model update request with the provided value when the WidgetData is WidgetLens. For WidgetValue and onChange event should be used.

resultNode :: WidgetNode s e -> WidgetResult s e Source #

Generates a WidgetResult with only the node field filled.

resultEvts :: Typeable e => WidgetNode s e -> [e] -> WidgetResult s e Source #

Generates a WidgetResult with the node field and events filled.

resultReqs :: WidgetNode s e -> [WidgetRequest s e] -> WidgetResult s e Source #

Generates a WidgetResult with the node field and reqs filled.

resultReqsEvts Source #

Arguments

:: Typeable e 
=> WidgetNode s e

The new version of the node.

-> [WidgetRequest s e]

The widget requests.

-> [e]

The user events.

-> WidgetResult s e

The result.

Generates a WidgetResult with the node, events and reqs fields filled. These related helpers exist because list has nicer literal syntax than Seq.

The events are appended after the requests. If a specific order of events and requests is needed, add the events to reqs using RaiseEvent.

makeState :: WidgetModel i => i -> WidgetEnv s e -> WidgetNode s e -> Maybe WidgetState Source #

Wraps a value in WidgetState, ignoring wenv and node. Useful when creating Widget instances if the state is available beforehand.

useState :: WidgetModel i => Maybe WidgetState -> Maybe i Source #

Casts the wrapped value in WidgetState to the expected type, if possible.

useShared :: Typeable i => Maybe WidgetShared -> Maybe i Source #

Casts the wrapped value in WidgetShared to the expected type, if possible.

infoMatches :: WidgetNodeInfo -> WidgetNodeInfo -> Bool Source #

Checks if the type and key of two WidgetNodeInfo match.

nodeMatches :: WidgetNode s e -> WidgetNode s e -> Bool Source #

Checks if the type and key of two WidgetNodes match.

handleWidgetIdChange :: WidgetNode s e -> WidgetResult s e -> WidgetResult s e Source #

Checks if the path the node in the provided result changed compared to the old node. In case it did, it appends a SetWidgetPath request to keep track of the new location.

findWidgetIdFromPath :: WidgetEnv s e -> Path -> Maybe WidgetId Source #

Returns the WidgetId associated to the given path, if any.

delayedMessage :: Typeable i => WidgetNode s e -> i -> Int -> WidgetRequest s e Source #

Sends a message to the given node with a delay of n ms.

delayedMessage_ :: Typeable i => WidgetId -> Path -> i -> Int -> WidgetRequest s e Source #

Sends a message to the given WidgetId with a delay of n ms.