From 06561bb671ac089933eff4b3ecd82abe1f3287a6 Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Mon, 27 May 2024 16:28:48 -0400 Subject: [PATCH] Scrollbar, ScrollContainer use ContentObject now --- scrollbar.go | 14 +++++++------- scrollcontainer.go | 8 ++++---- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/scrollbar.go b/scrollbar.go index 4f4f5da..3f2b707 100644 --- a/scrollbar.go +++ b/scrollbar.go @@ -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()) } } diff --git a/scrollcontainer.go b/scrollcontainer.go index 927446f..efd96ec 100644 --- a/scrollcontainer.go +++ b/scrollcontainer.go @@ -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 (