pub struct WindowManager { /* private fields */ }Expand description
Manages per-window WidgetTrees and window lifecycle.
The primary window (WindowId::PRIMARY) is always present and cannot
be destroyed. Secondary windows are created via
create_window and removed via
destroy_window.
Implementations§
Source§impl WindowManager
impl WindowManager
Sourcepub fn new(primary_rect: Rect) -> Self
pub fn new(primary_rect: Rect) -> Self
Create a new manager with the primary window having the given root rect.
Sourcepub fn create_window(&mut self, config: WindowConfig) -> WindowId
pub fn create_window(&mut self, config: WindowConfig) -> WindowId
Create a secondary window with the given configuration, returning its id.
The new window’s widget tree is initialised with a root rect matching the config’s width/height dimensions.
Sourcepub fn destroy_window(&mut self, id: WindowId) -> Result<(), UiError>
pub fn destroy_window(&mut self, id: WindowId) -> Result<(), UiError>
Destroy a secondary window, freeing its widget tree.
§Errors
Returns an error if id is WindowId::PRIMARY or does not exist.
Sourcepub fn tree(&self, id: WindowId) -> Option<&WidgetTree>
pub fn tree(&self, id: WindowId) -> Option<&WidgetTree>
Borrow the WidgetTree for a window.
Sourcepub fn tree_mut(&mut self, id: WindowId) -> Option<&mut WidgetTree>
pub fn tree_mut(&mut self, id: WindowId) -> Option<&mut WidgetTree>
Mutably borrow the WidgetTree for a window.
Sourcepub fn config(&self, id: WindowId) -> Option<&WindowConfig>
pub fn config(&self, id: WindowId) -> Option<&WindowConfig>
Borrow the WindowConfig for a window.
Sourcepub fn window_ids(&self) -> Vec<WindowId>
pub fn window_ids(&self) -> Vec<WindowId>
Return a sorted list of all open window ids.
Sourcepub fn window_count(&self) -> usize
pub fn window_count(&self) -> usize
Return the number of currently open windows.
Sourcepub fn channel(&self) -> &WindowChannel
pub fn channel(&self) -> &WindowChannel
Borrow the shared cross-window communication channel.
Sourcepub fn resize_window(&mut self, id: WindowId, width: f32, height: f32)
pub fn resize_window(&mut self, id: WindowId, width: f32, height: f32)
Update a window’s logical dimensions and reinitialise its widget tree.
This is a blunt resize: all existing widget nodes are dropped and the tree is recreated with only the root node. Adapters that cache the tree contents should rebuild after calling this method.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for WindowManager
impl RefUnwindSafe for WindowManager
impl Send for WindowManager
impl Sync for WindowManager
impl Unpin for WindowManager
impl UnsafeUnpin for WindowManager
impl UnwindSafe for WindowManager
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> 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