Oh yeah yeah!

This commit is contained in:
Sasha Koshka 2023-04-18 03:23:51 -04:00
parent 6276327613
commit a2b1ac0c73
3 changed files with 32 additions and 23 deletions

View File

@ -58,6 +58,10 @@ func (element *List) Draw (destination canvas.Canvas) {
}
func (element *List) Layout () {
if element.scroll.Y > element.maxScrollHeight() {
element.scroll.Y = element.maxScrollHeight()
}
margin := element.theme.Margin(tomo.PatternSunken)
padding := element.theme.Padding(tomo.PatternSunken)
bounds := padding.Apply(element.entity.Bounds())

View File

@ -198,7 +198,10 @@ func (element *Scroll) updateMinimumSize () {
}
func (element *Scroll) updateEnabled () {
horizontal, vertical := element.child.ScrollAxes()
horizontal, vertical := false, false
if element.child != nil {
horizontal, vertical = element.child.ScrollAxes()
}
if element.horizontal != nil {
element.horizontal.SetEnabled(horizontal)
}

View File

@ -20,28 +20,30 @@ func run () {
disconnectedContainer := elements.NewHBox(false, true)
list := elements.NewList (
2,
elements.NewCell(elements.NewLabel("Item 0", false)),
elements.NewCell(elements.NewLabel("Item 1", false)),
elements.NewCell(elements.NewLabel("Item 2", false)),
elements.NewCell(elements.NewLabel("Item 3", false)),
elements.NewCell(elements.NewLabel("Item 4", false)),
elements.NewCell(elements.NewLabel("Item 5", false)),
elements.NewCell(elements.NewLabel("Item 6", false)),
elements.NewCell(elements.NewLabel("Item 7", false)),
elements.NewCell(elements.NewLabel("Item 8", false)),
elements.NewCell(elements.NewLabel("Item 9", false)),
elements.NewCell(elements.NewLabel("Item 10", false)),
elements.NewCell(elements.NewLabel("Item 11", false)),
elements.NewCell(elements.NewLabel("Item 12", false)),
elements.NewCell(elements.NewLabel("Item 13", false)),
elements.NewCell(elements.NewLabel("Item 14", false)),
elements.NewCell(elements.NewLabel("Item 15", false)),
elements.NewCell(elements.NewLabel("Item 16", false)),
elements.NewCell(elements.NewLabel("Item 17", false)),
elements.NewCell(elements.NewLabel("Item 18", false)),
elements.NewCell(elements.NewLabel("Item 19", false)),
elements.NewCell(elements.NewLabel("Item 20", false)),
elements.NewCell(elements.NewLabel("Item 21", false)))
elements.NewCell(elements.NewCheckbox("Item 0", true)),
elements.NewCell(elements.NewCheckbox("Item 1", false)),
elements.NewCell(elements.NewCheckbox("Item 2", false)),
elements.NewCell(elements.NewCheckbox("Item 3", true)),
elements.NewCell(elements.NewCheckbox("Item 4", false)),
elements.NewCell(elements.NewCheckbox("Item 5", false)),
elements.NewCell(elements.NewCheckbox("Item 6", false)),
elements.NewCell(elements.NewCheckbox("Item 7", true)),
elements.NewCell(elements.NewCheckbox("Item 8", true)),
elements.NewCell(elements.NewCheckbox("Item 9", false)),
elements.NewCell(elements.NewCheckbox("Item 10", false)),
elements.NewCell(elements.NewCheckbox("Item 11", true)),
elements.NewCell(elements.NewCheckbox("Item 12", false)),
elements.NewCell(elements.NewCheckbox("Item 13", true)),
elements.NewCell(elements.NewCheckbox("Item 14", false)),
elements.NewCell(elements.NewCheckbox("Item 15", false)),
elements.NewCell(elements.NewCheckbox("Item 16", true)),
elements.NewCell(elements.NewCheckbox("Item 17", true)),
elements.NewCell(elements.NewCheckbox("Item 18", false)),
elements.NewCell(elements.NewCheckbox("Item 19", false)),
elements.NewCell(elements.NewCheckbox("Item 20", true)),
elements.NewCell(elements.NewCheckbox("Item 21", false)),
elements.NewCell (elements.NewScroll (elements.NewTextBox (
"", "I bet you weren't expecting this!"), true, false)))
list.Collapse(0, 32)
scrollBar := elements.NewScrollBar(true)
list.OnScrollBoundsChange (func () {