Copyright | (c) 2018 Francisco Vallarino |
---|---|
License | BSD-3-Clause (see the LICENSE file) |
Maintainer | fjvallarino@gmail.com |
Stability | experimental |
Portability | non-portable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Monomer.Widgets.Containers.Box
Contents
Description
Container for a single item, providing functionalities that may not be available in other widgets.
Useful in different layout situations, since it provides alignment options. This allows for the inner widget to keep its size while being positioned more explicitly, while the box takes up the complete space assigned by its parent (in particular for containers which do not follow SizeReq restrictions, such as Grid).
box_ [alignRight, alignBottom] $ image "assets/test-image.jpg" `styleBasic` [width 100, height 100]
Can be used to add padding to an inner widget with a border. This is equivalent to the margin property in CSS.
-- Padding is inside the border content = label "Message" `styleBasic` [padding 5, border 1 black] -- Padding in the wrapper box acts as margin container = box content `styleBasic` [padding 5]
Also useful to handle click events in complex widget structures (for example, a label with an image at its side).
content = vstack [ label "All the content widget is clickable", spacer, image "assets/test-image.jpg" ] clickableItem = box_ [onClick ItemClicked] content `styleBasic' [cursorHand]
Synopsis
- data BoxCfg s e
- expandContent :: BoxCfg s e
- boxFilterEvent :: ContainerFilterHandler s e -> BoxCfg s e
- box :: (WidgetModel s, WidgetEvent e) => WidgetNode s e -> WidgetNode s e
- box_ :: (WidgetModel s, WidgetEvent e) => [BoxCfg s e] -> WidgetNode s e -> WidgetNode s e
Configuration
Configuration options for box:
mergeRequired
: function called during merge that receives the old and new model, returning True in case the child widget needs to be merged. Since by default merge is required, this function can be used to restrict merging when it would be expensive and it is not necessary. For example, a list of widgets representing search result only needs to be updated when the list of results changes, not while the user inputs new search criteria (which also triggers a model change and, hence, the merge process).ignoreEmptyArea
: when the inner widget does not use all the available space, ignoring the unassigned space allows for mouse events to pass through. This is useful in zstack layers.sizeReqUpdater
: allows modifying theSizeReq
generated by the inner widget.alignLeft
: aligns the inner widget to the left.alignCenter
: aligns the inner widget to the horizontal center.alignRight
: aligns the inner widget to the right.alignTop
: aligns the inner widget to the top.alignMiddle
: aligns the inner widget to the vertical middle.alignBottom
: aligns the inner widget to the bottom.onFocus
: event to raise when focus is received.onFocusReq
:WidgetRequest
to generate when focus is received.onBlur
: event to raise when focus is lost.onBlurReq
:WidgetRequest
to generate when focus is lost.onEnter
: on mouse enter event.onEnterReq
: generates a WidgetRequest on mouse enter.onLeave
: on mouse leave event.onLeaveReq
: generates a WidgetRequest on mouse leave.onClick
: click event.onClickReq
: generates a WidgetRequest on click.onClickEmpty
: click event on empty area.onClickEmptyReq
: generates a WidgetRequest on click in empty area.onBtnPressed
: on button pressed event.onBtnPressedReq
: generates a WidgetRequest when button is pressed.onBtnReleased
: on button released event.onBtnReleasedReq
: generates a WidgetRequest when button is released.expandContent
: if the inner widget should use all the available space. To be able to use alignment options, this must be False (the default).boxFilterEvent
: allows filtering or modifying aSystemEvent
.
Instances
expandContent :: BoxCfg s e Source #
Assigns all the available space to its contained child.
boxFilterEvent :: ContainerFilterHandler s e -> BoxCfg s e Source #
Receives a System event and, optionally, modifies the event, its target, or stops the event propagation by returning Nothing.
Constructors
Arguments
:: (WidgetModel s, WidgetEvent e) | |
=> WidgetNode s e | The child node. |
-> WidgetNode s e | The created box container. |
Creates a box widget with a single node as child.
Arguments
:: (WidgetModel s, WidgetEvent e) | |
=> [BoxCfg s e] | The config options. |
-> WidgetNode s e | The child node. |
-> WidgetNode s e | The created box container. |
Creates a box widget with a single node as child. Accepts config.