2023-01-12 17:51:42 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import "git.tebibyte.media/sashakoshka/tomo"
|
|
|
|
import "git.tebibyte.media/sashakoshka/tomo/popups"
|
2023-03-31 03:19:04 +00:00
|
|
|
import "git.tebibyte.media/sashakoshka/tomo/layouts"
|
|
|
|
import "git.tebibyte.media/sashakoshka/tomo/elements"
|
2023-03-16 05:14:39 +00:00
|
|
|
import _ "git.tebibyte.media/sashakoshka/tomo/backends/all"
|
2023-03-16 18:22:56 +00:00
|
|
|
import "git.tebibyte.media/sashakoshka/tomo/elements/containers"
|
2023-01-12 17:51:42 +00:00
|
|
|
|
|
|
|
func main () {
|
|
|
|
tomo.Run(run)
|
|
|
|
}
|
|
|
|
|
|
|
|
func run () {
|
2023-04-10 06:58:52 +00:00
|
|
|
window, err := tomo.NewWindow(tomo.Bounds(0, 0, 0, 0))
|
|
|
|
if err != nil { panic(err.Error()) }
|
2023-01-12 17:51:42 +00:00
|
|
|
window.SetTitle("Dialog Boxes")
|
|
|
|
|
2023-03-31 03:19:04 +00:00
|
|
|
container := containers.NewContainer(layouts.Vertical { true, true })
|
2023-01-12 17:51:42 +00:00
|
|
|
window.Adopt(container)
|
|
|
|
|
2023-03-31 03:19:04 +00:00
|
|
|
container.Adopt(elements.NewLabel("Try out different dialogs:", false), true)
|
2023-01-12 17:51:42 +00:00
|
|
|
|
2023-03-31 03:19:04 +00:00
|
|
|
infoButton := elements.NewButton("popups.DialogKindInfo")
|
2023-01-12 17:51:42 +00:00
|
|
|
infoButton.OnClick (func () {
|
|
|
|
popups.NewDialog (
|
|
|
|
popups.DialogKindInfo,
|
2023-03-24 04:47:04 +00:00
|
|
|
window,
|
2023-01-12 17:51:42 +00:00
|
|
|
"Information",
|
|
|
|
"You are wacky")
|
|
|
|
})
|
|
|
|
container.Adopt(infoButton, false)
|
2023-01-30 22:25:09 +00:00
|
|
|
infoButton.Focus()
|
2023-01-12 17:51:42 +00:00
|
|
|
|
2023-03-31 03:19:04 +00:00
|
|
|
questionButton := elements.NewButton("popups.DialogKindQuestion")
|
2023-01-12 17:51:42 +00:00
|
|
|
questionButton.OnClick (func () {
|
|
|
|
popups.NewDialog (
|
|
|
|
popups.DialogKindQuestion,
|
2023-03-24 04:47:04 +00:00
|
|
|
window,
|
2023-01-12 17:51:42 +00:00
|
|
|
"The Big Question",
|
|
|
|
"Are you real?",
|
|
|
|
popups.Button { "Yes", func () { } },
|
|
|
|
popups.Button { "No", func () { } },
|
|
|
|
popups.Button { "Not sure", func () { } })
|
|
|
|
})
|
|
|
|
container.Adopt(questionButton, false)
|
|
|
|
|
2023-03-31 03:19:04 +00:00
|
|
|
warningButton := elements.NewButton("popups.DialogKindWarning")
|
2023-01-12 17:51:42 +00:00
|
|
|
warningButton.OnClick (func () {
|
|
|
|
popups.NewDialog (
|
2023-02-21 21:48:56 +00:00
|
|
|
popups.DialogKindWarning,
|
2023-03-24 04:47:04 +00:00
|
|
|
window,
|
2023-01-12 17:51:42 +00:00
|
|
|
"Warning",
|
|
|
|
"They are fast approaching.")
|
|
|
|
})
|
|
|
|
container.Adopt(warningButton, false)
|
|
|
|
|
2023-03-31 03:19:04 +00:00
|
|
|
errorButton := elements.NewButton("popups.DialogKindError")
|
2023-01-12 17:51:42 +00:00
|
|
|
errorButton.OnClick (func () {
|
|
|
|
popups.NewDialog (
|
2023-02-21 21:48:56 +00:00
|
|
|
popups.DialogKindError,
|
2023-03-24 04:47:04 +00:00
|
|
|
window,
|
2023-01-12 17:51:42 +00:00
|
|
|
"Error",
|
|
|
|
"There is nowhere left to go.")
|
|
|
|
})
|
|
|
|
container.Adopt(errorButton, false)
|
|
|
|
|
2023-03-31 03:19:04 +00:00
|
|
|
cancelButton := elements.NewButton("No thank you.")
|
2023-01-12 17:51:42 +00:00
|
|
|
cancelButton.OnClick(tomo.Stop)
|
|
|
|
container.Adopt(cancelButton, false)
|
|
|
|
|
|
|
|
window.OnClose(tomo.Stop)
|
|
|
|
window.Show()
|
|
|
|
}
|