mirror of
https://github.com/rivo/tview.git
synced 2025-04-26 13:49:06 +08:00
Flex must call Box's Draw() function first. Fixes #26
This commit is contained in:
parent
677c227861
commit
5fd6365352
@ -14,6 +14,7 @@ func main() {
|
|||||||
AddItem(tview.NewBox().SetBorder(true).SetTitle("Middle (3 x height of Top)"), 0, 3, false).
|
AddItem(tview.NewBox().SetBorder(true).SetTitle("Middle (3 x height of Top)"), 0, 3, false).
|
||||||
AddItem(tview.NewBox().SetBorder(true).SetTitle("Bottom (5 rows)"), 5, 1, false), 0, 2, false).
|
AddItem(tview.NewBox().SetBorder(true).SetTitle("Bottom (5 rows)"), 5, 1, false), 0, 2, false).
|
||||||
AddItem(tview.NewBox().SetBorder(true).SetTitle("Right (20 cols)"), 20, 1, false)
|
AddItem(tview.NewBox().SetBorder(true).SetTitle("Right (20 cols)"), 20, 1, false)
|
||||||
|
flex.SetBorder(true)
|
||||||
if err := app.SetRoot(flex, true).SetFocus(flex).Run(); err != nil {
|
if err := app.SetRoot(flex, true).SetFocus(flex).Run(); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
7
flex.go
7
flex.go
@ -79,15 +79,14 @@ func (f *Flex) AddItem(item Primitive, fixedSize, proportion int, focus bool) *F
|
|||||||
|
|
||||||
// Draw draws this primitive onto the screen.
|
// Draw draws this primitive onto the screen.
|
||||||
func (f *Flex) Draw(screen tcell.Screen) {
|
func (f *Flex) Draw(screen tcell.Screen) {
|
||||||
|
f.Box.Draw(screen)
|
||||||
|
|
||||||
// Calculate size and position of the items.
|
// Calculate size and position of the items.
|
||||||
|
|
||||||
// Do we use the entire screen?
|
// Do we use the entire screen?
|
||||||
if f.fullScreen {
|
if f.fullScreen {
|
||||||
f.x = 0
|
|
||||||
f.y = 0
|
|
||||||
width, height := screen.Size()
|
width, height := screen.Size()
|
||||||
f.width = width
|
f.SetRect(0, 0, width, height)
|
||||||
f.height = height
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// How much space can we distribute?
|
// How much space can we distribute?
|
||||||
|
Loading…
x
Reference in New Issue
Block a user