Scrollbar, ScrollContainer use ContentObject now

This commit is contained in:
Sasha Koshka 2024-05-27 16:28:48 -04:00
parent a71d81af48
commit 06561bb671
2 changed files with 11 additions and 11 deletions

View File

@ -60,9 +60,9 @@ func NewHorizontalScrollbar () *Scrollbar {
return newScrollbar("horizontal")
}
// Link assigns this scrollbar to a ContentBox. Closing the returned cookie will
// unlink it.
func (this *Scrollbar) Link (box tomo.ContentBox) event.Cookie {
// Link assigns this scrollbar to a ContentObject. Closing the returned cookie
// will unlink it.
func (this *Scrollbar) Link (box tomo.ContentObject) event.Cookie {
this.layout.linked = box
this.linkCookie = this.newLinkCookie (
box.OnContentBoundsChange(this.handleLinkedContentBoundsChange))
@ -230,7 +230,7 @@ func (this *Scrollbar) fallbackDragOffset () image.Point {
func (this *Scrollbar) pageSize () int {
if this.layout.linked == nil { return 0 }
viewport := this.layout.linked.InnerBounds()
viewport := this.layout.linked.GetBox().InnerBounds()
if this.layout.vertical {
return viewport.Dy()
} else {
@ -279,7 +279,7 @@ func (this *scrollbarCookie) Close () {
type scrollbarLayout struct {
vertical bool
value float64
linked tomo.ContentBox
linked tomo.ContentObject
}
func (scrollbarLayout) MinimumSize (hints tomo.LayoutHints, boxes []tomo.Box) image.Point {
@ -341,9 +341,9 @@ func (this scrollbarLayout) viewportContentRatio () float64 {
func (this scrollbarLayout) viewportLength () float64 {
if this.vertical {
return float64(this.linked.InnerBounds().Dy())
return float64(this.linked.GetBox().InnerBounds().Dy())
} else {
return float64(this.linked.InnerBounds().Dx())
return float64(this.linked.GetBox().InnerBounds().Dx())
}
}

View File

@ -68,7 +68,7 @@ func NewScrollContainer (sides ScrollSide) *ScrollContainer {
// SetRoot sets the root child of the ScrollContainer. There can only be one at
// a time, and setting it will remove and unlink the current child if there is
// one.
func (this *ScrollContainer) SetRoot (root tomo.ContentBox) {
func (this *ScrollContainer) SetRoot (root tomo.ContentObject) {
if this.layout.root != nil {
// remove root and close cookies
this.Remove(this.layout.root)
@ -134,14 +134,14 @@ func (this *ScrollContainer) handleScroll (x, y float64) {
}
type scrollContainerLayout struct {
root tomo.ContentBox
root tomo.ContentObject
horizontal *Scrollbar
vertical *Scrollbar
}
func (this *scrollContainerLayout) MinimumSize (hints tomo.LayoutHints, boxes []tomo.Box) image.Point {
var minimum image.Point; if this.root != nil {
minimum = this.root.MinimumSize()
minimum = this.root.GetBox().MinimumSize()
}
if this.horizontal != nil {
minimum.Y += this.horizontal.MinimumSize().Y
@ -165,7 +165,7 @@ func (this *scrollContainerLayout) Arrange (hints tomo.LayoutHints, boxes []tomo
rootBounds.Max.X -= this.vertical.MinimumSize().X
}
if this.root != nil {
this.root.SetBounds(rootBounds)
this.root.GetBox().SetBounds(rootBounds)
}
if this.horizontal != nil {
this.horizontal.SetBounds(image.Rect (