mirror of
https://github.com/rivo/tview.git
synced 2026-04-26 21:35:54 +03:00
[GH-ISSUE #277] Resolve Grid's preference of larger items #216
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/tview#216
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 @Anaminus on GitHub (Apr 25, 2019).
Original GitHub issue: https://github.com/rivo/tview/issues/277
The following code is meant to demonstrate a primitive
pthat either fills the screen, or is centered when the screen is wide enough:In practice, the primitive is always drawn fullscreen, because the grid prefers the larger of the two items. Since priority is otherwise determined by insertion order, this preference seems to do very little other than restrict the layouts that are possible with grids. Unfortunately, outright removing the behavior isn't backwards-compatible, so I suggest making it optional with some sort of set-size-preference method.
If a breaking change is tolerable, then the issue could be resolved by removing the following lines:
github.com/rivo/tview@90b4da1bd6/grid.go (L319-L322)@rivo commented on GitHub (May 14, 2019):
This was actually a bug, it turns out. The comments for
Grid.AddItem()say:The code you showed compared the item's width/height instead of the minimum width/height. I fixed this in the latest commit.