pub struct GridPainter { /* private fields */ }Expand description
Draws a GridSource onto a Canvas.
Owns the column layout and the font’s character map; glyphs come from the canvas’s shared cache. Painting a frame whose characters have all been drawn (or prewarmed) before allocates nothing; a character seen for the first time is mapped and rasterized, allocating once.
Implementations§
Source§impl GridPainter
impl GridPainter
Sourcepub fn new(
columns: Vec<Column>,
rows: u32,
font: Font,
px: f32,
palette: Palette,
) -> Self
pub fn new( columns: Vec<Column>, rows: u32, font: Font, px: f32, palette: Palette, ) -> Self
A painter for rows data rows of columns, in font at px pixels per em.
Sourcepub fn layout(&self) -> &GridLayout
pub fn layout(&self) -> &GridLayout
The geometry this painter draws with.
Sourcepub fn prewarm(&mut self, cache: &mut GlyphCache, chars: &str) -> usize
pub fn prewarm(&mut self, cache: &mut GlyphCache, chars: &str) -> usize
Rasterizes every character of chars into cache at every subpixel position now,
so frames that only use them never rasterize (or allocate). Updates queue as usual.
Returns how many glyphs could not be cached (the atlas is too small for the set, or a glyph is larger than a page); they would be retried, and allocate, while painting.
Sourcepub fn paint<S: GridSource + ?Sized>(
&mut self,
source: &S,
canvas: &mut Canvas<'_>,
)
pub fn paint<S: GridSource + ?Sized>( &mut self, source: &S, canvas: &mut Canvas<'_>, )
Draws the grid for source onto canvas.
Sourcepub fn paint_columns<S: GridSource + ?Sized>(
&mut self,
source: &S,
canvas: &mut Canvas<'_>,
columns: Range<usize>,
)
pub fn paint_columns<S: GridSource + ?Sized>( &mut self, source: &S, canvas: &mut Canvas<'_>, columns: Range<usize>, )
Draws the grid for source onto canvas, asking for and drawing the cells of
columns only (the header bar and row stripes still span the grid): for a widget
that shows some columns scrolled and others frozen.