Checkboxes!

This commit is contained in:
Sasha Koshka
2023-01-17 16:38:57 -05:00
parent 37458f4fde
commit 5d64788b68
4 changed files with 299 additions and 50 deletions

34
examples/checkbox/main.go Normal file
View File

@@ -0,0 +1,34 @@
package main
import "git.tebibyte.media/sashakoshka/tomo"
import "git.tebibyte.media/sashakoshka/tomo/layouts"
import "git.tebibyte.media/sashakoshka/tomo/elements/basic"
import _ "git.tebibyte.media/sashakoshka/tomo/backends/x"
func main () {
tomo.Run(run)
}
func run () {
window, _ := tomo.NewWindow(2, 2)
window.SetTitle("Checkboxes")
container := basic.NewContainer(layouts.Vertical { true, true })
window.Adopt(container)
container.Adopt(basic.NewCheckbox("Oh god", false), false)
container.Adopt(basic.NewCheckbox("Can you hear them", true), false)
container.Adopt(basic.NewCheckbox("They are in the walls", false), false)
container.Adopt(basic.NewCheckbox("They are coming for us", false), false)
disabledCheckbox := basic.NewCheckbox("We are but their helpless prey", false)
disabledCheckbox.SetEnabled(false)
container.Adopt(disabledCheckbox, false)
container.Adopt(basic.NewCheckbox("Enable vsync", true), false)
button := basic.NewButton("What")
button.OnClick(tomo.Stop)
container.Adopt(button, false)
button.Select()
window.OnClose(tomo.Stop)
window.Show()
}