monomer-1.4.0.0: 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.Core.Util

Description

Helper functions for Core types.

Synopsis

Documentation

pathFromKey :: WidgetEnv s e -> WidgetKey -> Maybe Path Source #

Returns the Path associated to a given WidgetKey, if any. The search is restricted to the parent Monomer.Widgets.Composite.

widgetIdFromKey :: WidgetEnv s e -> WidgetKey -> Maybe WidgetId Source #

Returns the WidgetId associated to a given WidgetKey, if any. The search is restricted to the parent Monomer.Widgets.Composite.

nodeInfoFromKey :: WidgetEnv s e -> WidgetKey -> Maybe WidgetNodeInfo Source #

Returns the WidgetNodeInfo associated to the given WidgetKey, if any. The search is restricted to the parent Monomer.Widgets.Composite.

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

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

nodeInfoFromPath :: WidgetEnv s e -> Path -> Maybe WidgetNodeInfo Source #

Returns the WidgetNodeInfo associated to the given Path, if any.

findChildNodeInfoByPath :: WidgetEnv s e -> WidgetNode s e -> Path -> Maybe WidgetNodeInfo Source #

Returns the WidgetNodeInfo associated to a given Path. The path will be searched for starting from the provided WidgetNode.

findChildBranchByPath :: WidgetEnv s e -> WidgetNode s e -> Path -> Seq WidgetNodeInfo Source #

Returns the WidgetNodeInfo branch associated to a given Path. The path will be searched for starting from the provided WidgetNode.

findParentNodeInfoByType :: WidgetEnv s e -> Path -> WidgetType -> Maybe WidgetNodeInfo Source #

Returns the first parent WidgetNodeInfo of the Path that matches the given WidgetType.

getLayoutDirection :: Bool -> LayoutDirection Source #

Helper functions that associates False to Vertical and True to Horizontal.

eventsFromReqs :: Seq (WidgetRequest s e) -> Seq e Source #

Filters user events from a list of WidgetRequests.

isIgnoreParentEvents :: WidgetRequest s e -> Bool Source #

Ignore events generated by the parent. Could be used to consume the tab key and avoid having the focus move to the next widget.

isIgnoreChildrenEvents :: WidgetRequest s e -> Bool Source #

Ignore children events. Scroll relies on this to handle click/wheel.

isResizeWidgets :: WidgetRequest s e -> Bool Source #

The widget content changed and requires a different size. Processed at the end of the cycle, since several widgets may request it.

isResizeWidgetsImmediate :: WidgetRequest s e -> Bool Source #

The widget content changed and requires a different size. Processed immediately. Avoid if possible, since it can affect performance.

isMoveFocus :: WidgetRequest s e -> Bool Source #

Moves the focus, optionally indicating a starting widgetId.

isSetFocus :: WidgetRequest s e -> Bool Source #

Sets the focus to the given widgetId.

isGetClipboard :: WidgetRequest s e -> Bool Source #

Requests the clipboard contents. It will be received as a SystemEvent.

isSetClipboard :: WidgetRequest s e -> Bool Source #

Sets the clipboard to the given ClipboardData.

isStartTextInput :: WidgetRequest s e -> Bool Source #

Sets the viewport which should be remain visible when an on-screen keyboard is displayed. Required for mobile.

isStopTextInput :: WidgetRequest s e -> Bool Source #

Resets the keyboard viewport,

isSetOverlay :: WidgetRequest s e -> Bool Source #

Sets a widget as the base target of future events. This is used by the dropdown component to handle list events (which is on top of everything).

isResetOverlay :: WidgetRequest s e -> Bool Source #

Removes the existing overlay.

isSetCursorIcon :: WidgetRequest s e -> Bool Source #

Sets the current active cursor icon. This acts as a stack, so removing means going back a step to the cursor set by a parent widget.

isResetCursorIcon :: WidgetRequest s e -> Bool Source #

Removes a cursor icon setting from the stack.

isStartDrag :: WidgetRequest s e -> Bool Source #

Sets the current item being dragged and the message it carries. This message is used by targets to check if they accept it or not.

isStopDrag :: WidgetRequest s e -> Bool Source #

Cancels the current dragging process.

isRenderOnce :: WidgetRequest s e -> Bool Source #

Requests rendering a single frame. Rendering is not done at a fixed rate, in order to reduce CPU usage. Widgets are responsible of requesting rendering at points of interest. Mouse and keyboard events automatically generate render requests, but the result of a WidgetTask does not.

isRenderEvery :: WidgetRequest s e -> Bool Source #

Useful if a widget requires periodic rendering. An optional maximum number of frames can be provided.

isRenderStop :: WidgetRequest s e -> Bool Source #

Stops a previous periodic rendering request.

isRemoveRendererImage :: WidgetRequest s e -> Bool Source #

Requests to have an image removed from the renderer.

isExitApplication :: WidgetRequest s e -> Bool Source #

Requests to exit the application. Can also be used to cancel a previous request (or a window close).

isUpdateModel :: WidgetRequest s e -> Bool Source #

Request a model update. This usually involves lenses and "widgetDataSet".

isSetWidgetPath :: WidgetRequest s e -> Bool Source #

Updates the path of a given widget. Both Monomer.Widgets.Single and Monomer.Widgets.Container handle this automatically.

isResetWidgetPath :: WidgetRequest s e -> Bool Source #

Clears an association between widgetId and path.

isRaiseEvent :: WidgetRequest s e -> Bool Source #

Raises a user event, which usually will be processed in handleEvent in a Monomer.Widgets.Composite instance.

isSendMessage :: WidgetRequest s e -> Bool Source #

Sends a message to the given widgetId. If the target does not expect the message's type, it will be ignored.

isRunTask :: WidgetRequest s e -> Bool Source #

Runs an asynchronous tasks. It is mandatory to return a message that will be sent to the task owner (this is the only way to feed data back).

isRunProducer :: WidgetRequest s e -> Bool Source #

Similar to RunTask, but can generate unlimited messages. This is useful for WebSockets and similar data sources. It receives a function that with which to send messagess to the producer owner.

isFocusRequest :: WidgetRequest s e -> Bool Source #

Checks if the request is either MoveFocus or SetFocus.

isResizeResult :: Maybe (WidgetResult s e) -> Bool Source #

Checks if the result contains a Resize request.

isResizeImmediateResult :: Maybe (WidgetResult s e) -> Bool Source #

Checks if the result contains a ResizeImmediate request.

isResizeAnyResult :: Maybe (WidgetResult s e) -> Bool Source #

Checks if the result contains any kind of resize request.

isMacOS :: WidgetEnv s e -> Bool Source #

Checks if the platform is macOS

currentTimeMs :: Integral a => WidgetEnv s e -> a Source #

Returns the current time in milliseconds. Adds appStartTs and timestamp fields from WidgetEnv and converts the result to the expected Integral type.

widgetTreeDesc :: Int -> WidgetNode s e -> String Source #

Returns a string description of a node and its children.

nodeDesc :: Int -> WidgetNode s e -> String Source #

Returns a string description of a node.

widgetInstTreeDesc :: Int -> WidgetInstanceNode -> String Source #

Returns a string description of a node info and its children.

nodeInstDesc :: Int -> WidgetInstanceNode -> String Source #

Returns a string description of a node info.

treeInstDescFromNode :: WidgetEnv s e -> Int -> WidgetNode s e -> String Source #

Returns a string description of a node info and its children, from a node.