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 |
Container that stacks its children along a main axis.
An hstack widget will assign horizontal space to its children according to their size requests. The inverse happens with vstack and vertical space, which assigns vertical space as requested and all the horizontal space available.
For example, a label will get enough space to be displayed completely, and it will also get all the vertical space the hstack has. This means that if the hstack is the top level widget in the window, the label will also be as tall as the window.
Both can be combined to create complex layouts. Considering the situation of a top-level hstack which created a large vertical label, we could wrap the hstack with a vstack to only use as much horizontal and vertical space as needed. Both stack widgets will request space from their parent, along their corresponding axis, based on the requests of their children.
The layout algorithm considers the different type of size requirements and
assigns space according to the logic defined in SizeReq
. If the requested
fixed space is larger that the viewport of the stack, the content will overflow.
vstack_ [childSpacing] [ label "Selected image", image "assets/large-image.jpg" `styleBasic` [maxHeight 400], button "Complete" CompleteAction ]
Synopsis
- data StackCfg
- hstack :: Traversable t => t (WidgetNode s e) -> WidgetNode s e
- hstack_ :: Traversable t => [StackCfg] -> t (WidgetNode s e) -> WidgetNode s e
- vstack :: Traversable t => t (WidgetNode s e) -> WidgetNode s e
- vstack_ :: Traversable t => [StackCfg] -> t (WidgetNode s e) -> WidgetNode s e
- assignStackAreas :: Bool -> Rect -> Double -> Seq (WidgetNode s e) -> (Seq Rect, Double)
Configuration
Configuration options for stack:
childSpacing
: spacing between the child widgets.ignoreEmptyArea
: when the widgets do 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 stack.
Instances
Semigroup StackCfg Source # | |
Monoid StackCfg Source # | |
Default StackCfg Source # | |
Defined in Monomer.Widgets.Containers.Stack | |
CmbChildSpacing StackCfg Source # | |
Defined in Monomer.Widgets.Containers.Stack childSpacing :: StackCfg Source # childSpacing_ :: Double -> StackCfg Source # | |
CmbSizeReqUpdater StackCfg Source # | |
Defined in Monomer.Widgets.Containers.Stack | |
CmbIgnoreEmptyArea StackCfg Source # | |
Defined in Monomer.Widgets.Containers.Stack |
Constructors
hstack :: Traversable t => t (WidgetNode s e) -> WidgetNode s e Source #
Creates a horizontal stack.
hstack_ :: Traversable t => [StackCfg] -> t (WidgetNode s e) -> WidgetNode s e Source #
Creates a horizontal stack. Accepts config.
vstack :: Traversable t => t (WidgetNode s e) -> WidgetNode s e Source #
Creates a vertical stack.
vstack_ :: Traversable t => [StackCfg] -> t (WidgetNode s e) -> WidgetNode s e Source #
Creates a vertical stack. Accepts config.
Helpers
:: Bool | True if horizontal, False for vertical. |
-> Rect | The available space to assign. |
-> Double | The spacing between adjacent children. |
-> Seq (WidgetNode s e) | The widgets that will be assigned space. |
-> (Seq Rect, Double) | The assigned areas and used space in main axis. |
Assigns space from rect to each of the provided widgets based on their size requirements.