Scrollbar, ScrollContainer use ContentObject now
This commit is contained in:
parent
a71d81af48
commit
06561bb671
14
scrollbar.go
14
scrollbar.go
@ -60,9 +60,9 @@ func NewHorizontalScrollbar () *Scrollbar {
|
|||||||
return newScrollbar("horizontal")
|
return newScrollbar("horizontal")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Link assigns this scrollbar to a ContentBox. Closing the returned cookie will
|
// Link assigns this scrollbar to a ContentObject. Closing the returned cookie
|
||||||
// unlink it.
|
// will unlink it.
|
||||||
func (this *Scrollbar) Link (box tomo.ContentBox) event.Cookie {
|
func (this *Scrollbar) Link (box tomo.ContentObject) event.Cookie {
|
||||||
this.layout.linked = box
|
this.layout.linked = box
|
||||||
this.linkCookie = this.newLinkCookie (
|
this.linkCookie = this.newLinkCookie (
|
||||||
box.OnContentBoundsChange(this.handleLinkedContentBoundsChange))
|
box.OnContentBoundsChange(this.handleLinkedContentBoundsChange))
|
||||||
@ -230,7 +230,7 @@ func (this *Scrollbar) fallbackDragOffset () image.Point {
|
|||||||
|
|
||||||
func (this *Scrollbar) pageSize () int {
|
func (this *Scrollbar) pageSize () int {
|
||||||
if this.layout.linked == nil { return 0 }
|
if this.layout.linked == nil { return 0 }
|
||||||
viewport := this.layout.linked.InnerBounds()
|
viewport := this.layout.linked.GetBox().InnerBounds()
|
||||||
if this.layout.vertical {
|
if this.layout.vertical {
|
||||||
return viewport.Dy()
|
return viewport.Dy()
|
||||||
} else {
|
} else {
|
||||||
@ -279,7 +279,7 @@ func (this *scrollbarCookie) Close () {
|
|||||||
type scrollbarLayout struct {
|
type scrollbarLayout struct {
|
||||||
vertical bool
|
vertical bool
|
||||||
value float64
|
value float64
|
||||||
linked tomo.ContentBox
|
linked tomo.ContentObject
|
||||||
}
|
}
|
||||||
|
|
||||||
func (scrollbarLayout) MinimumSize (hints tomo.LayoutHints, boxes []tomo.Box) image.Point {
|
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 {
|
func (this scrollbarLayout) viewportLength () float64 {
|
||||||
if this.vertical {
|
if this.vertical {
|
||||||
return float64(this.linked.InnerBounds().Dy())
|
return float64(this.linked.GetBox().InnerBounds().Dy())
|
||||||
} else {
|
} else {
|
||||||
return float64(this.linked.InnerBounds().Dx())
|
return float64(this.linked.GetBox().InnerBounds().Dx())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ func NewScrollContainer (sides ScrollSide) *ScrollContainer {
|
|||||||
// SetRoot sets the root child of the ScrollContainer. There can only be one at
|
// 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
|
// a time, and setting it will remove and unlink the current child if there is
|
||||||
// one.
|
// one.
|
||||||
func (this *ScrollContainer) SetRoot (root tomo.ContentBox) {
|
func (this *ScrollContainer) SetRoot (root tomo.ContentObject) {
|
||||||
if this.layout.root != nil {
|
if this.layout.root != nil {
|
||||||
// remove root and close cookies
|
// remove root and close cookies
|
||||||
this.Remove(this.layout.root)
|
this.Remove(this.layout.root)
|
||||||
@ -134,14 +134,14 @@ func (this *ScrollContainer) handleScroll (x, y float64) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type scrollContainerLayout struct {
|
type scrollContainerLayout struct {
|
||||||
root tomo.ContentBox
|
root tomo.ContentObject
|
||||||
horizontal *Scrollbar
|
horizontal *Scrollbar
|
||||||
vertical *Scrollbar
|
vertical *Scrollbar
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *scrollContainerLayout) MinimumSize (hints tomo.LayoutHints, boxes []tomo.Box) image.Point {
|
func (this *scrollContainerLayout) MinimumSize (hints tomo.LayoutHints, boxes []tomo.Box) image.Point {
|
||||||
var minimum image.Point; if this.root != nil {
|
var minimum image.Point; if this.root != nil {
|
||||||
minimum = this.root.MinimumSize()
|
minimum = this.root.GetBox().MinimumSize()
|
||||||
}
|
}
|
||||||
if this.horizontal != nil {
|
if this.horizontal != nil {
|
||||||
minimum.Y += this.horizontal.MinimumSize().Y
|
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
|
rootBounds.Max.X -= this.vertical.MinimumSize().X
|
||||||
}
|
}
|
||||||
if this.root != nil {
|
if this.root != nil {
|
||||||
this.root.SetBounds(rootBounds)
|
this.root.GetBox().SetBounds(rootBounds)
|
||||||
}
|
}
|
||||||
if this.horizontal != nil {
|
if this.horizontal != nil {
|
||||||
this.horizontal.SetBounds(image.Rect (
|
this.horizontal.SetBounds(image.Rect (
|
||||||
|
Loading…
Reference in New Issue
Block a user