2023-01-24 14:41:12 -07:00
|
|
|
package main
|
|
|
|
|
|
|
|
import "git.tebibyte.media/sashakoshka/tomo"
|
|
|
|
import "git.tebibyte.media/sashakoshka/tomo/popups"
|
2023-02-01 23:48:16 -07:00
|
|
|
import "git.tebibyte.media/sashakoshka/tomo/elements"
|
|
|
|
import "git.tebibyte.media/sashakoshka/tomo/layouts/basic"
|
2023-01-24 14:41:12 -07:00
|
|
|
import "git.tebibyte.media/sashakoshka/tomo/elements/basic"
|
|
|
|
import "git.tebibyte.media/sashakoshka/tomo/elements/testing"
|
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 () {
|
|
|
|
window, _ := tomo.NewWindow(300, 2)
|
|
|
|
window.SetTitle("List Sidebar")
|
|
|
|
|
2023-02-01 23:48:16 -07:00
|
|
|
container := basicElements.NewContainer(basicLayouts.Horizontal { true, true })
|
2023-01-24 14:41:12 -07:00
|
|
|
window.Adopt(container)
|
|
|
|
|
2023-02-01 23:48:16 -07:00
|
|
|
var currentPage elements.Element
|
|
|
|
turnPage := func (newPage elements.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-02-01 23:48:16 -07:00
|
|
|
intro := basicElements.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-02-01 23:48:16 -07:00
|
|
|
button := basicElements.NewButton("I do nothing!")
|
2023-01-24 14:41:12 -07:00
|
|
|
button.OnClick (func () {
|
|
|
|
popups.NewDialog(popups.DialogKindInfo, "", "Sike!")
|
|
|
|
})
|
|
|
|
mouse := testing.NewMouse()
|
2023-02-16 12:39:51 -07:00
|
|
|
input := basicElements.NewTextBox("Write some text", "")
|
2023-02-01 23:48:16 -07:00
|
|
|
form := basicElements.NewContainer(basicLayouts.Vertical { true, false})
|
|
|
|
form.Adopt(basicElements.NewLabel("I have:", false), false)
|
|
|
|
form.Adopt(basicElements.NewSpacer(true), false)
|
|
|
|
form.Adopt(basicElements.NewCheckbox("Skin", true), false)
|
|
|
|
form.Adopt(basicElements.NewCheckbox("Blood", false), false)
|
|
|
|
form.Adopt(basicElements.NewCheckbox("Bone", false), false)
|
2023-02-16 12:57:46 -07:00
|
|
|
art := testing.NewArtist()
|
2023-01-24 14:41:12 -07:00
|
|
|
|
2023-02-01 23:48:16 -07:00
|
|
|
list := basicElements.NewList (
|
|
|
|
basicElements.NewListEntry("button", func () { turnPage(button) }),
|
|
|
|
basicElements.NewListEntry("mouse", func () { turnPage(mouse) }),
|
|
|
|
basicElements.NewListEntry("input", func () { turnPage(input) }),
|
2023-02-16 12:57:46 -07:00
|
|
|
basicElements.NewListEntry("form", func () { turnPage(form) }),
|
|
|
|
basicElements.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()
|
|
|
|
}
|