ferroui_base/platform/i_cursor_factory.rs
1use super::ICursorImpl;
2use crate::input::StandardCursorType;
3use crate::media::imaging::Bitmap;
4use crate::PixelPoint;
5use std::rc::Rc;
6
7/// Creates the platform implementations of mouse cursors.
8///
9/// This is an implementation detail of the platform backends.
10pub trait ICursorFactory {
11 /// Gets the platform cursor for a standard cursor type.
12 fn get_cursor(&self, cursor_type: StandardCursorType) -> Rc<dyn ICursorImpl>;
13
14 /// Creates a platform cursor from a bitmap. `hot_spot` is the position
15 /// within the bitmap that is the position of the pointer.
16 ///
17 /// Every backend is expected to implement this. The default exists so
18 /// that a backend written before bitmap cursors were part of the
19 /// contract keeps building.
20 ///
21 /// # Panics
22 /// The default implementation panics: the backend does not support
23 /// bitmap cursors.
24 fn create_cursor(&self, cursor: &Bitmap, hot_spot: PixelPoint) -> Rc<dyn ICursorImpl> {
25 let _ = (cursor, hot_spot);
26 panic!("The cursor factory of the platform does not support bitmap cursors.")
27 }
28}