#[repr(C)]pub struct WindowState {Show 16 fields
pub title: AzString,
pub theme: WindowTheme,
pub size: WindowSize,
pub position: WindowPosition,
pub flags: WindowFlags,
pub debug_state: DebugState,
pub keyboard_state: KeyboardState,
pub mouse_state: MouseState,
pub touch_state: TouchState,
pub ime_position: ImePosition,
pub monitor: Monitor,
pub platform_specific_options: PlatformSpecificOptions,
pub renderer_options: RendererOptions,
pub background_color: ColorU,
pub layout_callback: LayoutCallback,
pub close_callback: OptionCallback,
}Fields§
§title: AzString§theme: WindowThemeTheme of this window (dark or light) - can be set / overridden by the user
Usually the operating system will set this field. On change, it will
emit a WindowEventFilter::ThemeChanged event
size: WindowSizeSize of the window + max width / max height: 800 x 600 by default
position: WindowPositionThe x and y position, or None to let the WM decide where to put the window (default)
flags: WindowFlagsFlags such as whether the window is minimized / maximized, fullscreen, etc.
debug_state: DebugStateMostly used for debugging, shows WebRender-builtin graphs on the screen. Used for performance monitoring and displaying frame times (rendering-only).
keyboard_state: KeyboardStateCurrent keyboard state - NOTE: mutating this field (currently) does nothing (doesn’t get synchronized with OS-level window)!
mouse_state: MouseStateCurrent mouse state
touch_state: TouchStateStores all states of currently connected touch input devices, pencils, tablets, etc.
ime_position: ImePositionSets location of IME candidate box in client area coordinates relative to the top left of the window.
monitor: MonitorWhich monitor the window is currently residing on
platform_specific_options: PlatformSpecificOptionsWindow options that can only be set on a certain platform
(WindowsWindowOptions / LinuxWindowOptions / MacWindowOptions).
renderer_options: RendererOptionsWhether this window has SRGB / vsync / hardware acceleration
background_color: ColorUColor of the window background (can be transparent if necessary)
layout_callback: LayoutCallbackThe layout() function for this window, stored as a callback function pointer,
There are multiple reasons for doing this (instead of requiring T: Layout everywhere):
- It seperates the
Domfrom theLayouttrait, making it possible to split the UI solving and styling into reusable crates - It’s less typing work (prevents having to type
<T: Layout>everywhere) - It’s potentially more efficient to compile (less type-checking required)
- It’s a preparation for the C ABI, in which traits don’t exist (for language bindings). In the C ABI “traits” are simply structs with function pointers (and void* instead of T)
close_callback: OptionCallbackOptional callback to run when the window closes
Implementations§
Source§impl WindowState
impl WindowState
Sourcepub fn new(callback: LayoutCallbackType) -> Self
pub fn new(callback: LayoutCallbackType) -> Self
Creates a new, default WindowState with the given CSS style
Sourcepub fn get_mouse_state(&self) -> &MouseState
pub fn get_mouse_state(&self) -> &MouseState
Returns the current keyboard keyboard state. We don’t want the library user to be able to modify this state, only to read it.
Sourcepub fn get_keyboard_state(&self) -> &KeyboardState
pub fn get_keyboard_state(&self) -> &KeyboardState
Returns the current windows mouse state. We don’t want the library user to be able to modify this state, only to read it.
Sourcepub fn get_physical_size(&self) -> (usize, usize)
pub fn get_physical_size(&self) -> (usize, usize)
Returns the physical (width, height) in pixel of this window
Sourcepub fn get_hidpi_factor(&self) -> f32
pub fn get_hidpi_factor(&self) -> f32
Returns the current HiDPI factor for this window.
Trait Implementations§
Source§impl Clone for WindowState
impl Clone for WindowState
Source§fn clone(&self) -> WindowState
fn clone(&self) -> WindowState
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for WindowState
impl Debug for WindowState
Source§impl Default for WindowState
impl Default for WindowState
Source§impl From<FullWindowState> for WindowState
impl From<FullWindowState> for WindowState
Source§fn from(full_window_state: FullWindowState) -> WindowState
fn from(full_window_state: FullWindowState) -> WindowState
Source§impl PartialEq for WindowState
impl PartialEq for WindowState
impl StructuralPartialEq for WindowState
Auto Trait Implementations§
impl Freeze for WindowState
impl RefUnwindSafe for WindowState
impl Send for WindowState
impl Sync for WindowState
impl Unpin for WindowState
impl UnwindSafe for WindowState
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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>
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