Trait i_slint_core::item_rendering::ItemRenderer

source ·
pub trait ItemRenderer {
Show 26 methods // Required methods fn draw_rectangle( &mut self, rect: Pin<&Rectangle>, _self_rc: &ItemRc, _size: LogicalSize ); fn draw_border_rectangle( &mut self, rect: Pin<&dyn RenderBorderRectangle>, _self_rc: &ItemRc, _size: LogicalSize, _cache: &CachedRenderingData ); fn draw_image( &mut self, image: Pin<&dyn RenderImage>, _self_rc: &ItemRc, _size: LogicalSize, _cache: &CachedRenderingData ); fn draw_text( &mut self, text: Pin<&Text>, _self_rc: &ItemRc, _size: LogicalSize ); fn draw_text_input( &mut self, text_input: Pin<&TextInput>, _self_rc: &ItemRc, _size: LogicalSize ); fn draw_path( &mut self, path: Pin<&Path>, _self_rc: &ItemRc, _size: LogicalSize ); fn draw_box_shadow( &mut self, box_shadow: Pin<&BoxShadow>, _self_rc: &ItemRc, _size: LogicalSize ); fn combine_clip( &mut self, rect: LogicalRect, radius: LogicalBorderRadius, border_width: LogicalLength ) -> bool; fn get_current_clip(&self) -> LogicalRect; fn translate(&mut self, distance: LogicalVector); 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: &ItemRc, update_fn: &dyn Fn(&mut dyn FnMut(u32, u32, &[u8])) ); fn draw_string(&mut self, string: &str, color: Color); fn draw_image_direct(&mut self, image: Image); fn window(&self) -> &WindowInner; fn as_any(&mut self) -> Option<&mut dyn Any>; // Provided methods fn visit_opacity( &mut self, opacity_item: Pin<&Opacity>, _self_rc: &ItemRc, _size: LogicalSize ) -> RenderingResult { ... } fn visit_layer( &mut self, _layer_item: Pin<&Layer>, _self_rc: &ItemRc, _size: LogicalSize ) -> RenderingResult { ... } fn visit_clip( &mut self, clip_item: Pin<&Clip>, item_rc: &ItemRc, _size: LogicalSize ) -> RenderingResult { ... } fn translation(&self) -> LogicalVector { ... } fn filter_item(&mut self, item: &ItemRc) -> (bool, LogicalRect) { ... } fn metrics(&self) -> RenderingMetrics { ... }
}
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§

source

fn draw_rectangle( &mut self, rect: Pin<&Rectangle>, _self_rc: &ItemRc, _size: LogicalSize )

source

fn draw_border_rectangle( &mut self, rect: Pin<&dyn RenderBorderRectangle>, _self_rc: &ItemRc, _size: LogicalSize, _cache: &CachedRenderingData )

source

fn draw_image( &mut self, image: Pin<&dyn RenderImage>, _self_rc: &ItemRc, _size: LogicalSize, _cache: &CachedRenderingData )

source

fn draw_text(&mut self, text: Pin<&Text>, _self_rc: &ItemRc, _size: LogicalSize)

source

fn draw_text_input( &mut self, text_input: Pin<&TextInput>, _self_rc: &ItemRc, _size: LogicalSize )

source

fn draw_path(&mut self, path: Pin<&Path>, _self_rc: &ItemRc, _size: LogicalSize)

source

fn draw_box_shadow( &mut self, box_shadow: Pin<&BoxShadow>, _self_rc: &ItemRc, _size: LogicalSize )

source

fn combine_clip( &mut self, rect: LogicalRect, radius: LogicalBorderRadius, border_width: LogicalLength ) -> bool

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) Returns a boolean indicating the state of the new clip region: true if the clip region covers an area; false if the clip region is empty.

source

fn get_current_clip(&self) -> LogicalRect

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

source

fn translate(&mut self, distance: LogicalVector)

source

fn rotate(&mut self, angle_in_degrees: f32)

source

fn apply_opacity(&mut self, opacity: f32)

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

source

fn save_state(&mut self)

source

fn restore_state(&mut self)

source

fn scale_factor(&self) -> f32

Returns the scale factor

source

fn draw_cached_pixmap( &mut self, item_cache: &ItemRc, update_fn: &dyn Fn(&mut dyn FnMut(u32, u32, &[u8])) )

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

source

fn draw_string(&mut self, string: &str, color: Color)

Draw the given string with the specified color at current (0, 0) with the default font. Mainly used by the performance counter overlay.

source

fn draw_image_direct(&mut self, image: Image)

source

fn window(&self) -> &WindowInner

source

fn as_any(&mut self) -> Option<&mut dyn Any>

Return the internal renderer

Provided Methods§

source

fn visit_opacity( &mut self, opacity_item: Pin<&Opacity>, _self_rc: &ItemRc, _size: LogicalSize ) -> RenderingResult

source

fn visit_layer( &mut self, _layer_item: Pin<&Layer>, _self_rc: &ItemRc, _size: LogicalSize ) -> RenderingResult

source

fn visit_clip( &mut self, clip_item: Pin<&Clip>, item_rc: &ItemRc, _size: LogicalSize ) -> RenderingResult

source

fn translation(&self) -> LogicalVector

source

fn filter_item(&mut self, item: &ItemRc) -> (bool, LogicalRect)

This is called before it is being rendered (before the draw_* function). Returns

  • if the item needs to be drawn (false means it is clipped or doesn’t need to be drawn)
  • the geometry of the item
source

fn metrics(&self) -> RenderingMetrics

Returns any rendering metrics collecting since the creation of the renderer (typically per frame)

Implementors§