Module tooltip
Expand description
Tooltip primitive — a small label revealed after a short hover delay.
on_hover_enter/on_hover_leave/tick drive the timing state so the
primitive is unit-testable without a winit event loop or a wall clock.
Structs§
- Tooltip
- Tooltip
Host - One controller owned by
crate::app::App— not one tooltip widget per control — is what makes tooltips work for every widget exposingWidget::tooltipwith zero per-app wiring, and guarantees at most one chip on screen. Timing is wall-clock through an injectednow: Instant, so it’s unit-testable.
Enums§
- Tooltip
Side - Which side of its control a tooltip prefers. A control in a row has its neighbours beside it, so its chip goes below; one in a vertical rail has them above and below, so its chip goes beside it, where it hides none of them.
Constants§
- DEFAULT_
DELAY - HOVER_
DWELL - Middle of the 400-600ms comfort band: shows help promptly on a deliberate hover without firing on a pointer merely passing through.
Functions§
- chip_
paint_ bounds - Every pixel
draw_chipcan paint for a chip atrect: the chip, its edge and snapping, and the floating shadow under it. - chip_
reach_ above - How far above its anchor a one-line chip reaches when
chip_rectstands it there: its gap off the anchor, its height and the margin it keeps inside its viewport. A viewport with this much room above the anchor holds the chip there. - chip_
rect - Preferred placement is centred just below the anchor; flips above when it would spill past the bottom edge and there is more room above. Clamped horizontally too, so a control at the far edge gets a chip that hugs it instead of painting off-screen.
- chip_
rect_ on chip_recton the preferredsideof the anchor.- chip_
size - The chip’s size for
label: wrappedCaptiontext plus the chip’s pads. - chip_
size_ in_ viewport - Measure the complete hint at the width its viewport can actually hold.
- draw_
chip - The floating material every floating surface is made of (blurred where the renderer runs the backdrop pass, the opaque panel ground otherwise), with the panel edge, at the control radius: a tooltip is a small floating Panel, not a card.
- draw_
hover_ tooltip - Composes
chip_size,chip_rectanddraw_chip— the one callTooltipHostuses to render a tooltip. - draw_
hover_ tooltip_ on draw_hover_tooltipon the side of its anchor the control prefers.- draw_
marked_ tooltip_ on - A chip saying
labelatanchor, marked by a dot incolorbefore it: what a control says about itself after the person used it (why it did not run, in the danger colour). - draw_
person_ tooltip_ on - A tooltip naming a person: their presence
coloras a dot beforelabel, the way presence marks them everywhere else, on the side ofanchorthe control prefers. - hover_
chip_ rect_ on - Where
draw_hover_tooltip_onplaces the chip forlabel.