Toast
toast · Overlays · interactive
Short-lived messages, stacked in a corner and gone on their own.
Import
cpp
#include "gbui/widgets/toast.hpp"Example
cpp
ToastResult toast(Ui& ui, const Interaction& input, ToastState& state, float delta, const ToastOptions& options = {});Draws the stack and advances its timers. delta is the frame's own seconds. Called once per outlet, near the end of the frame — it draws on the overlay layer, so where it sits in the tree decides nothing about where it appears, but building it last keeps it above anything that shares that layer. It never takes the keyboard. A message that stole focus would interrupt whatever the reader was typing, and the live region is what delivers it instead; only the × and the action are Tab stops, and only while they exist.
API
ToastOptions
| Option | Type | Default | What it does |
|---|---|---|---|
placement | ToastPlacementTopLeft · TopCenter · TopRight · BottomLeft · BottomCenter · BottomRight · Anchored | ToastPlacement::TopRight | Which corner, edge or anchor the stack sits against. Which way it grows follows from it and is not a second decision. |
group | std::string_view | Which entries this outlet shows. Empty shows the ungrouped ones. | |
anchorId | std::string_view | The tag ToastPlacement::Anchored measures against. | |
bounds | Rect | The rectangle the corners are measured from. Empty is the window. What lets a stack live inside a panel rather than over the whole screen — a docked tool reporting into its own pane rather than across the application it is embedded in. | |
progress | bool | true | A bar draining across the foot of each toast, showing the time left. Drawn only where there is a time left: a toast with no duration has nothing to count down and gets none. |
maxVisible | std::size_t | 4 | How many are on screen at once. The rest wait their turn, which is better than a stack taller than the window. |
width | float | 340.0f | |
gap | float | 8.0f | Between two toasts in the stack. |
margin | float | 16.0f | Between the stack and the edge it is anchored to. |
name | std::string_view | "Notifications" | What the region is called. A reader arriving at it out of context is otherwise told only that something changed. |