Skip to main content

Renderer

Trait Renderer 

Source
pub trait Renderer {
Show 15 methods // Required methods fn start_layer(&mut self, bounds: Rectangle); fn end_layer(&mut self); fn start_transformation(&mut self, transformation: Transformation); fn end_transformation(&mut self); fn fill_quad(&mut self, quad: Quad, background: impl Into<Background>); fn allocate_image( &mut self, handle: &Handle, callback: impl FnOnce(Result<Allocation, Error>) + Send + 'static, ); fn hint(&mut self, scale: Scale); fn scale(&self) -> Option<Scale>; fn reset(&mut self, new_bounds: Rectangle); fn settings(&self) -> Settings; // Provided methods fn with_layer(&mut self, bounds: Rectangle, f: impl FnOnce(&mut Self)) { ... } fn with_transformation( &mut self, transformation: Transformation, f: impl FnOnce(&mut Self), ) { ... } fn with_translation( &mut self, translation: Vector, f: impl FnOnce(&mut Self), ) { ... } fn hint_factor(&self) -> Option<f32> { ... } fn tick(&mut self) { ... }
}
Expand description

A component that can be used by widgets to draw themselves on a screen.

Required Methods§

Source

fn start_layer(&mut self, bounds: Rectangle)

Starts recording a new layer.

Source

fn end_layer(&mut self)

Ends recording a new layer.

The new layer will clip its contents to the provided bounds.

Source

fn start_transformation(&mut self, transformation: Transformation)

Starts recording with a new Transformation.

Source

fn end_transformation(&mut self)

Ends recording a new layer.

The new layer will clip its contents to the provided bounds.

Source

fn fill_quad(&mut self, quad: Quad, background: impl Into<Background>)

Fills a Quad with the provided Background.

Source

fn allocate_image( &mut self, handle: &Handle, callback: impl FnOnce(Result<Allocation, Error>) + Send + 'static, )

Creates an image::Allocation for the given image::Handle and calls the given callback with it.

Source

fn hint(&mut self, scale: Scale)

Provides hints to the Renderer about the rendering target.

This may be used internally by the Renderer to perform optimizations and/or improve rendering quality.

For instance, providing a Scale may be used by some renderers to perform metrics hinting internally in physical coordinates while keeping layout coordinates logical and, therefore, maintain linearity.

Source

fn scale(&self) -> Option<Scale>

Returns the last Scale provided as a hint.

Source

fn reset(&mut self, new_bounds: Rectangle)

Resets the Renderer to start drawing in the new_bounds from scratch.

Source

fn settings(&self) -> Settings

Returns the Settings of this Renderer.

Provided Methods§

Source

fn with_layer(&mut self, bounds: Rectangle, f: impl FnOnce(&mut Self))

Draws the primitives recorded in the given closure in a new layer.

The layer will clip its contents to the provided bounds.

Source

fn with_transformation( &mut self, transformation: Transformation, f: impl FnOnce(&mut Self), )

Applies a Transformation to the primitives recorded in the given closure.

Source

fn with_translation(&mut self, translation: Vector, f: impl FnOnce(&mut Self))

Applies a translation to the primitives recorded in the given closure.

Source

fn hint_factor(&self) -> Option<f32>

Returns the last hint factor provided as a hint, only if Settings::metrics_hinting is enabled.

Source

fn tick(&mut self)

Polls any concurrent computations that may be pending in the Renderer.

By default, it does nothing.

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.

Implementations on Foreign Types§

Source§

impl Renderer for ()

Source§

fn start_layer(&mut self, _bounds: Rectangle)

Source§

fn end_layer(&mut self)

Source§

fn start_transformation(&mut self, _transformation: Transformation)

Source§

fn end_transformation(&mut self)

Source§

fn fill_quad(&mut self, _quad: Quad, _background: impl Into<Background>)

Source§

fn allocate_image( &mut self, handle: &Handle, callback: impl FnOnce(Result<Allocation, Error>) + Send + 'static, )

Source§

fn hint(&mut self, _scale: Scale)

Source§

fn scale(&self) -> Option<Scale>

Source§

fn reset(&mut self, _new_bounds: Rectangle)

Source§

fn settings(&self) -> Settings

Implementors§