summaryrefslogtreecommitdiff
path: root/grid.go
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-09-01 10:11:41 -0400
committerPietro Gagliardi <[email protected]>2014-09-01 10:11:41 -0400
commit83b1957fd7d03e0eb16f86e481596af1d095dd16 (patch)
treea1d2636908911e4414e7ae9a91888a088ba96b80 /grid.go
parentdcb505fd01b5fb5c527f3376154c8d970a67789c (diff)
Implemented vertical alignment in Grid.
Diffstat (limited to 'grid.go')
-rw-r--r--grid.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/grid.go b/grid.go
index 1b4f7bc..a049a38 100644
--- a/grid.go
+++ b/grid.go
@@ -259,12 +259,14 @@ func (g *grid) allocate(x int, y int, width int, height int, d *sizing) (allocat
default:
panic(fmt.Errorf("invalid xalign %d in Grid.allocate()", cell.xalign))
}
+ cell.yoff = 0
switch cell.yalign {
case LeftTop:
// do nothing; this is the default
case Center:
+ cell.yoff = (rowheights[cell.gridy] - cell.height) / 2
case RightBottom:
- // TODO
+ cell.yoff = rowheights[cell.gridy] - cell.height
case Fill:
cell.height = rowheights[cell.gridy]
default:
@@ -280,7 +282,7 @@ func (g *grid) allocate(x int, y int, width int, height int, d *sizing) (allocat
current = nil
for col, c := range xcol {
cell := g.controls[c]
- as := c.allocate(x + cell.xoff, y, cell.width, cell.height, d)
+ 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
}