Re-added OnScrollBoundsChange methods because they are useful

This commit is contained in:
Sasha Koshka 2023-03-15 23:56:00 -04:00
parent 639baecee5
commit 8aaa017902
3 changed files with 23 additions and 1 deletions

View File

@ -21,6 +21,8 @@ type DocumentContainer struct {
config config.Wrapped
theme theme.Wrapped
onScrollBoundsChange func ()
}
// NewDocumentContainer creates a new document container.
@ -255,6 +257,12 @@ func (element *DocumentContainer) ScrollTo (position image.Point) {
}
}
// OnScrollBoundsChange sets a function to be called when the element's viewport
// bounds, content bounds, or scroll axes change.
func (element *DocumentContainer) OnScrollBoundsChange (callback func ()) {
element.onScrollBoundsChange = callback
}
func (element *DocumentContainer) maxScrollHeight () (height int) {
padding := element.theme.Padding(theme.PatternSunken)
viewportHeight := element.Bounds().Dy() - padding.Vertical()

View File

@ -30,7 +30,8 @@ type List struct {
config config.Wrapped
theme theme.Wrapped
onNoEntrySelected func ()
onNoEntrySelected func ()
onScrollBoundsChange func ()
}
// NewList creates a new list element with the specified entries.
@ -240,6 +241,12 @@ func (element *List) OnNoEntrySelected (callback func ()) {
element.onNoEntrySelected = callback
}
// OnScrollBoundsChange sets a function to be called when the element's viewport
// bounds, content bounds, or scroll axes change.
func (element *List) OnScrollBoundsChange (callback func ()) {
element.onScrollBoundsChange = callback
}
// CountEntries returns the amount of entries in the list.
func (element *List) CountEntries () (count int) {
return len(element.entries)

View File

@ -34,6 +34,7 @@ type TextBox struct {
onKeyDown func (key input.Key, modifiers input.Modifiers) (handled bool)
onChange func ()
onScrollBoundsChange func ()
}
// NewTextBox creates a new text box with the specified placeholder text, and
@ -241,6 +242,12 @@ func (element *TextBox) OnChange (callback func ()) {
element.onChange = callback
}
// OnScrollBoundsChange sets a function to be called when the element's viewport
// bounds, content bounds, or scroll axes change.
func (element *TextBox) OnScrollBoundsChange (callback func ()) {
element.onScrollBoundsChange = callback
}
// ScrollContentBounds returns the full content size of the element.
func (element *TextBox) ScrollContentBounds () (bounds image.Rectangle) {
bounds = element.valueDrawer.LayoutBounds()