From 1596d54834fed9020a4a068c7a67dbbe630d00aa Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Tue, 11 Jun 2024 17:17:11 -0400 Subject: [PATCH] Fix up objects code --- container.go | 3 --- scrollbar.go | 8 ++++++++ scrollcontainer.go | 9 +++++++++ slider.go | 8 ++++++++ 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/container.go b/container.go index 1724238..004d1e3 100644 --- a/container.go +++ b/container.go @@ -28,7 +28,6 @@ func newContainer (layout tomo.Layout, children ...tomo.Object) *Container { func NewOuterContainer (layout tomo.Layout, children ...tomo.Object) *Container { this := newContainer(layout, children...) this.SetRole(tomo.R("objects", "Container", "outer")) - tomo.Apply(this) return this } @@ -37,7 +36,6 @@ func NewOuterContainer (layout tomo.Layout, children ...tomo.Object) *Container func NewSunkenContainer (layout tomo.Layout, children ...tomo.Object) *Container { this := newContainer(layout, children...) this.SetRole(tomo.R("objects", "Container", "sunken")) - tomo.Apply(this) return this } @@ -45,7 +43,6 @@ func NewSunkenContainer (layout tomo.Layout, children ...tomo.Object) *Container func NewInnerContainer (layout tomo.Layout, children ...tomo.Object) *Container { this := newContainer(layout, children...) this.SetRole(tomo.R("objects", "Container", "inner")) - tomo.Apply(this) return this } diff --git a/scrollbar.go b/scrollbar.go index 1554ab5..1366342 100644 --- a/scrollbar.go +++ b/scrollbar.go @@ -335,6 +335,14 @@ func (this scrollbarLayout) Arrange (hints tomo.LayoutHints, boxes []tomo.Box) { } +func (this scrollbarLayout) RecommendedHeight (tomo.LayoutHints, []tomo.Box, int) int { + return 0 +} + +func (this scrollbarLayout) RecommendedWidth (tomo.LayoutHints, []tomo.Box, int) int { + return 0 +} + func (this scrollbarLayout) viewportContentRatio () float64 { if this.linked == nil { return 0 } return this.viewportLength() / this.contentLength() diff --git a/scrollcontainer.go b/scrollcontainer.go index b7751b3..9659acc 100644 --- a/scrollcontainer.go +++ b/scrollcontainer.go @@ -133,6 +133,7 @@ func (this *ScrollContainer) handleScroll (x, y float64) { Sub(image.Pt(int(x), int(y)))) } +// TODO: remove this and replace it with something from the layouts package type scrollContainerLayout struct { root tomo.ContentObject horizontal *Scrollbar @@ -183,6 +184,14 @@ func (this *scrollContainerLayout) Arrange (hints tomo.LayoutHints, boxes []tomo } } +func (this *scrollContainerLayout) RecommendedHeight (tomo.LayoutHints, []tomo.Box, int) int { + return 0 +} + +func (this *scrollContainerLayout) RecommendedWidth (tomo.LayoutHints, []tomo.Box, int) int { + return 0 +} + func max (x, y int) int { if x > y { return x } return y diff --git a/slider.go b/slider.go index 0982de7..4ae1c47 100644 --- a/slider.go +++ b/slider.go @@ -238,3 +238,11 @@ func (this sliderLayout) Arrange (hints tomo.LayoutHints, boxes []tomo.Box) { Add(gutter.Min)) } } + +func (this sliderLayout) RecommendedHeight (tomo.LayoutHints, []tomo.Box, int) int { + return 0 +} + +func (this sliderLayout) RecommendedWidth (tomo.LayoutHints, []tomo.Box, int) int { + return 0 +}