Add recommended sizes and all that jazz
This commit is contained in:
parent
80f60b42de
commit
c7f09c7894
@ -128,6 +128,15 @@ func (this *box) borderSum () tomo.Inset {
|
||||
return sum
|
||||
}
|
||||
|
||||
func (this *box) borderAndPaddingSum () tomo.Inset {
|
||||
sum := this.borderSum()
|
||||
sum[0] += this.padding[0]
|
||||
sum[1] += this.padding[1]
|
||||
sum[2] += this.padding[2]
|
||||
sum[3] += this.padding[3]
|
||||
return sum
|
||||
}
|
||||
|
||||
func (this *box) SetBounds (bounds image.Rectangle) {
|
||||
if this.bounds == bounds { return }
|
||||
this.bounds = bounds
|
||||
|
@ -73,6 +73,24 @@ func (this *containerBox) ScrollTo (point image.Point) {
|
||||
this.invalidateLayout()
|
||||
}
|
||||
|
||||
func (this *containerBox) RecommendedHeight (width int) int {
|
||||
if this.layout == nil {
|
||||
return this.MinimumSize().Y
|
||||
} else {
|
||||
return this.layout.RecommendedHeight(this.layoutHints(), this.children, width) +
|
||||
this.borderAndPaddingSum().Vertical()
|
||||
}
|
||||
}
|
||||
|
||||
func (this *containerBox) RecommendedWidth (height int) int {
|
||||
if this.layout == nil {
|
||||
return this.MinimumSize().X
|
||||
} else {
|
||||
return this.layout.RecommendedWidth(this.layoutHints(), this.children, height) +
|
||||
this.borderAndPaddingSum().Horizontal()
|
||||
}
|
||||
}
|
||||
|
||||
func (this *containerBox) OnContentBoundsChange (callback func()) event.Cookie {
|
||||
return this.on.contentBoundsChange.Connect(callback)
|
||||
}
|
||||
|
@ -65,6 +65,15 @@ func (this *textBox) ScrollTo (point image.Point) {
|
||||
this.invalidateLayout()
|
||||
}
|
||||
|
||||
func (this *textBox) RecommendedHeight (width int) int {
|
||||
return this.drawer.ReccomendedHeightFor(width) + this.borderAndPaddingSum().Vertical()
|
||||
}
|
||||
|
||||
func (this *textBox) RecommendedWidth (height int) int {
|
||||
// TODO maybe not the best idea?
|
||||
return this.MinimumSize().X
|
||||
}
|
||||
|
||||
func (this *textBox) OnContentBoundsChange (callback func()) event.Cookie {
|
||||
return this.on.contentBoundsChange.Connect(callback)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user