Expand description
Thread-local draw-request and invalidation signals.
Two independent channels feed the host’s event loop:
-
Immediate draw request —
request_draw/wants_draw. Any widget whose visual output just changed callsrequest_draw(); the next iteration of the host loop draws a frame and clears the flag. The same call advancesinvalidation_epoch, letting event dispatch dirty the affected retained ancestor path even when the event bubbles as ignored. -
Scheduled draw —
request_draw_after/take_next_draw_deadline. A widget that needs a draw at a future time (text-cursor blink, tooltip delay) callsrequest_draw_after(Duration); the host’s loop goes to sleep withControlFlow::WaitUntil(that_instant)and draws when the deadline fires. Successive calls keep the EARLIEST deadline.
The host loop draws iff wants_draw() || now >= take_next_draw_deadline().
Between draws it idles; no frames are drawn while nothing has changed.
Structs§
- Tween
- Smooth scalar tween between
0.0and1.0(or any pair of values the caller interprets). Drives animations such as the scroll-bar hover expansion and toggle-switch on/off slide.
Functions§
- async_
state_ epoch - Current async-state epoch. Backbuffer caches store this and force a re-raster when it doesn’t match.
- clear_
draw_ request - Reset the per-frame draw flags. The
App::paintentry point calls this before delegating to the root widget so each frame starts fresh — widgets that still need a draw (animation in flight, focus blink, etc.) must re-arm during their draw, otherwise the loop goes idle. - invalidation_
epoch - Monotonic draw-request epoch used to detect visual changes during dispatch.
- request_
draw - Request that the host schedule another draw as soon as possible.
- request_
draw_ after - Schedule a future draw. Keeps the EARLIEST pending deadline, so multiple widgets asking for different delays will all be served by the soonest one (each widget re-arms its own deadline on the next draw anyway).
- request_
draw_ without_ invalidation - Request a frame without advancing
invalidation_epoch. - signal_
async_ state_ change - Note that an async-side state change happened (image loader finished,
font loaded, etc.). Calls
request_draw()so the next frame fires, AND bumps theasync_state_epochso retained backbuffers re-rasterise — without the latter, the freshly-loaded data gets drawn into whatever placeholder rect the previous layout reserved (the markdown SVG-badge “wrong scale on first frame” bug). - take_
next_ draw_ deadline - Read-and-clear the scheduled draw deadline. The host reads this after drawing so the next frame’s scheduled wake is determined entirely by what the fresh draw registered (e.g. a text field re-arms the 500 ms blink each frame while it remains focused; losing focus means no re-arm and the loop goes idle).
- wants_
draw - Non-destructive read. Hosts call this after drawing to decide control-flow for the next loop iteration.