notifications

package
v0.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 28, 2019 License: GPL-3.0 Imports: 4 Imported by: 10

Documentation

Overview

Package notifications exposes functions to display messages in toast widgets.

Index

Constants

View Source
const Medium float32 = 4

Medium is the standard duration for a notification

Variables

This section is empty.

Functions

func Clear

func Clear()

Clear empties the notification list

func Display

func Display(severity Severity, message string, duration float32) xid.ID

Display creates a new notification.

func DisplayAndLog

func DisplayAndLog(severity Severity, prefix, message string, vars ...interface{}) xid.ID

DisplayAndLog creates a new notification and also logs the message to stdout.

func Process

func Process(dt float32)

Process iterates over the notifications, update them, delete the old ones.

func Update

func Update(id xid.ID, severity Severity, message string)

Update the message of a given notification. Also resets the delay before disapearing.

Types

type Notification

type Notification struct {
	ID       xid.ID
	Severity Severity
	Message  string
	Duration float32
}

Notification is a message that will be displayed on the screen during a certain time.

func List

func List() []Notification

List lists the current notifications.

type Severity added in v0.2.8

type Severity uint8

Severity represents the severity of a notification message. It will affect the color of the notification text in the UI.

const (
	// Info is for informative message, when everything is fine
	Info Severity = iota
	// Success is for successful actions
	Success
	// Warning is also for informative messages, when something is not right
	// for example, if a menu entry has not been implemented.
	Warning
	// Error is for failed actions. For example, trying to load a game that
	// doesn't exists.
	Error
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL