Module toast
Expand description
Transient notices and the notification card.
TransientandNoticekeep 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.ToastCardandpaint_cardpaint the shell’s notification card, outside any window: the desktop’s notification banners and the lock screen’s.ToastKindmaps toTheme::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. - Sender
Mark - 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.
- Toast
Card - Immediate-mode content for one notification / toast card, painted by
paint_card. Built fluently:ToastCard::new("Slow network", ToastKind::Warning).body("retrying"). - Toast
Card Hit - Geometry
paint_cardhands 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§
- Toast
Kind - Severity / category of a toast. Maps to the semantic color ramp in
crate::tokens::Colorsfor the left accent bar.
Constants§
- NOTICE_
LIFETIME - How long a notice stays up: a
Noticeor aTransientshown 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
widthwide: 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 thanpaint_cardpaints 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
bandgiven 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
rectand return the geometry a caller needs to route clicks. The card is width/height-agnostic (it lays out relative torect), 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
shownforttlhas expired. Under the capture clock (--shots) nothing expires, so a scenario that stages a toast keeps it in frame.