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 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§
fn 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§
fn run_event_loop(&self) -> Result<(), PlatformError>
fn run_event_loop(&self) -> Result<(), PlatformError>
Spins an event loop and renders the visible windows.
fn 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
fn 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.
fn 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.
fn 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
fn 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