2023-01-24 14:41:12 -07:00
|
|
|
package main
|
|
|
|
|
|
|
|
import "git.tebibyte.media/sashakoshka/tomo"
|
|
|
|
import "git.tebibyte.media/sashakoshka/tomo/popups"
|
2023-03-30 21:19:04 -06:00
|
|
|
import "git.tebibyte.media/sashakoshka/tomo/layouts"
|
2023-02-01 23:48:16 -07:00
|
|
|
import "git.tebibyte.media/sashakoshka/tomo/elements"
|
2023-01-24 14:41:12 -07:00
|
|
|
import "git.tebibyte.media/sashakoshka/tomo/elements/testing"
|
2023-03-16 12:22:56 -06:00
|
|
|
import "git.tebibyte.media/sashakoshka/tomo/elements/containers"
|
2023-03-15 23:14:39 -06:00
|
|
|
import _ "git.tebibyte.media/sashakoshka/tomo/backends/all"
|
2023-01-24 14:41:12 -07:00
|
|
|
|
|
|
|
func main () {
|
|
|
|
tomo.Run(run)
|
|
|
|
}
|
|
|
|
|
|
|
|
func run () {
|
2023-04-10 00:58:52 -06:00
|
|
|
window, _ := tomo.NewWindow(tomo.Bounds(0, 0, 300, 0))
|
2023-01-24 14:41:12 -07:00
|
|
|
window.SetTitle("List Sidebar")
|
|
|
|
|
2023-03-30 21:19:04 -06:00
|
|
|
container := containers.NewContainer(layouts.Horizontal { true, true })
|
2023-01-24 14:41:12 -07:00
|
|
|
window.Adopt(container)
|
|
|
|
|
2023-03-30 21:19:04 -06:00
|
|
|
var currentPage tomo.Element
|
|
|
|
turnPage := func (newPage tomo.Element) {
|
2023-01-24 14:41:12 -07:00
|
|
|
container.Warp (func () {
|
|
|
|
if currentPage != nil {
|
|
|
|
container.Disown(currentPage)
|
|
|
|
}
|
|
|
|
container.Adopt(newPage, true)
|
|
|
|
currentPage = newPage
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2023-03-30 21:19:04 -06:00
|
|
|
intro := elements.NewLabel (
|
2023-01-26 10:05:28 -07:00
|
|
|
"The List element can be easily used as a sidebar. " +
|
|
|
|
"Click on entries to flip pages!", true)
|
2023-03-30 21:19:04 -06:00
|
|
|
button := elements.NewButton("I do nothing!")
|
2023-01-24 14:41:12 -07:00
|
|
|
button.OnClick (func () {
|
2023-03-30 21:19:04 -06:00
|
|
|
popups.NewDialog(popups.DialogKindInfo, window, "", "Sike!")
|
2023-01-24 14:41:12 -07:00
|
|
|
})
|
|
|
|
mouse := testing.NewMouse()
|
2023-03-30 21:19:04 -06:00
|
|
|
input := elements.NewTextBox("Write some text", "")
|
|
|
|
form := containers.NewContainer(layouts.Vertical { true, false})
|
|
|
|
form.Adopt(elements.NewLabel("I have:", false), false)
|
|
|
|
form.Adopt(elements.NewSpacer(true), false)
|
|
|
|
form.Adopt(elements.NewCheckbox("Skin", true), false)
|
|
|
|
form.Adopt(elements.NewCheckbox("Blood", false), false)
|
|
|
|
form.Adopt(elements.NewCheckbox("Bone", false), false)
|
2023-02-16 12:57:46 -07:00
|
|
|
art := testing.NewArtist()
|
2023-01-24 14:41:12 -07:00
|
|
|
|
2023-03-30 21:19:04 -06:00
|
|
|
list := elements.NewList (
|
|
|
|
elements.NewListEntry("button", func () { turnPage(button) }),
|
|
|
|
elements.NewListEntry("mouse", func () { turnPage(mouse) }),
|
|
|
|
elements.NewListEntry("input", func () { turnPage(input) }),
|
|
|
|
elements.NewListEntry("form", func () { turnPage(form) }),
|
|
|
|
elements.NewListEntry("art", func () { turnPage(art) }))
|
2023-01-26 10:05:28 -07:00
|
|
|
list.OnNoEntrySelected(func () { turnPage (intro) })
|
2023-01-24 14:41:12 -07:00
|
|
|
list.Collapse(96, 0)
|
|
|
|
|
|
|
|
container.Adopt(list, false)
|
2023-01-26 10:05:28 -07:00
|
|
|
turnPage(intro)
|
2023-01-24 14:41:12 -07:00
|
|
|
|
|
|
|
window.OnClose(tomo.Stop)
|
|
|
|
window.Show()
|
|
|
|
}
|