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.Widgets.Containers.Stack

Description

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

Configuration

data StackCfg Source #

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 the SizeReq generated by the 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

assignStackAreas Source #

Arguments

:: 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.