Flex must call Box's Draw() function first. Fixes #26

This commit is contained in:
Oliver 2018-01-14 13:50:58 +01:00
parent 677c227861
commit 5fd6365352
2 changed files with 4 additions and 4 deletions

View File

@ -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("Bottom (5 rows)"), 5, 1, false), 0, 2, 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 {
panic(err)
}

View File

@ -79,15 +79,14 @@ func (f *Flex) AddItem(item Primitive, fixedSize, proportion int, focus bool) *F
// Draw draws this primitive onto the screen.
func (f *Flex) Draw(screen tcell.Screen) {
f.Box.Draw(screen)
// Calculate size and position of the items.
// Do we use the entire screen?
if f.fullScreen {
f.x = 0
f.y = 0
width, height := screen.Size()
f.width = width
f.height = height
f.SetRect(0, 0, width, height)
}
// How much space can we distribute?