diff --git a/elements/basic/container.go b/elements/basic/container.go index 0f4ff6e..6728f31 100644 --- a/elements/basic/container.go +++ b/elements/basic/container.go @@ -71,7 +71,7 @@ func (element *Container) Adopt (child elements.Element, expand bool) { element.core.DamageAll() }) if child0, ok := child.(elements.Flexible); ok { - child0.OnFlexibleHeightChange(element.updateMinimumSize) + child0.OnFlexibleHeightChange(element.notifyFlexibleChange) } if child0, ok := child.(elements.Focusable); ok { child0.OnFocusRequest (func () (granted bool) { @@ -323,14 +323,15 @@ func (element *Container) updateMinimumSize () { padding := element.theme.Padding(theme.PatternBackground) width, height := element.layout.MinimumSize ( element.children, margin, padding) - if element.flexible { - height = element.layout.FlexibleHeightFor ( - element.children, margin, - padding, width) - } element.core.SetMinimumSize(width, height) } +func (element *Container) notifyFlexibleChange () { + if element.onFlexibleHeightChange != nil { + element.onFlexibleHeightChange() + } +} + func (element *Container) doLayout () { margin := element.theme.Margin(theme.PatternBackground) padding := element.theme.Padding(theme.PatternBackground) diff --git a/examples/scroll/main.go b/examples/scroll/main.go index ae97064..04e0fdf 100644 --- a/examples/scroll/main.go +++ b/examples/scroll/main.go @@ -16,7 +16,6 @@ func run () { container := basicElements.NewContainer(basicLayouts.Vertical { true, true }) window.Adopt(container) - textBox := basicElements.NewTextBox("", copypasta) scrollContainer := basicElements.NewScrollContainer(true, false) @@ -56,8 +55,8 @@ func run () { list.ScrollTo(viewport) }) - container.Adopt(basicElements.NewLabel("A ScrollContainer:", false), false) scrollContainer.Adopt(textBox) + container.Adopt(basicElements.NewLabel("A ScrollContainer:", false), false) container.Adopt(scrollContainer, false) disconnectedContainer.Adopt(list, false) disconnectedContainer.Adopt (basicElements.NewLabel (