WindowState

Struct WindowState 

Source
#[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: WindowTheme

Theme 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: WindowSize

Size of the window + max width / max height: 800 x 600 by default

§position: WindowPosition

The x and y position, or None to let the WM decide where to put the window (default)

§flags: WindowFlags

Flags such as whether the window is minimized / maximized, fullscreen, etc.

§debug_state: DebugState

Mostly used for debugging, shows WebRender-builtin graphs on the screen. Used for performance monitoring and displaying frame times (rendering-only).

§keyboard_state: KeyboardState

Current keyboard state - NOTE: mutating this field (currently) does nothing (doesn’t get synchronized with OS-level window)!

§mouse_state: MouseState

Current mouse state

§touch_state: TouchState

Stores all states of currently connected touch input devices, pencils, tablets, etc.

§ime_position: ImePosition

Sets location of IME candidate box in client area coordinates relative to the top left of the window.

§monitor: Monitor

Which monitor the window is currently residing on

§platform_specific_options: PlatformSpecificOptions

Window options that can only be set on a certain platform (WindowsWindowOptions / LinuxWindowOptions / MacWindowOptions).

§renderer_options: RendererOptions

Whether this window has SRGB / vsync / hardware acceleration

§background_color: ColorU

Color of the window background (can be transparent if necessary)

§layout_callback: LayoutCallback

The 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 Dom from the Layout trait, 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: OptionCallback

Optional callback to run when the window closes

Implementations§

Source§

impl WindowState

Source

pub fn new(callback: LayoutCallbackType) -> Self

Creates a new, default WindowState with the given CSS style

Source

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.

Source

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.

Source

pub fn get_physical_size(&self) -> (usize, usize)

Returns the physical (width, height) in pixel of this window

Source

pub fn get_hidpi_factor(&self) -> f32

Returns the current HiDPI factor for this window.

Trait Implementations§

Source§

impl Clone for WindowState

Source§

fn clone(&self) -> WindowState

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for WindowState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for WindowState

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl From<FullWindowState> for WindowState

Source§

fn from(full_window_state: FullWindowState) -> WindowState

Converts to this type from the input type.
Source§

impl PartialEq for WindowState

Source§

fn eq(&self, other: &WindowState) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for WindowState

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.