pub struct LayoutCache { /* private fields */ }Expand description
Keeps the last layout of one widget’s text and recomputes it only when an input changes.
Implementations§
Source§impl LayoutCache
impl LayoutCache
Sourcepub fn get(
&mut self,
engine: &mut dyn TextLayout,
text: &str,
style: &TextStyle,
max_width: Option<u32>,
) -> &LaidOut
pub fn get( &mut self, engine: &mut dyn TextLayout, text: &str, style: &TextStyle, max_width: Option<u32>, ) -> &LaidOut
Returns the layout for the inputs, computing it with engine only if the text, font,
font size, font style or width differ from the previous call. Changing only the color
or the justification does not lay out again.
§Arguments
engine- The layout engine to use on a miss.text- The text to lay out.style- The font, size and style.max_width- The width in pixels at which to wrap, orNonefor no wrapping.
§Returns
The cached or freshly computed layout.
Sourcepub fn invalidate(&mut self)
pub fn invalidate(&mut self)
Forgets the cached layout so the next get lays out again.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for LayoutCache
impl !Send for LayoutCache
impl !Sync for LayoutCache
impl !UnwindSafe for LayoutCache
impl Freeze for LayoutCache
impl Unpin for LayoutCache
impl UnsafeUnpin for LayoutCache
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more