rivo / tview

Terminal UI library with rich, interactive widgets — written in Golang
MIT License
11.17k stars 574 forks source link

Flex vs Grid #890

Closed paololazzari closed 1 year ago

paololazzari commented 1 year ago

It seems like the Flex and Grid primitives offer similar functionality. When should I use one over the other?

digitallyserviced commented 1 year ago

@paololazzari

They do not offer similar functions ultimately.

Flex's auto layout in one direction with each item added.

Flex `SetDirection(FlexRow)`
===============
|   item 1    |
|   item 2    |
|   item 3    |
===============

Flex `SetDirection(FlexColumn)`
============================
| item 1 | item 2 | item 3 |
============================

Grids you MUST define how many cols/rows an item spans, what row/col it starts from, and are not auto-layout'd

Grid 
6 rows x 6 cols
============================
| item 1 | item 2 | item 3 |
============================
| item 4 3col |            |
|       item 5 6cols       |
|   item 6 4col   | item 7 |
============================
paololazzari commented 1 year ago

Thank you