erm/app/darktile/gui/popups.go

31 lines
762 B
Go
Raw Normal View History

2021-07-30 22:29:20 +00:00
package gui
import (
"fmt"
"image/color"
"time"
2023-01-16 02:11:07 +00:00
"tuxpa.in/t/erm/app/darktile/gui/popup"
2021-07-30 22:29:20 +00:00
)
const (
popupMessageDisplayDuration = time.Second * 5
popupErrorDisplayDuration = time.Second * 10
)
func (g *GUI) ShowPopup(msg string, fg color.Color, bg color.Color, duration time.Duration) {
g.popupMessages = append(g.popupMessages, popup.Message{
2021-07-30 22:29:20 +00:00
Text: msg,
Expiry: time.Now().Add(duration),
Foreground: fg,
Background: bg,
})
}
func (g *GUI) ShowError(msg string) {
g.ShowPopup(fmt.Sprintf("Error!\n%s", msg), color.White, color.RGBA{A: 0xff, R: 0xff}, popupErrorDisplayDuration)
}
func (g *GUI) ShowMessage(msg string) {
g.ShowPopup(msg, color.White, color.RGBA{A: 0xff, G: 0x40, R: 0x40, B: 0xff}, popupMessageDisplayDuration)
}