diff --git a/containerbox.go b/containerbox.go index 2e5e37a..34de3dd 100644 --- a/containerbox.go +++ b/containerbox.go @@ -12,7 +12,7 @@ type containerBox struct { contentBounds image.Rectangle scroll image.Point - gap tomo.Gap + gap image.Point children []anyBox layout tomo.Layout @@ -55,7 +55,7 @@ func (this *containerBox) OnContentBoundsChange (callback func()) event.Cookie { return this.on.contentBoundsChange.Connect(callback) } -func (this *containerBox) SetGap (gap tomo.Gap) { +func (this *containerBox) SetGap (gap image.Point) { if this.gap == gap { return } this.gap = gap this.invalidateLayout() @@ -143,6 +143,16 @@ func (this *containerBox) canvas () canvas.Canvas { return this.box.canvas } +func (this *containerBox) layoutHints () tomo.LayoutHints { + innerBounds := this.InnerBounds().Sub(this.scroll) + return tomo.LayoutHints { + Bounds: innerBounds, + OverflowX: this.hOverflow, + OverflowY: this.vOverflow, + Gap: this.gap, + } +} + func (this *containerBox) doLayout () { this.box.doLayout() // TODO: possibly store all children as tomo.Box-es and don't allocate a @@ -155,10 +165,7 @@ func (this *containerBox) doLayout () { if this.layout != nil { // TODO maybe we should pass more information into Arrange such // as overflow information and scroll - this.layout.Arrange ( - this.InnerBounds().Sub(this.scroll), - this.gap, - boxes) + this.layout.Arrange(this.layoutHints(), boxes) } if previousContentBounds != this.contentBounds { this.on.contentBoundsChange.Broadcast() diff --git a/go.mod b/go.mod index a827c1a..63b63d8 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.20 require ( git.tebibyte.media/tomo/ggfx v0.4.0 - git.tebibyte.media/tomo/tomo v0.8.0 + git.tebibyte.media/tomo/tomo v0.10.0 git.tebibyte.media/tomo/xgbkb v1.0.1 github.com/jezek/xgb v1.1.0 github.com/jezek/xgbutil v0.0.0-20230603163917-04188eb39cf0 @@ -13,5 +13,5 @@ require ( require ( github.com/BurntSushi/freetype-go v0.0.0-20160129220410-b763ddbfe298 // indirect github.com/BurntSushi/graphics-go v0.0.0-20160129215708-b43f31a4a966 // indirect - golang.org/x/image v0.8.0 // indirect + golang.org/x/image v0.9.0 // indirect ) diff --git a/go.sum b/go.sum index 26d9573..f9da488 100644 --- a/go.sum +++ b/go.sum @@ -25,6 +25,10 @@ git.tebibyte.media/tomo/tomo v0.7.3 h1:eHwuYKe+0nLWoEfPZid8njirxmWY3dFmdY+PsPp1R git.tebibyte.media/tomo/tomo v0.7.3/go.mod h1:lTwjpiHbP4UN/kFw+6FwhG600B+PMKVtMOr7wpd5IUY= git.tebibyte.media/tomo/tomo v0.8.0 h1:Sqvos2Huf0mSHFZ0FJrBZiH8Ro/gmQPHCvK6Qr29SBo= git.tebibyte.media/tomo/tomo v0.8.0/go.mod h1:lTwjpiHbP4UN/kFw+6FwhG600B+PMKVtMOr7wpd5IUY= +git.tebibyte.media/tomo/tomo v0.9.0 h1:Ow7LaOwPTNogkREDVbxsx827XcyHKzXq3dFSM0TttC4= +git.tebibyte.media/tomo/tomo v0.9.0/go.mod h1:lTwjpiHbP4UN/kFw+6FwhG600B+PMKVtMOr7wpd5IUY= +git.tebibyte.media/tomo/tomo v0.10.0 h1:SFX4JQt1KgWeX9RnYoUQRj7MyFyb1ld8uDPHFTU2IKU= +git.tebibyte.media/tomo/tomo v0.10.0/go.mod h1:lTwjpiHbP4UN/kFw+6FwhG600B+PMKVtMOr7wpd5IUY= git.tebibyte.media/tomo/xgbkb v1.0.1 h1:b3HDUopjdQp1MZrb5Vpil4bOtk3NnNXtfQW27Blw2kE= git.tebibyte.media/tomo/xgbkb v1.0.1/go.mod h1:P5Du0yo5hUsojchW08t+Mds0XPIJXwMi733ZfklzjRw= github.com/BurntSushi/freetype-go v0.0.0-20160129220410-b763ddbfe298 h1:1qlsVAQJXZHsaM8b6OLVo6muQUQd4CwkH/D3fnnbHXA= @@ -40,6 +44,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/image v0.8.0 h1:agUcRXV/+w6L9ryntYYsF2x9fQTMd4T8fiiYXAVW6Jg= golang.org/x/image v0.8.0/go.mod h1:PwLxp3opCYg4WR2WO9P0L6ESnsD6bLTWcw8zanLMVFM= +golang.org/x/image v0.9.0 h1:QrzfX26snvCM20hIhBwuHI/ThTg18b/+kcKdXHvnR+g= +golang.org/x/image v0.9.0/go.mod h1:jtrku+n79PfroUbvDdeUWMAI+heR786BofxrbiSF+J0= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -63,6 +69,7 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.10.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=