Removed container from SimpleGrid and Grid. This is necessary to do now, alas; the Windows gouicontainers left over weren't being hidden, causing undesirable Tab behavior.

This commit is contained in:
Pietro Gagliardi 2014-10-26 21:33:52 -04:00
parent d97f5233a9
commit de9c598ca3
2 changed files with 13 additions and 19 deletions

16
grid.go
View File

@ -59,7 +59,7 @@ type grid struct {
controls []gridCell controls []gridCell
indexof map[Control]int indexof map[Control]int
prev int prev int
container *container parent *controlParent
padded bool padded bool
xmax int xmax int
@ -90,7 +90,6 @@ type gridCell struct {
func NewGrid() Grid { func NewGrid() Grid {
return &grid{ return &grid{
indexof: map[Control]int{}, indexof: map[Control]int{},
container: newContainer(),
} }
} }
@ -136,7 +135,9 @@ func (g *grid) Add(control Control, nextTo Control, side Side, xexpand bool, xal
xspan: xspan, xspan: xspan,
yspan: yspan, yspan: yspan,
} }
control.setParent(g.container.parent()) if g.parent != nil {
control.setParent(g.parent)
}
// if this is the first control, just add it in directly // if this is the first control, just add it in directly
if len(g.controls) != 0 { if len(g.controls) != 0 {
next := g.prev next := g.prev
@ -175,7 +176,10 @@ func (g *grid) SetPadded(padded bool) {
} }
func (g *grid) setParent(p *controlParent) { func (g *grid) setParent(p *controlParent) {
g.container.setParent(p) g.parent = p
for _, c := range g.controls {
c.control.setParent(g.parent)
}
} }
func (g *grid) containerShow() { func (g *grid) containerShow() {
@ -210,15 +214,11 @@ func (g *grid) mkgrid() (gg [][]int, colwidths []int, rowheights []int) {
} }
func (g *grid) resize(x int, y int, width int, height int, d *sizing) { func (g *grid) resize(x int, y int, width int, height int, d *sizing) {
g.container.resize(x, y, width, height, d)
if len(g.controls) == 0 { if len(g.controls) == 0 {
// nothing to do // nothing to do
return return
} }
x, y, width, height = g.container.bounds(d)
// -2) get this Grid's padding // -2) get this Grid's padding
xpadding := d.xpadding xpadding := d.xpadding
ypadding := d.ypadding ypadding := d.ypadding

View File

@ -40,7 +40,6 @@ type simpleGrid struct {
stretchyfill bool stretchyfill bool
widths, heights [][]int // caches to avoid reallocating each time widths, heights [][]int // caches to avoid reallocating each time
rowheights, colwidths []int rowheights, colwidths []int
container *container
padded bool padded bool
} }
@ -81,13 +80,6 @@ func NewSimpleGrid(nPerRow int, controls ...Control) SimpleGrid {
heights: ch, heights: ch,
rowheights: make([]int, nRows), rowheights: make([]int, nRows),
colwidths: make([]int, nPerRow), colwidths: make([]int, nPerRow),
container: newContainer(),
}
p := g.container.parent()
for _, cc := range g.controls {
for _, c := range cc {
c.setParent(p)
}
} }
return g return g
} }
@ -121,7 +113,11 @@ func (g *simpleGrid) SetPadded(padded bool) {
} }
func (g *simpleGrid) setParent(parent *controlParent) { func (g *simpleGrid) setParent(parent *controlParent) {
g.container.setParent(parent) for _, cc := range g.controls {
for _, c := range cc {
c.setParent(parent)
}
}
} }
func (g *simpleGrid) containerShow() { func (g *simpleGrid) containerShow() {
@ -148,11 +144,9 @@ func (g *simpleGrid) resize(x int, y int, width int, height int, d *sizing) {
return b return b
} }
g.container.resize(x, y, width, height, d)
if len(g.controls) == 0 { if len(g.controls) == 0 {
return return
} }
x, y, width, height = g.container.bounds(d)
// -1) get this SimpleGrid's padding // -1) get this SimpleGrid's padding
xpadding := d.xpadding xpadding := d.xpadding
ypadding := d.ypadding ypadding := d.ypadding