Popups package uses the new modal system

This commit is contained in:
Sasha Koshka 2023-03-24 00:47:04 -04:00
parent d710d13f0d
commit a2c0ff5f4c
2 changed files with 12 additions and 2 deletions

View File

@ -24,6 +24,7 @@ func run () {
infoButton.OnClick (func () {
popups.NewDialog (
popups.DialogKindInfo,
window,
"Information",
"You are wacky")
})
@ -34,6 +35,7 @@ func run () {
questionButton.OnClick (func () {
popups.NewDialog (
popups.DialogKindQuestion,
window,
"The Big Question",
"Are you real?",
popups.Button { "Yes", func () { } },
@ -46,6 +48,7 @@ func run () {
warningButton.OnClick (func () {
popups.NewDialog (
popups.DialogKindWarning,
window,
"Warning",
"They are fast approaching.")
})
@ -55,6 +58,7 @@ func run () {
errorButton.OnClick (func () {
popups.NewDialog (
popups.DialogKindError,
window,
"Error",
"There is nowhere left to go.")
})

View File

@ -27,15 +27,21 @@ type Button struct {
OnPress func ()
}
// NewDialog creates a new dialog window and returns it.
// NewDialog creates a new modal dialog window and returns it. If parent is nil,
// the dialog will just be a normal window
func NewDialog (
kind DialogKind,
parent elements.Window,
title, message string,
buttons ...Button,
) (
window elements.Window,
) {
window, _ = tomo.NewWindow(2, 2)
if parent == nil {
window, _ = tomo.NewWindow(2, 2)
} else {
window, _ = parent.NewModal(2, 2)
}
window.SetTitle(title)
container := containers.NewContainer(basicLayouts.Dialog { true, true })