Fixed empty cells in Grid not handled correctly.

This commit is contained in:
Pietro Gagliardi 2014-09-01 13:31:39 -04:00
parent 53c57267b1
commit 76c518b3e2
1 changed files with 12 additions and 10 deletions

22
grid.go
View File

@ -288,17 +288,19 @@ func (g *grid) allocate(x int, y int, width int, height int, d *sizing) (allocat
for row, xcol := range g.grid {
current = nil
for col, c := range xcol {
cell := g.controls[c]
as := c.allocate(x + cell.xoff, y + cell.yoff, cell.width, cell.height, d)
if current != nil { // connect first left to first right
current.neighbor = c
if c != nil { // treat empty cells like spaces
cell := g.controls[c]
as := c.allocate(x + cell.xoff, y + cell.yoff, cell.width, cell.height, d)
if current != nil { // connect first left to first right
current.neighbor = c
}
if len(as) != 0 {
current = as[0] // next left is first subwidget
} else {
current = nil // spaces don't have allocation data
}
allocations = append(allocations, as...)
}
if len(as) != 0 {
current = as[0] // next left is first subwidget
} else {
current = nil // spaces don't have allocation data
}
allocations = append(allocations, as...)
x += colwidths[col] + d.xpadding
}
x = startx