etui/widgets/notification
Types
Which screen corner to render notifications in.
pub type Corner {
TopRight
TopLeft
BottomRight
BottomLeft
}
Constructors
-
TopRight -
TopLeft -
BottomRight -
BottomLeft
Notification severity level.
pub type Level {
Info
Success
Warning
Error
}
Constructors
-
Info -
Success -
Warning -
Error
Active notification queue.
pub type NotificationQueue {
NotificationQueue(
items: List(Notification),
max: Int,
corner: Corner,
)
}
Constructors
-
NotificationQueue( items: List(Notification), max: Int, corner: Corner, )Arguments
- max
-
Maximum simultaneous notifications shown (oldest dropped first).
- corner
-
Corner to stack notifications in.
Values
pub fn dismiss_all(q: NotificationQueue) -> NotificationQueue
Dismiss all notifications.
pub fn dismiss_first(q: NotificationQueue) -> NotificationQueue
Dismiss the oldest notification.
pub fn dismiss_level(
q: NotificationQueue,
level: Level,
) -> NotificationQueue
Dismiss all notifications matching level.
pub fn error(message: String, ttl ttl: Int) -> Notification
Build an Error notification (persistent by default: ttl = -1).
pub fn has_notifications(q: NotificationQueue) -> Bool
True if there are active notifications.
pub fn persistent(message: String, level: Level) -> Notification
Persistent notification (never auto-expires; dismiss manually).
pub fn push(
q: NotificationQueue,
n: Notification,
) -> NotificationQueue
Add a notification. If queue is full, the oldest is dropped.
pub fn queue_new(max max: Int) -> NotificationQueue
New empty queue. Max = 5, corner = BottomRight.
pub fn render(
buf: buffer.Buffer,
area: geometry.Rect,
q: NotificationQueue,
) -> buffer.Buffer
Render all active notifications stacked in the configured corner. Each notification is a single-row bordered box; they stack inward.
pub fn success(message: String, ttl ttl: Int) -> Notification
Build a Success notification.
pub fn tick(q: NotificationQueue) -> NotificationQueue
Advance time by one tick. Decrements TTL on all non-persistent notifications and removes expired ones (ttl == 0).
pub fn warning(message: String, ttl ttl: Int) -> Notification
Build a Warning notification.
pub fn with_corner(
q: NotificationQueue,
corner: Corner,
) -> NotificationQueue
Set which corner to stack notifications.