Created Dynamic layout (markdown)

Jakub Sobon 2019-03-30 02:10:15 -04:00
parent d6761fa9d2
commit d1adb3cfc1
1 changed files with 29 additions and 0 deletions

29
Dynamic-layout.md Normal file

@ -0,0 +1,29 @@
[![Doc Status](https://godoc.org/github.com/mum4k/termdash/container?status.png)](https://godoc.org/github.com/mum4k/termdash/container)
This page explains how to change the layout of the terminal dynamically at runtime. This can be done by updating the options at a specific container. The developer creates options that represent the new desired layout using one of the two available methods, i.e. the [[Binary tree layout|binary-tree-layout]] or the [[Grid layout|grid-layout]].
Dynamic layout changes are demonstrated in the [termdashdemo](https://github.com/mum4k/termdash/blob/master/termdashdemo/termdashdemo.go), run it using the following command:
```go
go run github.com/mum4k/termdash/termdashdemo/termdashdemo.go
```
## Identifying containers
In order to update a container, the developer must provide its identifier. By default the created containers have no identifiers assigned and thus cannot be updated. Use the **container.ID** option to create a container with a custom identifier. This identifier is later used when updating the container.
### [container.ID](https://godoc.org/github.com/mum4k/termdash/container#ID):
The **container.ID** option sets the identifier on a container. This can be later used to update the container's options.
## Changing the layout
Use the **Container.Update** method to specify new options for a container.
### [Container.Update](https://godoc.org/github.com/mum4k/termdash/container#Container.Update):
The **Container.Update** method applies the specified options to a container with the provided ID. This can be used to perform simple changes like adding a border or layout changes. When changing the layout, the developer can replace the widget with another one or define new splits for the container that effectively establish new layout on the screen.
### Replacing widget in a container
### Changing the layout by specifying new splits