summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-06-26 10:36:59 -0400
committerPietro Gagliardi <[email protected]>2014-06-26 10:36:59 -0400
commit214467bb939db60ae6080fc83f7009f14c84982a (patch)
treefc07da4b230b0d97d04a12010f7449f4c5db478d
parent131809fc625e56abda3ce381920bb1021de9c793 (diff)
Implemented window margins for Grids and Stacks.
-rw-r--r--grid.go7
-rw-r--r--stack.go7
-rw-r--r--test/main.go1
3 files changed, 11 insertions, 4 deletions
diff --git a/grid.go b/grid.go
index 53c7d35..8a42bcf 100644
--- a/grid.go
+++ b/grid.go
@@ -139,8 +139,11 @@ func (g *Grid) allocate(x int, y int, width int, height int, d *sysSizeData) (al
ymargin := d.ymargin
d.xmargin = 0
d.ymargin = 0
-_=xmargin
-_=ymargin
+ // 0) inset the available rect by the margins
+ x += xmargin
+ y += ymargin
+ width -= xmargin * 2
+ height -= ymargin * 2
// 1) clear data structures
for i := range g.rowheights {
g.rowheights[i] = 0
diff --git a/stack.go b/stack.go
index c534ff2..7896da5 100644
--- a/stack.go
+++ b/stack.go
@@ -89,8 +89,11 @@ func (s *Stack) allocate(x int, y int, width int, height int, d *sysSizeData) (a
ymargin := d.ymargin
d.xmargin = 0
d.ymargin = 0
-_=xmargin
-_=ymargin
+ // 0) inset the available rect by the margins
+ x += xmargin
+ y += ymargin
+ width -= xmargin * 2
+ height -= ymargin * 2
// 1) get height and width of non-stretchy controls; figure out how much space is alloted to stretchy controls
stretchywid = width
stretchyht = height
diff --git a/test/main.go b/test/main.go
index 16513b8..b65a799 100644
--- a/test/main.go
+++ b/test/main.go
@@ -41,6 +41,7 @@ func gridWindow() *Window {
l20, c21, l22)
g.SetFilling(1, 2)
g.SetStretchy(1, 1)
+ w.SetSpaced(*spacingTest)
w.Open(g)
return w
}