Skip to main content

GridPainter

Struct GridPainter 

Source
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

Source

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.

Source

pub fn layout(&self) -> &GridLayout

The geometry this painter draws with.

Source

pub fn palette(&self) -> &Palette

The colors this painter draws with.

Source

pub fn columns(&self) -> &[Column]

The columns, left to right.

Source

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.

Source

pub fn paint<S: GridSource + ?Sized>( &mut self, source: &S, canvas: &mut Canvas<'_>, )

Draws the grid for source onto canvas.

Source

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.

Trait Implementations§

Source§

impl Debug for GridPainter

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.