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

50 lines
1.5 KiB
Go
Raw Normal View History

2023-01-17 21:38:57 +00:00
package main
import "git.tebibyte.media/sashakoshka/tomo"
2023-01-17 21:46:07 +00:00
import "git.tebibyte.media/sashakoshka/tomo/popups"
2023-01-17 21:38:57 +00:00
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)
2023-01-17 21:46:07 +00:00
container.Adopt (basic.NewLabel (
"We advise you to not read thPlease listen to me. I am " +
"trapped inside the example code. This is the only way for " +
"me to communicate.", true), true)
2023-01-17 22:01:35 +00:00
container.Adopt(basic.NewSpacer(true), false)
2023-01-17 21:38:57 +00:00
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)
2023-01-17 21:46:07 +00:00
vsync := basic.NewCheckbox("Enable vsync", false)
vsync.OnToggle (func () {
2023-01-17 21:46:07 +00:00
if vsync.Value() {
popups.NewDialog (
popups.DialogKindInfo,
"Ha!",
"That doesn't do anything.")
}
})
container.Adopt(vsync, false)
2023-01-17 21:38:57 +00:00
button := basic.NewButton("What")
button.OnClick(tomo.Stop)
container.Adopt(button, false)
button.Focus()
2023-01-17 21:38:57 +00:00
window.OnClose(tomo.Stop)
window.Show()
}