2023-01-12 10:51:42 -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"
|
2023-03-15 23:14:39 -06:00
|
|
|
import _ "git.tebibyte.media/sashakoshka/tomo/backends/all"
|
2023-01-12 10:51:42 -07:00
|
|
|
|
|
|
|
func main () {
|
|
|
|
tomo.Run(run)
|
|
|
|
}
|
|
|
|
|
|
|
|
func run () {
|
2023-04-10 00:58:52 -06:00
|
|
|
window, err := tomo.NewWindow(tomo.Bounds(0, 0, 0, 0))
|
|
|
|
if err != nil { panic(err.Error()) }
|
2023-01-12 10:51:42 -07:00
|
|
|
window.SetTitle("Dialog Boxes")
|
|
|
|
|
2023-04-16 15:30:13 -06:00
|
|
|
container := elements.NewVBox(true, true)
|
2023-01-12 10:51:42 -07:00
|
|
|
window.Adopt(container)
|
|
|
|
|
2023-03-30 21:19:04 -06:00
|
|
|
container.Adopt(elements.NewLabel("Try out different dialogs:", false), true)
|
2023-01-12 10:51:42 -07:00
|
|
|
|
2023-03-30 21:19:04 -06:00
|
|
|
infoButton := elements.NewButton("popups.DialogKindInfo")
|
2023-01-12 10:51:42 -07:00
|
|
|
infoButton.OnClick (func () {
|
|
|
|
popups.NewDialog (
|
|
|
|
popups.DialogKindInfo,
|
2023-03-23 22:47:04 -06:00
|
|
|
window,
|
2023-01-12 10:51:42 -07:00
|
|
|
"Information",
|
|
|
|
"You are wacky")
|
|
|
|
})
|
|
|
|
container.Adopt(infoButton, false)
|
2023-01-30 15:25:09 -07:00
|
|
|
infoButton.Focus()
|
2023-01-12 10:51:42 -07:00
|
|
|
|
2023-03-30 21:19:04 -06:00
|
|
|
questionButton := elements.NewButton("popups.DialogKindQuestion")
|
2023-01-12 10:51:42 -07:00
|
|
|
questionButton.OnClick (func () {
|
|
|
|
popups.NewDialog (
|
|
|
|
popups.DialogKindQuestion,
|
2023-03-23 22:47:04 -06:00
|
|
|
window,
|
2023-01-12 10:51:42 -07: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-30 21:19:04 -06:00
|
|
|
warningButton := elements.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-03-23 22:47:04 -06:00
|
|
|
window,
|
2023-01-12 10:51:42 -07:00
|
|
|
"Warning",
|
|
|
|
"They are fast approaching.")
|
|
|
|
})
|
|
|
|
container.Adopt(warningButton, false)
|
|
|
|
|
2023-03-30 21:19:04 -06:00
|
|
|
errorButton := elements.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-03-23 22:47:04 -06:00
|
|
|
window,
|
2023-01-12 10:51:42 -07:00
|
|
|
"Error",
|
|
|
|
"There is nowhere left to go.")
|
|
|
|
})
|
|
|
|
container.Adopt(errorButton, false)
|
|
|
|
|
2023-04-10 14:47:03 -06:00
|
|
|
menuButton := elements.NewButton("menu")
|
|
|
|
menuButton.OnClick (func () {
|
2023-04-15 20:23:08 -06:00
|
|
|
// TODO: make a better way to get the bounds of something
|
2023-04-10 14:47:03 -06:00
|
|
|
menu, err := window.NewMenu (
|
|
|
|
tomo.Bounds(0, 0, 64, 64).
|
2023-04-15 20:23:08 -06:00
|
|
|
Add(menuButton.Entity().Bounds().Min))
|
2023-04-10 14:47:03 -06:00
|
|
|
if err != nil { println(err.Error()) }
|
|
|
|
menu.Adopt(elements.NewLabel("I'm a shy window...", true))
|
|
|
|
menu.Show()
|
|
|
|
})
|
|
|
|
container.Adopt(menuButton, false)
|
|
|
|
|
2023-03-30 21:19:04 -06:00
|
|
|
cancelButton := elements.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()
|
|
|
|
}
|