Skip to main content

Module toast

Module toast 

Expand description

Transient notices and the notification card.

  • Transient and Notice keep a window’s transient message (a confirmation, something under way, a failure) for its lifetime and show it in the window’s bar (crate::window_toolbar::notify); no window paints a card for one.
  • ToastCard and paint_card paint the shell’s notification card, outside any window: the desktop’s notification banners and the lock screen’s.
  • ToastKind maps to Theme::tokens.colors.semantic.*.

Structs§

Dwell
How long a transient card has been up for someone to read, which is what its lifetime counts against. The clock runs only while the card is on screen and nobody holds it (the pointer on it, keyboard focus in it): a card that never fit on screen, or one being read, never runs out under the reader. The desktop’s notification banners keep it.
Notice
The one transient message an app shows in its window’s bar: a confirmation, something under way, or a failure. The app shows it and publishes it on every sync; the notice keeps its own lifetime (Transient), and the bar announces it.
SenderMark
The mark a notification leads with, on its banner and on its row in the notification centre: the sender’s own artwork when one arrived with it, else the glyph standing for what sent it. Both surfaces paint this one value, so an app’s row and its banner lead with the same picture.
ToastCard
Immediate-mode content for one notification / toast card, painted by paint_card. Built fluently: ToastCard::new("Slow network", ToastKind::Warning).body("retrying").
ToastCardHit
Geometry paint_card hands back so callers hit-test the card’s interactive regions against widget-owned rects (no bespoke maths).
Transient
A message an app shows over its content for a while. It is one of two kinds:

Enums§

ToastKind
Severity / category of a toast. Maps to the semantic color ramp in crate::tokens::Colors for the left accent bar.

Constants§

NOTICE_LIFETIME
How long a notice stays up: a Notice or a Transient shown in the window’s bar (crate::window_toolbar::notify).

Functions§

card_ground
A card’s ground and its edge: the floating card’s opaque panel ground and the panel edge.
card_height
Height of a card width wide: the attribution line (the app, and how long ago it arrived), the title, the body clamped to two lines, the actions and the padding. A card never reserves less room than paint_card paints into it.
card_radius
The radius of a floating card: a notification banner, a toast, and the status cards that stand in a column with them. One floating card is one shape everywhere, the floating Panel’s (radii.panel), so a banner, the palette and a menu never disagree about their corners.
choice_foot
The padding under a card’s choices: the card’s own vertical padding.
choice_gap
The space between a card’s two choices.
choice_height
The height of a card’s choices: compact controls, so a card reads as its message first.
choice_lead
The step between a card’s text and its choices: a full related step, so the choices read as the message’s answer rather than part of it.
choice_rects
Where a pair of choices sits on band given the widths they ask for: at the trailing edge at their own width, the answer last, as a dialog’s do, so the card reads as a sentence that ends in its choices rather than a pair of slabs. Equal halves only when both cannot fit at their width. Returns (secondary, primary).
choice_width
The width a card’s choice asks for: its label (and icon) on a compact face, never narrower than a comfortable target.
minimum_card_height
Minimum height for a compact card with one elided line per text field. Uses the same normalized text, roles, padding and shared action controls as paint_card. A host choosing a fixed-width banner must reserve this height before stacking cards; enlarging type must not paint text over its actions.
paint_card
Paint a toast / notification card into rect and return the geometry a caller needs to route clicks. The card is width/height-agnostic (it lays out relative to rect), so a 48px single-line in-app toast and a 64px three-line OS notification share this one renderer.
paint_card_surface
The card’s body: the one floating card (crate::widget::floating_surface::paint_card), fading with the card.
transient_expired
Whether a transient shown at shown for ttl has expired. Under the capture clock (--shots) nothing expires, so a scenario that stages a toast keeps it in frame.