mirror of
https://github.com/rivo/tview.git
synced 2026-04-26 13:25:51 +03:00
[GH-ISSUE #231] Grid questions #177
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/tview#177
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 @dguendisch on GitHub (Jan 22, 2019).
Original GitHub issue: https://github.com/rivo/tview/issues/231
I have a hard time understanding
Grid's meaning of width and height. Either the code documentation is mixing them up a lot (not likely) or I have a different understanding than tview about them (more likely).Let's take e.g. the doc of its
AddItem(p Primitive, row int, column int, height int, width int, ...)method:How can something span a width of rows?? I mean the wider an item gets, the more columns it spans.
The same for "... span ... height columns": the higher an item gets, the more rows it will span.
Later:
Ok, so we add
pat row=2 with a height=3, so it'll span row 2, 3 and 4 => I understand that one, it matches my understanding of width and height :)But we define col=4 and width=2, so it should span columns 4 and 5 instead of what's written in the documentation.
The same goes on with
SetRows(...)...But I guess I got something totally wrong with the
Grid, so any explanation is appreciated :)@rivo commented on GitHub (Jan 22, 2019):
I renamed the parameters in
AddItem()tocolSpanandrowSpan. I also fixed the example which, as you pointed out, was wrong. I believe this should clarify your questions.If you're still having trouble with this, let me know.
@dguendisch commented on GitHub (Jan 22, 2019):
The names are more clearer, thanks. As I see from
1ac6fbcthe doc was indeed wrong. E.g. in the docwidthwas replaced withrowSpan, while in the method signature,heightwas replaced withrowSpan, so the doc mixed it up.If you like to continue, see e.g.
SetRowsdoc. I understand what it does but the doc states e.g.There is in my understanding no such thing as a "leftmost row", there is either a "topmost row" or a "leftmost column". It continues then with mixing width and height in the same way as in
AddItempreviously. Really confusing for newbies like me :)@rivo commented on GitHub (Jan 24, 2019):
Thanks for catching this one, too. I think I must have switched
SetColumns()withSetRows()at some point without fully adapting the comments. My latest commit should fix those comments.Let me know if you find anything else.
@dguendisch commented on GitHub (Jan 24, 2019):
Thanks a lot, now everything makes sense :)
@xhsky commented on GitHub (Jun 24, 2022):
The row and columns of the grid's AddItem() seem to be a ratio, not the row and width on the screen? Are there more detailed descriptions and examples of these parameters?
@rivo commented on GitHub (Jun 24, 2022):
The
rowSpanandcolumnSpanparameters refer to rows and columns of the grid, not the screen. The size of the grid's rows and columns are defined withSetColumns()andSetRows(). SeeSetColumns()for a detailed description, including proportional sizing.@xhsky commented on GitHub (Jun 24, 2022):
func (g *Grid) AddItem(p Primitive, row, column, rowSpan, colSpan, minGridHeight, minGridWidth int, focus bool) *Grid
Do the row and column in this function parameter represent the starting position of p on the screen? How exactly is it positioned?
@rivo commented on GitHub (Jun 24, 2022):
Pretty much like the documentation says:
Grid rows and grid columns, that is.