pub trait Platform {
// Required method
fn create_window_adapter(
&self,
) -> Result<Rc<dyn WindowAdapter>, PlatformError>;
// Provided methods
fn run_event_loop(&self) -> Result<(), PlatformError> { ... }
fn new_event_loop_proxy(&self) -> Option<Box<dyn EventLoopProxy>> { ... }
fn duration_since_start(&self) -> Duration { ... }
fn click_interval(&self) -> Duration { ... }
fn cursor_flash_cycle(&self) -> Duration { ... }
fn set_clipboard_text(&self, _text: &str, _clipboard: Clipboard) { ... }
fn clipboard_text(&self, _clipboard: Clipboard) -> Option<String> { ... }
fn debug_log(&self, _arguments: Arguments<'_>) { ... }
}
Expand description
This trait defines the interface between Slint and platform APIs typically provided by operating and windowing systems.
Required Methods§
Sourcefn create_window_adapter(&self) -> Result<Rc<dyn WindowAdapter>, PlatformError>
fn create_window_adapter(&self) -> Result<Rc<dyn WindowAdapter>, PlatformError>
Instantiate a window for a component.
Provided Methods§
Sourcefn run_event_loop(&self) -> Result<(), PlatformError>
fn run_event_loop(&self) -> Result<(), PlatformError>
Spins an event loop and renders the visible windows.
Sourcefn new_event_loop_proxy(&self) -> Option<Box<dyn EventLoopProxy>>
fn new_event_loop_proxy(&self) -> Option<Box<dyn EventLoopProxy>>
Return an EventLoopProxy
that can be used to send event to the event loop
If this function returns None
(the default implementation), then it will
not be possible to send event to the event loop and the function
slint::invoke_from_event_loop()
and
slint::quit_event_loop()
will panic
Sourcefn duration_since_start(&self) -> Duration
fn duration_since_start(&self) -> Duration
Returns the current time as a monotonic duration since the start of the program
This is used by the animations and timer to compute the elapsed time.
When the std
feature is enabled, this function is implemented in terms of
std::time::Instant::now()
, but on #![no_std]
platform, this function must
be implemented.
Sourcefn click_interval(&self) -> Duration
fn click_interval(&self) -> Duration
Returns the current interval to internal measure the duration to send a double click event.
A double click event is a series of two pointer clicks.
Sourcefn cursor_flash_cycle(&self) -> Duration
fn cursor_flash_cycle(&self) -> Duration
Returns the current rate at which the text cursor should flash or blink.
This is the length of the entire visible-hidden-visible cycle, so for a duration of 1000ms it is visible for 500ms then hidden for 500ms, then visible again.
If this value is Duration::ZERO
then the cycle is disabled.
Sourcefn set_clipboard_text(&self, _text: &str, _clipboard: Clipboard)
fn set_clipboard_text(&self, _text: &str, _clipboard: Clipboard)
Sends the given text into the system clipboard.
If the platform doesn’t support the specified clipboard, this function should do nothing
Sourcefn clipboard_text(&self, _clipboard: Clipboard) -> Option<String>
fn clipboard_text(&self, _clipboard: Clipboard) -> Option<String>
Returns a copy of text stored in the system clipboard, if any.
If the platform doesn’t support the specified clipboard, the function should return None