Text boxes now have properly constrained scrolling/autoscrolling
This commit is contained in:
parent
2ecfafa469
commit
7fc2b1cd87
68
textbox.go
68
textbox.go
@ -59,7 +59,7 @@ func (this *textBox) ContentBounds () image.Rectangle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *textBox) ScrollTo (point image.Point) {
|
func (this *textBox) ScrollTo (point image.Point) {
|
||||||
// TODO: constrain scroll
|
if this.scroll == point { return }
|
||||||
this.scroll = point
|
this.scroll = point
|
||||||
this.invalidateLayout()
|
this.invalidateLayout()
|
||||||
}
|
}
|
||||||
@ -115,6 +115,7 @@ func (this *textBox) Select (dot text.Dot) {
|
|||||||
if this.dot == dot { return }
|
if this.dot == dot { return }
|
||||||
this.SetFocused(true)
|
this.SetFocused(true)
|
||||||
this.dot = dot
|
this.dot = dot
|
||||||
|
this.scrollToDot()
|
||||||
this.on.dotChange.Broadcast()
|
this.on.dotChange.Broadcast()
|
||||||
this.invalidateDraw()
|
this.invalidateDraw()
|
||||||
}
|
}
|
||||||
@ -275,16 +276,13 @@ func (this *textBox) normalizedLayoutBoundsSpace () image.Rectangle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *textBox) contentMinimum () image.Point {
|
func (this *textBox) contentMinimum () image.Point {
|
||||||
minimum := image.Pt (
|
minimum := this.drawer.MinimumSize()
|
||||||
this.drawer.Em().Round(),
|
|
||||||
this.drawer.LineHeight().Round())
|
|
||||||
|
|
||||||
textSize := this.drawer.MinimumSize()
|
if this.hOverflow || this.wrap {
|
||||||
if !this.hOverflow && !this.wrap {
|
minimum.X = this.drawer.Em().Round()
|
||||||
minimum.X = textSize.X
|
|
||||||
}
|
}
|
||||||
if !this.vOverflow {
|
if this.vOverflow {
|
||||||
minimum.Y = textSize.Y
|
minimum.Y = this.drawer.LineHeight().Round()
|
||||||
}
|
}
|
||||||
|
|
||||||
return minimum.Add(this.box.contentMinimum())
|
return minimum.Add(this.box.contentMinimum())
|
||||||