Re-organized module structure

This commit is contained in:
2023-03-30 23:19:04 -04:00
parent 719b7b99ac
commit 53bfc8df68
62 changed files with 458 additions and 532 deletions

View File

@@ -2,9 +2,8 @@ package popups
import "git.tebibyte.media/sashakoshka/tomo"
import "git.tebibyte.media/sashakoshka/tomo/theme"
import "git.tebibyte.media/sashakoshka/tomo/layouts"
import "git.tebibyte.media/sashakoshka/tomo/elements"
import "git.tebibyte.media/sashakoshka/tomo/layouts/basic"
import "git.tebibyte.media/sashakoshka/tomo/elements/basic"
import "git.tebibyte.media/sashakoshka/tomo/elements/containers"
// DialogKind defines the semantic role of a dialog window.
@@ -31,11 +30,11 @@ type Button struct {
// the dialog will just be a normal window
func NewDialog (
kind DialogKind,
parent elements.Window,
parent tomo.Window,
title, message string,
buttons ...Button,
) (
window elements.Window,
window tomo.Window,
) {
if parent == nil {
window, _ = tomo.NewWindow(2, 2)
@@ -44,10 +43,10 @@ func NewDialog (
}
window.SetTitle(title)
container := containers.NewContainer(basicLayouts.Dialog { true, true })
container := containers.NewContainer(layouts.Dialog { true, true })
window.Adopt(container)
messageContainer := containers.NewContainer(basicLayouts.Horizontal { true, false })
messageContainer := containers.NewContainer(layouts.Horizontal { true, false })
iconId := theme.IconInformation
switch kind {
case DialogKindInfo: iconId = theme.IconInformation
@@ -56,20 +55,20 @@ func NewDialog (
case DialogKindError: iconId = theme.IconError
}
messageContainer.Adopt(basicElements.NewIcon(iconId, theme.IconSizeLarge), false)
messageContainer.Adopt(basicElements.NewLabel(message, false), true)
messageContainer.Adopt(elements.NewIcon(iconId, theme.IconSizeLarge), false)
messageContainer.Adopt(elements.NewLabel(message, false), true)
container.Adopt(messageContainer, true)
if len(buttons) == 0 {
button := basicElements.NewButton("OK")
button := elements.NewButton("OK")
button.SetIcon(theme.IconYes)
button.OnClick(window.Close)
container.Adopt(button, false)
button.Focus()
} else {
var button *basicElements.Button
var button *elements.Button
for _, buttonDescriptor := range buttons {
button = basicElements.NewButton(buttonDescriptor.Name)
button = elements.NewButton(buttonDescriptor.Name)
button.SetEnabled(buttonDescriptor.OnPress != nil)
button.OnClick (func () {
buttonDescriptor.OnPress()