logo
pub trait ItemRenderer {
Show 20 methods fn draw_rectangle(&mut self, rect: Pin<&Rectangle>);
fn draw_border_rectangle(&mut self, rect: Pin<&BorderRectangle>);
fn draw_image(&mut self, image: Pin<&ImageItem>);
fn draw_clipped_image(&mut self, image: Pin<&ClippedImage>);
fn draw_text(&mut self, text: Pin<&Text>);
fn draw_text_input(&mut self, text_input: Pin<&TextInput>);
fn draw_path(&mut self, path: Pin<&Path>);
fn draw_box_shadow(&mut self, box_shadow: Pin<&BoxShadow>);
fn combine_clip(&mut self, rect: Rect, radius: f32, border_width: f32);
fn get_current_clip(&self) -> Rect;
fn translate(&mut self, x: f32, y: f32);
fn rotate(&mut self, angle_in_degrees: f32);
fn apply_opacity(&mut self, opacity: f32);
fn save_state(&mut self);
fn restore_state(&mut self);
fn scale_factor(&self) -> f32;
fn draw_cached_pixmap(
        &mut self,
        item_cache: &CachedRenderingData,
        update_fn: &dyn Fn(&mut dyn FnMut(u32, u32, &[u8]))
    );
fn draw_string(&mut self, string: &str, color: Color);
fn window(&self) -> WindowRc;
fn as_any(&mut self) -> &mut dyn Any;
}
Expand description

Trait used to render each items.

The item needs to be rendered relative to its (x,y) position. For example, draw_rectangle should draw a rectangle in (pos.x + rect.x, pos.y + rect.y)

Required methods

Clip the further call until restore_state. radius/border_width can be used for border rectangle clip. (FIXME: consider removing radius/border_width and have another function that take a path instead)

Get the current clip bounding box in the current transformed coordinate.

Apply the opacity (between 0 and 1) for all following items until the next call to restore_state.

Returns the scale factor

Draw a pixmap in position indicated by the pos. The pixmap will be taken from cache if the cache is valid, otherwise, update_fn will be called with a callback that need to be called once with fn (width, height, data) where data are the RGBA premultiplied pixel values

Return the internal renderer

Implementors