summaryrefslogtreecommitdiff
path: root/redo/sizing.go
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-07-25 22:13:09 -0400
committerPietro Gagliardi <[email protected]>2014-07-25 22:13:09 -0400
commit41f3ef292f2e0d70beb3722004c968881ca0fae2 (patch)
tree1993bd896d607ef7b961bd7c3f89c6258401d69d /redo/sizing.go
parentc676a2d9b7996df8d76d42c47b5f376b72b08ae0 (diff)
Cleaned up sizing a bit. Being able to know how big something will be ahead of time would be better.
Diffstat (limited to 'redo/sizing.go')
-rw-r--r--redo/sizing.go18
1 files changed, 15 insertions, 3 deletions
diff --git a/redo/sizing.go b/redo/sizing.go
index 0db6216..97cf4e8 100644
--- a/redo/sizing.go
+++ b/redo/sizing.go
@@ -30,19 +30,31 @@ type controlSizing interface {
type container struct {
child Control
spaced bool
- beginResize func() (d *sizing)
+ beginResize func() (d *sizing) // for the initial call
+ d *sizing // for recursive calls
}
func (c *container) resize(width, height int) {
if c.child == nil { // no children; nothing to do
return
}
- d := c.beginResize()
+ if c.d == nil { // initial call
+ if c.beginResize == nil {
+ // should be a recursive call, but is not
+ // TODO get rid of this
+ return
+ }
+ c.d = c.beginResize()
+ defer c.endResize(c.d)
+ }
+ d := c.d
allocations := c.child.allocate(0, 0, width, height, d)
c.translateAllocationCoords(allocations, width, height)
// move in reverse so as to approximate right->left order so neighbors make sense
for i := len(allocations) - 1; i >= 0; i-- {
allocations[i].this.commitResize(allocations[i], d)
}
- c.endResize(d)
+ // always set c.d to nil so it can be garbage-collected
+ // the c.endResize() above won't matter since the c.d there is evaluated then, not when c.endResize() is called
+ c.d = nil
}