restructure compact widgets

This commit is contained in:
Bradley Cicenas
2017-03-06 00:15:32 +00:00
parent 3172f141f9
commit 52a3e61b92
7 changed files with 121 additions and 109 deletions

View File

@@ -21,17 +21,30 @@ func NewCompactGrid() *CompactGrid {
}
func (cg *CompactGrid) Align() {
// Update y recursively
cg.header.SetY(cg.Y)
// update header y pos
if cg.header.Y != cg.Y {
cg.header.SetY(cg.Y)
}
// update row y pos recursively
y := cg.Y + 1
for _, r := range cg.Rows {
r.SetY(y)
if r.Y != y {
r.SetY(y)
}
y += r.Height
}
// Update width recursively
cg.header.SetWidth(cg.Width)
// update header width
if cg.header.Width != cg.Width {
cg.header.SetWidth(cg.Width)
}
// update row width recursively
for _, r := range cg.Rows {
r.SetWidth(cg.Width)
if r.Width != cg.Width {
r.SetWidth(cg.Width)
}
}
}