Copyright | (c) 2018 Francisco Vallarino |
---|---|
License | BSD-3-Clause (see the LICENSE file) |
Maintainer | fjvallarino@gmail.com |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
Helper functions for widget lifecycle.
Synopsis
- defaultWidgetNode :: WidgetType -> Widget s e -> WidgetNode s e
- isWidgetVisible :: WidgetEnv s e -> WidgetNode s e -> Bool
- nodeVisibleChanged :: WidgetNode s e -> WidgetNode s e -> Bool
- nodeEnabledChanged :: WidgetNode s e -> WidgetNode s e -> Bool
- nodeFlagsChanged :: WidgetNode s e -> WidgetNode s e -> Bool
- childrenVisibleChanged :: WidgetNode s e -> WidgetNode s e -> Bool
- childrenEnabledChanged :: WidgetNode s e -> WidgetNode s e -> Bool
- childrenFlagsChanged :: WidgetNode s e -> WidgetNode s e -> Bool
- widgetDataGet :: s -> WidgetData s a -> a
- widgetDataSet :: WidgetData s a -> a -> [WidgetRequest s e]
- resultNode :: WidgetNode s e -> WidgetResult s e
- resultEvts :: Typeable e => WidgetNode s e -> [e] -> WidgetResult s e
- resultReqs :: WidgetNode s e -> [WidgetRequest s e] -> WidgetResult s e
- resultReqsEvts :: Typeable e => WidgetNode s e -> [WidgetRequest s e] -> [e] -> WidgetResult s e
- makeState :: WidgetModel i => i -> WidgetEnv s e -> WidgetNode s e -> Maybe WidgetState
- useState :: WidgetModel i => Maybe WidgetState -> Maybe i
- useShared :: Typeable i => Maybe WidgetShared -> Maybe i
- infoMatches :: WidgetNodeInfo -> WidgetNodeInfo -> Bool
- nodeMatches :: WidgetNode s e -> WidgetNode s e -> Bool
- handleWidgetIdChange :: WidgetNode s e -> WidgetResult s e -> WidgetResult s e
- findWidgetIdFromPath :: WidgetEnv s e -> Path -> Maybe WidgetId
- delayedMessage :: Typeable i => WidgetNode s e -> i -> Int -> WidgetRequest s e
- delayedMessage_ :: Typeable i => WidgetId -> Path -> i -> Int -> WidgetRequest s e
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.
:: 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.