Quelled some of the strangeness
This commit is contained in:
parent
081b005679
commit
15fa3b2497
@ -267,6 +267,10 @@ func (element *DocumentContainer) ScrollTo (position image.Point) {
|
|||||||
if position.Y < 0 {
|
if position.Y < 0 {
|
||||||
position.Y = 0
|
position.Y = 0
|
||||||
}
|
}
|
||||||
|
maxScrollHeight := element.maxScrollHeight()
|
||||||
|
if position.Y > maxScrollHeight {
|
||||||
|
position.Y = maxScrollHeight
|
||||||
|
}
|
||||||
element.scroll = position
|
element.scroll = position
|
||||||
if element.core.HasImage() && !element.warping {
|
if element.core.HasImage() && !element.warping {
|
||||||
element.redoAll()
|
element.redoAll()
|
||||||
@ -274,6 +278,14 @@ func (element *DocumentContainer) ScrollTo (position image.Point) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (element *DocumentContainer) maxScrollHeight () (height int) {
|
||||||
|
padding := element.theme.Padding(theme.PatternSunken)
|
||||||
|
viewportHeight := element.Bounds().Dy() - padding.Vertical()
|
||||||
|
height = element.contentBounds.Dy() - viewportHeight
|
||||||
|
if height < 0 { height = 0 }
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// ScrollAxes returns the supported axes for scrolling.
|
// ScrollAxes returns the supported axes for scrolling.
|
||||||
func (element *DocumentContainer) ScrollAxes () (horizontal, vertical bool) {
|
func (element *DocumentContainer) ScrollAxes () (horizontal, vertical bool) {
|
||||||
return false, true
|
return false, true
|
||||||
@ -339,4 +351,6 @@ func (element *DocumentContainer) doLayout () {
|
|||||||
element.contentBounds = element.contentBounds.Union(entry.Bounds)
|
element.contentBounds = element.contentBounds.Union(entry.Bounds)
|
||||||
dot.Y += height
|
dot.Y += height
|
||||||
}
|
}
|
||||||
|
element.contentBounds =
|
||||||
|
element.contentBounds.Sub(element.contentBounds.Min)
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,16 @@ func run () {
|
|||||||
"text-wrapped labels.", true))
|
"text-wrapped labels.", true))
|
||||||
document.Adopt (basicElements.NewButton (
|
document.Adopt (basicElements.NewButton (
|
||||||
"You can also include normal elements like buttons,"))
|
"You can also include normal elements like buttons,"))
|
||||||
|
document.Adopt (basicElements.NewButton (
|
||||||
|
"You can also include normal elements like buttons,"))
|
||||||
|
document.Adopt (basicElements.NewButton (
|
||||||
|
"You can also include normal elements like buttons,"))
|
||||||
|
document.Adopt (basicElements.NewButton (
|
||||||
|
"You can also include normal elements like buttons,"))
|
||||||
|
document.Adopt (basicElements.NewButton (
|
||||||
|
"You can also include normal elements like buttons,"))
|
||||||
|
document.Adopt (basicElements.NewButton (
|
||||||
|
"You can also include normal elements like buttons,"))
|
||||||
document.Adopt (basicElements.NewCheckbox (
|
document.Adopt (basicElements.NewCheckbox (
|
||||||
"checkboxes,", true))
|
"checkboxes,", true))
|
||||||
document.Adopt(basicElements.NewTextBox("", "And text boxes."))
|
document.Adopt(basicElements.NewTextBox("", "And text boxes."))
|
||||||
|
@ -41,8 +41,7 @@ func (setter *TypeSetter) needLayout () {
|
|||||||
metrics := setter.face.Metrics()
|
metrics := setter.face.Metrics()
|
||||||
remaining := setter.text
|
remaining := setter.text
|
||||||
y := fixed.Int26_6(0)
|
y := fixed.Int26_6(0)
|
||||||
maxY := fixed.I(setter.maxHeight) + metrics.Height
|
for len(remaining) > 0 {
|
||||||
for len(remaining) > 0 && (y < maxY || setter.maxHeight == 0) {
|
|
||||||
// process one line
|
// process one line
|
||||||
line, remainingFromLine := DoLine (
|
line, remainingFromLine := DoLine (
|
||||||
remaining, setter.face, fixed.I(setter.maxWidth))
|
remaining, setter.face, fixed.I(setter.maxWidth))
|
||||||
|
Reference in New Issue
Block a user