Describing widget placement and alignment.

Jakub Sobon 2019-03-02 22:24:58 -05:00
parent f500d5b24e
commit 2d3808b1c4
No known key found for this signature in database
GPG Key ID: F2451A77FB05D3B7
1 changed files with 33 additions and 1 deletions

@ -89,6 +89,38 @@ The **container.SplitPercent** option is used to specify at what percentage to p
The default value of the split is defined as a [package constant](https://godoc.org/github.com/mum4k/termdash/container#pkg-constants).
## Placing widgets
Apart from establishing the terminal layout, containers are meant to hold
widgets. Each container can hold exactly one widget. Containers that have
widgets cannot have sub-containers.
Container is responsible for allocating virtual canvas for the widget that is
in accordance to the options the widget provided.
See the [[Widget API|widget-api]] for more details on widget options. If the
widget specifies maximum canvas size or ratio, there might be an empty space
left inside the container and around the widget. If that happens, the widget
alignment options can help to visually align widgets inside a container.
Widgets that don't specify these options automatically stretch to the full size
of the container unless the container has padding specified.
### [container.PlaceWidget](https://godoc.org/github.com/mum4k/termdash/container#PlaceWidget)
The **container.PlaceWidget** option places the provided widget into the container.
### Widget alignment options
The following options can be used to align a widget within the container both
horizontally and vertically.
#### [container.AlignHorizontal](https://godoc.org/github.com/mum4k/termdash/container#AlignHorizontal)
The **container.AlignHorizontal** option is used to specify horizontal alignment for the widget. Refer to the [[Align API|align-api]] for alignment options.
#### [container.AlignHorizontal](https://godoc.org/github.com/mum4k/termdash/container#AlignHorizontal)
The **container.AlignVertical** option is used to specify vertical alignment for the widget. Refer to the [[Align API|align-api]] for alignment options.
## Style options for containers
This section describes container options that specify its style or look.
@ -127,4 +159,4 @@ The **container.BorderTitleAlignCenter** option indicates that the container tit
#### [container.BorderTitleAlignRight](https://godoc.org/github.com/mum4k/termdash/container#BorderTitleAlignRight):
The **container.BorderTitleAlignRight** option indicates that the container title should be aligned at the top right corner.
The **container.BorderTitleAlignRight** option indicates that the container title should be aligned at the top right corner.