From 11c747e2250e9e1f825e4116db8b569e22c6b889 Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Sat, 4 Mar 2023 23:09:46 -0500 Subject: [PATCH] Dialog boxes now have icons --- popups/dialog.go | 17 +++++++++++++++-- theme/theme.go | 4 ++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/popups/dialog.go b/popups/dialog.go index c8634d8..9235c11 100644 --- a/popups/dialog.go +++ b/popups/dialog.go @@ -1,6 +1,7 @@ package popups import "git.tebibyte.media/sashakoshka/tomo" +import "git.tebibyte.media/sashakoshka/tomo/theme" import "git.tebibyte.media/sashakoshka/tomo/elements" import "git.tebibyte.media/sashakoshka/tomo/layouts/basic" import "git.tebibyte.media/sashakoshka/tomo/elements/basic" @@ -35,11 +36,23 @@ func NewDialog ( ) { window, _ = tomo.NewWindow(2, 2) window.SetTitle(title) - + container := basicElements.NewContainer(basicLayouts.Dialog { true, true }) window.Adopt(container) - container.Adopt(basicElements.NewLabel(message, false), true) + messageContainer := basicElements.NewContainer(basicLayouts.Horizontal { true, false }) + iconId := theme.IconInformation + switch kind { + case DialogKindInfo: iconId = theme.IconInformation + case DialogKindQuestion: iconId = theme.IconQuestion + case DialogKindWarning: iconId = theme.IconWarning + case DialogKindError: iconId = theme.IconError + } + + messageContainer.Adopt(basicElements.NewIcon(iconId, theme.IconSizeSmall), false) + messageContainer.Adopt(basicElements.NewLabel(message, false), true) + container.Adopt(messageContainer, true) + if len(buttons) == 0 { button := basicElements.NewButton("OK") button.OnClick(window.Close) diff --git a/theme/theme.go b/theme/theme.go index 2db0276..277e8fe 100644 --- a/theme/theme.go +++ b/theme/theme.go @@ -132,7 +132,7 @@ const ( const ( // Action icons - IconOpen = iota + 0x100 + IconOpen Icon = iota + 0x100 IconSave IconSaveAs IconNew @@ -172,7 +172,7 @@ const ( const ( // Status icons - IconInformation = iota + 0x180 + IconInformation Icon = iota + 0x180 IconQuestion IconWarning IconError)