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/popups/main.go

69 lines
1.8 KiB
Go
Raw Normal View History

2023-01-12 10:51:42 -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/layouts/basic"
2023-01-12 10:51:42 -07:00
import "git.tebibyte.media/sashakoshka/tomo/elements/basic"
import _ "git.tebibyte.media/sashakoshka/tomo/backends/all"
2023-01-12 10:51:42 -07:00
func main () {
tomo.Run(run)
}
func run () {
window, _ := tomo.NewWindow(2, 2)
window.SetTitle("Dialog Boxes")
2023-02-01 23:48:16 -07:00
container := basicElements.NewContainer(basicLayouts.Vertical { true, true })
2023-01-12 10:51:42 -07:00
window.Adopt(container)
2023-02-01 23:48:16 -07:00
container.Adopt(basicElements.NewLabel("Try out different dialogs:", false), true)
2023-01-12 10:51:42 -07:00
2023-02-01 23:48:16 -07:00
infoButton := basicElements.NewButton("popups.DialogKindInfo")
2023-01-12 10:51:42 -07:00
infoButton.OnClick (func () {
popups.NewDialog (
popups.DialogKindInfo,
"Information",
"You are wacky")
})
container.Adopt(infoButton, false)
infoButton.Focus()
2023-01-12 10:51:42 -07:00
2023-02-01 23:48:16 -07:00
questionButton := basicElements.NewButton("popups.DialogKindQuestion")
2023-01-12 10:51:42 -07:00
questionButton.OnClick (func () {
popups.NewDialog (
popups.DialogKindQuestion,
"The Big Question",
"Are you real?",
popups.Button { "Yes", func () { } },
popups.Button { "No", func () { } },
popups.Button { "Not sure", func () { } })
})
container.Adopt(questionButton, false)
2023-02-01 23:48:16 -07:00
warningButton := basicElements.NewButton("popups.DialogKindWarning")
2023-01-12 10:51:42 -07:00
warningButton.OnClick (func () {
popups.NewDialog (
2023-02-21 14:48:56 -07:00
popups.DialogKindWarning,
2023-01-12 10:51:42 -07:00
"Warning",
"They are fast approaching.")
})
container.Adopt(warningButton, false)
2023-02-01 23:48:16 -07:00
errorButton := basicElements.NewButton("popups.DialogKindError")
2023-01-12 10:51:42 -07:00
errorButton.OnClick (func () {
popups.NewDialog (
2023-02-21 14:48:56 -07:00
popups.DialogKindError,
2023-01-12 10:51:42 -07:00
"Error",
"There is nowhere left to go.")
})
container.Adopt(errorButton, false)
2023-02-01 23:48:16 -07:00
cancelButton := basicElements.NewButton("No thank you.")
2023-01-12 10:51:42 -07:00
cancelButton.OnClick(tomo.Stop)
container.Adopt(cancelButton, false)
window.OnClose(tomo.Stop)
window.Show()
}