Skip to main content

frame_rate_readout

Function frame_rate_readout 

Source
pub(crate) fn frame_rate_readout(ui: &mut Ui, text: &str)
Expand description

Draw the frame-rate readout, showing text, centred along the top edge of ui’s screen.

The label is set to [egui::Label::extend], so the readout grows to fit its text instead of wrapping it. An anchored area lays its contents out against the size it remembered from the previous pass, so a reading that is wider than the last one — the first real reading after the empty placeholder, or any reading after the rate changes — would otherwise be broken across lines in a narrow window.

A free function rather than the body of the panel’s closure so a test can drive it against a bare [egui::Context]: what it has to get right — one line, whatever the previous reading was — is a property of the widget tree, not of the world.