Renderer

Trait Renderer 

Source
pub trait Renderer: Renderer {
    type Font: Default + Clone;

    const ICON_FONT: Self::Font;
    const CHECKMARK_ICON: char;
    const ARROW_DOWN_ICON: char;

    // Required methods
    fn default_size(&self) -> f32;
    fn measure(
        &self,
        content: &str,
        size: f32,
        font: Self::Font,
        bounds: Size,
    ) -> (f32, f32);
    fn hit_test(
        &self,
        contents: &str,
        size: f32,
        font: Self::Font,
        bounds: Size,
        point: Point,
        nearest_only: bool,
    ) -> Option<Hit>;
    fn fill_text(&mut self, text: Text<'_, Self::Font>);

    // Provided method
    fn measure_width(&self, content: &str, size: f32, font: Self::Font) -> f32 { ... }
}
Expand description

A renderer capable of measuring and drawing Text.

Required Associated Constants§

Source

const ICON_FONT: Self::Font

The icon font of the backend.

Source

const CHECKMARK_ICON: char

The char representing a ✔ icon in the ICON_FONT.

Source

const ARROW_DOWN_ICON: char

The char representing a ▼ icon in the built-in ICON_FONT.

Required Associated Types§

Source

type Font: Default + Clone

The font type used.

Required Methods§

Source

fn default_size(&self) -> f32

Returns the default size of Text.

Source

fn measure( &self, content: &str, size: f32, font: Self::Font, bounds: Size, ) -> (f32, f32)

Measures the text in the given bounds and returns the minimum boundaries that can fit the contents.

Source

fn hit_test( &self, contents: &str, size: f32, font: Self::Font, bounds: Size, point: Point, nearest_only: bool, ) -> Option<Hit>

Tests whether the provided point is within the boundaries of text laid out with the given parameters, returning information about the nearest character.

If nearest_only is true, the hit test does not consider whether the the point is interior to any glyph bounds, returning only the character with the nearest centeroid.

Source

fn fill_text(&mut self, text: Text<'_, Self::Font>)

Draws the given Text.

Provided Methods§

Source

fn measure_width(&self, content: &str, size: f32, font: Self::Font) -> f32

Measures the width of the text as if it were laid out in a single line.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl Renderer for Null

Available on debug-assertions enabled only.
Source§

const ICON_FONT: Font = Font::Default

Source§

const CHECKMARK_ICON: char = '0'

Source§

const ARROW_DOWN_ICON: char = '0'

Source§

type Font = Font