i_slint_core::renderer

Trait RendererSealed

Source
pub trait RendererSealed {
Show 14 methods // Required methods fn text_size( &self, font_request: FontRequest, text: &str, max_width: Option<LogicalLength>, scale_factor: ScaleFactor, text_wrap: TextWrap, ) -> LogicalSize; fn font_metrics( &self, font_request: FontRequest, scale_factor: ScaleFactor, ) -> FontMetrics; fn text_input_byte_offset_for_position( &self, text_input: Pin<&TextInput>, pos: LogicalPoint, font_request: FontRequest, scale_factor: ScaleFactor, ) -> usize; fn text_input_cursor_rect_for_byte_offset( &self, text_input: Pin<&TextInput>, byte_offset: usize, font_request: FontRequest, scale_factor: ScaleFactor, ) -> LogicalRect; fn default_font_size(&self) -> LogicalLength; fn set_window_adapter(&self, _window_adapter: &Rc<dyn WindowAdapter>); // Provided methods fn free_graphics_resources( &self, _component: ItemTreeRef<'_>, _items: &mut dyn Iterator<Item = Pin<ItemRef<'_>>>, ) -> Result<(), PlatformError> { ... } fn mark_dirty_region(&self, _region: DirtyRegion) { ... } fn register_font_from_memory( &self, _data: &'static [u8], ) -> Result<(), Box<dyn Error>> { ... } fn register_font_from_path( &self, _path: &Path, ) -> Result<(), Box<dyn Error>> { ... } fn register_bitmap_font(&self, _font_data: &'static BitmapFont) { ... } fn set_rendering_notifier( &self, _callback: Box<dyn RenderingNotifier>, ) -> Result<(), SetRenderingNotifierError> { ... } fn resize(&self, _size: PhysicalSize) -> Result<(), PlatformError> { ... } fn take_snapshot( &self, ) -> Result<SharedPixelBuffer<Rgba8Pixel>, PlatformError> { ... }
}
Expand description

Implementation details behind Renderer, but since this trait is not exported in the public API, it is not possible for the users to re-implement these functions.

Required Methods§

Source

fn text_size( &self, font_request: FontRequest, text: &str, max_width: Option<LogicalLength>, scale_factor: ScaleFactor, text_wrap: TextWrap, ) -> LogicalSize

Returns the size of the given text in logical pixels. When set, max_width means that one need to wrap the text, so it does not go further than that, using the wrapping type passed by text_wrap.

Source

fn font_metrics( &self, font_request: FontRequest, scale_factor: ScaleFactor, ) -> FontMetrics

Returns the metrics of the given font.

Source

fn text_input_byte_offset_for_position( &self, text_input: Pin<&TextInput>, pos: LogicalPoint, font_request: FontRequest, scale_factor: ScaleFactor, ) -> usize

Returns the (UTF-8) byte offset in the text property that refers to the character that contributed to the glyph cluster that’s visually nearest to the given coordinate. This is used for hit-testing, for example when receiving a mouse click into a text field. Then this function returns the “cursor” position.

Source

fn text_input_cursor_rect_for_byte_offset( &self, text_input: Pin<&TextInput>, byte_offset: usize, font_request: FontRequest, scale_factor: ScaleFactor, ) -> LogicalRect

That’s the opposite of Self::text_input_byte_offset_for_position It takes a (UTF-8) byte offset in the text property, and returns a Rectangle left to the char. It is one logical pixel wide and ends at the baseline.

Source

fn default_font_size(&self) -> LogicalLength

Source

fn set_window_adapter(&self, _window_adapter: &Rc<dyn WindowAdapter>)

Provided Methods§

Source

fn free_graphics_resources( &self, _component: ItemTreeRef<'_>, _items: &mut dyn Iterator<Item = Pin<ItemRef<'_>>>, ) -> Result<(), PlatformError>

Clear the caches for the items that are being removed

Source

fn mark_dirty_region(&self, _region: DirtyRegion)

Mark a given region as dirty regardless whether the items actually are dirty.

Example: when a PopupWindow disappears, the region under the popup needs to be redrawn

Source

fn register_font_from_memory( &self, _data: &'static [u8], ) -> Result<(), Box<dyn Error>>

This function can be used to register a custom TrueType font with Slint, for use with the font-family property. The provided slice must be a valid TrueType font.

Source

fn register_font_from_path(&self, _path: &Path) -> Result<(), Box<dyn Error>>

This function can be used to register a custom TrueType font with Slint, for use with the font-family property. The provided path must refer to a valid TrueType font.

Source

fn register_bitmap_font(&self, _font_data: &'static BitmapFont)

Source

fn set_rendering_notifier( &self, _callback: Box<dyn RenderingNotifier>, ) -> Result<(), SetRenderingNotifierError>

This function is called through the public API to register a callback that the backend needs to invoke during different phases of rendering.

Source

fn resize(&self, _size: PhysicalSize) -> Result<(), PlatformError>

Source

fn take_snapshot(&self) -> Result<SharedPixelBuffer<Rgba8Pixel>, PlatformError>

Re-implement this function to support Window::take_snapshot(), i.e. return the contents of the window in an image buffer.

Implementors§