This repository has been archived on 2023-08-08. You can view files and clone it, but cannot push or open issues or pull requests.
tomo-old/examples/checkbox/main.go

53 lines
1.6 KiB
Go
Raw Normal View History

2023-01-17 14:38:57 -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/elements"
import "git.tebibyte.media/sashakoshka/tomo/elements/containers"
import _ "git.tebibyte.media/sashakoshka/tomo/backends/all"
2023-01-17 14:38:57 -07:00
func main () {
tomo.Run(run)
}
func run () {
window, _ := tomo.NewWindow(tomo.Bounds(0, 0, 0, 0))
2023-01-17 14:38:57 -07:00
window.SetTitle("Checkboxes")
container := containers.NewVBox(true, true)
2023-01-17 14:38:57 -07:00
window.Adopt(container)
2023-03-30 21:19:04 -06:00
introText := elements.NewLabel (
2023-01-17 14:46:07 -07:00
"We advise you to not read thPlease listen to me. I am " +
"trapped inside the example code. This is the only way for " +
2023-03-16 23:00:11 -06:00
"me to communicate.", true)
introText.EmCollapse(0, 5)
container.Adopt(introText, true)
2023-03-30 21:19:04 -06:00
container.Adopt(elements.NewSpacer(true), false)
container.Adopt(elements.NewCheckbox("Oh god", false), false)
container.Adopt(elements.NewCheckbox("Can you hear them", true), false)
container.Adopt(elements.NewCheckbox("They are in the walls", false), false)
container.Adopt(elements.NewCheckbox("They are coming for us", false), false)
disabledCheckbox := elements.NewCheckbox("We are but their helpless prey", false)
2023-01-17 14:38:57 -07:00
disabledCheckbox.SetEnabled(false)
container.Adopt(disabledCheckbox, false)
2023-03-30 21:19:04 -06:00
vsync := elements.NewCheckbox("Enable vsync", false)
vsync.OnToggle (func () {
2023-01-17 14:46:07 -07:00
if vsync.Value() {
// popups.NewDialog (
// popups.DialogKindInfo,
// window,
// "Ha!",
// "That doesn't do anything.")
2023-01-17 14:46:07 -07:00
}
})
container.Adopt(vsync, false)
2023-03-30 21:19:04 -06:00
button := elements.NewButton("What")
2023-01-17 14:38:57 -07:00
button.OnClick(tomo.Stop)
container.Adopt(button, false)
button.Focus()
2023-01-17 14:38:57 -07:00
window.OnClose(tomo.Stop)
window.Show()
}