mirror of
https://github.com/rivo/tview.git
synced 2026-04-26 13:25:51 +03:00
[GH-ISSUE #23] Feature Request: GridView #17
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/tview#17
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @maja42 on GitHub (Jan 13, 2018).
Original GitHub issue: https://github.com/rivo/tview/issues/23
I have a use case where a "GridView" would be perfect. It is very similar to Flex, but handles the positioning of new items automatically based on an initial configuration.
Usage:
If add a lot of elements and they don't have enough vertical space (say, the GridView is 100 characters tall, the individual items are 20 characters tall, and I insert so many elements, that more than 5 rows are needed), the GridView should propably overflow, and there should be the possibility to scroll within the gridview to see all added items.
Also, items can be removed vom the GridView, in which case all items inserted afterwards will move one spot to the front, to avoid gaps.
(Btw, I just switched from gocui to tview, and it's great. Especially how well and fast you handle issues. Good work!)
@rivo commented on GitHub (Jan 13, 2018):
Thanks for your comment (and I'm glad you like it!). I try to handle issues quickly but a request like this is obviously not a small one.
I will look into this and keep you posted. But for now, it'll get the "on roadmap" label.
@maja42 commented on GitHub (Jan 16, 2018):
Thinking about it again, the API might be more useful (and responsive!) if you define a minimum and maxmium width for columns, and the GridView automatically wraps items if needed.
So if the terminal is very slim, all grid items are placed below each other. If it's wide, multiple items are placed within a single row.
Another feature that might become interesting once this is working: different min/max-widths for individual items. So you can have, eg. a few items with a width of 20 characters, and another one with 40 characters, which should be twice as big.
@rivo commented on GitHub (Jan 16, 2018):
It's a good idea to make it responsive. I'll keep this in mind. And yes, I plan on adding the possibility to span items over multiple columns. I still want to look at existing implementations (e.g. Bootstrap or the new CSS grid layout) before I start working on this.
Note that there won't be min/max widths, though. Sizes in
tvieware always set top-down so a parent element doesn't know how much space its child element is actually using. Instead, it tells the child element how much space it has. (Implementing flexible sizes would add a lot more complexity anyway. Browsers do that and their layout engines are not trivial.)@verdverm commented on GitHub (Jan 23, 2018):
There are some terminal grid examples out there:
The calculations they are using will likely be helpful to whom every takes on this task.
On a side note, the second one has an event system I have merged with this project. (See https://github.com/verdverm/vermui)
I've been using it to power the mouse and a gorilla/mux like routing system.
@rivo commented on GitHub (Feb 20, 2018):
A
Gridprimitive is now available so this issue is closed now. Please see the Godoc documentation and the Wiki for details.This implementation takes cues from the CSS grid layout. First, you define row and column sizes, then you add primitives to the grid which may span one or more rows/columns. It is also responsive in that you can place your primitives differently according to the available space.
You can specify gaps between rows and columns. Or you can cause borders to be drawn around primitives. This allows you to save screen space as the borders of neighbouring primitives will be combined (see also #57).
Grids can also be navigated, similarly to the
Tableclass.