pub struct Platform { /* private fields */ }Expand description
Application-wide platform api.
Implementations§
Source§impl Platform
impl Platform
pub fn new(sender: impl Fn(GlobalUserEvent) + 'static) -> Self
pub fn get() -> Self
Sourcepub fn window(&self, window_id: impl Into<u64>) -> PlatformWindow
pub fn window(&self, window_id: impl Into<u64>) -> PlatformWindow
Returns the live window with this ID, panicking if it has closed or does not exist.
Sourcepub fn try_window(&self, window_id: impl Into<u64>) -> Option<PlatformWindow>
pub fn try_window(&self, window_id: impl Into<u64>) -> Option<PlatformWindow>
Returns the live window with this ID, or None if it has closed or does not exist.
Sourcepub fn current_window(&self) -> PlatformWindow
pub fn current_window(&self) -> PlatformWindow
Returns the window from whose component, event handler, or scoped task this is called.
pub fn register_window(&self, window: PlatformWindow)
pub fn unregister_window(&self, window_id: impl Into<u64>)
pub fn send(&self, event: GlobalUserEvent)
Sourcepub fn load_font(
&self,
font_name: impl Into<Cow<'static, str>>,
font_data: impl Into<Bytes>,
)
pub fn load_font( &self, font_name: impl Into<Cow<'static, str>>, font_data: impl Into<Bytes>, )
Load a font at runtime in every window.
§Example
use freya_core::prelude::*;
fn load_rubik() {
let font = std::fs::read("./Rubik.ttf").expect("Failed to read the font file.");
Platform::get().load_font("Rubik", font);
}Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Platform
impl !Send for Platform
impl !Sync for Platform
impl !UnwindSafe for Platform
impl Freeze for Platform
impl Unpin for Platform
impl UnsafeUnpin for Platform
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more