diff options
| author | faiface <faiface@ksp.sk> | 2017-08-23 23:23:13 +0200 |
|---|---|---|
| committer | faiface <faiface@ksp.sk> | 2017-08-23 23:23:13 +0200 |
| commit | 453fca4f6ebc50b7ed8f31a04efe7edf4749c4dc (patch) | |
| tree | 2fefd384ec3644f15de5862657cf273c975df914 | |
| parent | 4952b441cc664ff941fb59c7a53bc554277c13a5 (diff) | |
| download | gui-453fca4f6ebc50b7ed8f31a04efe7edf4749c4dc.zip | |
layout: minor changes + bug fix
| -rw-r--r-- | layout/split.go | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/layout/split.go b/layout/split.go index 0c197b3..90c4a0a 100644 --- a/layout/split.go +++ b/layout/split.go @@ -17,7 +17,7 @@ func (b *Box) Image() *image.RGBA { } func (b *Box) Flush(r image.Rectangle) { - r = r.Intersect(b.dst.Image().Bounds()) + r = r.Intersect(b.sub.Bounds()) b.dst.Flush(r) } @@ -119,11 +119,12 @@ func NewSplit(dst EventImageFlusher, splitter Splitter) *Split { dst: dst, splitter: splitter, } - dst.Event("", s.Happen) - s.Event("resize", func(evt string) bool { + s.Event("resize", func(string) bool { s.Split() + s.dst.Flush(s.dst.Image().Bounds()) return true }) + dst.Event("", s.Happen) return s } @@ -144,6 +145,7 @@ func (s *Split) Add() *Box { dst: s.dst, } s.boxes = append(s.boxes, box) + s.Split() return box } @@ -154,8 +156,8 @@ func (s *Split) Split() { subR := s.splitter(r, i, n) s.boxes[i].sub = s.dst.Image().SubImage(subR).(*image.RGBA) } - for i := range s.boxes { - subR := s.boxes[i].sub.Bounds() - s.boxes[i].Happen(event.Sprint("resize", subR.Min.X, subR.Min.Y, subR.Max.X, subR.Max.Y)) + for _, box := range s.boxes { + subR := box.sub.Bounds() + box.Happen(event.Sprint("resize", subR.Min.X, subR.Min.Y, subR.Max.X, subR.Max.Y)) } } |