browser_window/
window.rs

1//! This module contains all window related functionality.
2
3mod builder;
4
5pub use builder::WindowBuilder;
6
7pub use super::core::window::WindowExt;
8use super::prelude::*;
9
10
11/// A handle that exposes all windowing functionality.
12pub struct WindowHandle(pub(super) WindowImpl);
13
14
15impl WindowHandle {
16	#[cfg(feature = "threadsafe")]
17	pub(crate) unsafe fn clone(&self) -> Self { Self(self.0.clone()) }
18
19	pub(super) fn new(inner: WindowImpl) -> Self { Self(inner) }
20
21	pub fn content_dimensions(&self) -> Dims2D { self.0.content_dimensions() }
22
23	pub fn opacity(&self) -> u8 { self.0.opacity() }
24
25	pub fn position(&self) -> Pos2D { self.0.position() }
26
27	pub fn title(&self) -> String { self.0.title() }
28
29	pub fn window_dimensions(&self) -> Dims2D { self.0.window_dimensions() }
30
31	/// Hides the window.
32	/// Keep in mind that hiding the window is not the same as closing it.
33	/// Hiding the window will keep it's resources alive.
34	/// If the window is hidden, and all window handles are gone, the memory is
35	/// effectively leaked.
36	pub fn hide(&self) { self.0.hide(); }
37
38	pub fn set_content_dimensions(&self, dimensions: Dims2D) {
39		self.0.set_content_dimensions(dimensions);
40	}
41
42	pub fn set_opacity(&self, opacity: u8) { self.0.set_opacity(opacity); }
43
44	pub fn set_position(&self, position: Pos2D) { self.0.set_position(position); }
45
46	pub fn set_title(&self, title: &str) { self.0.set_title(title); }
47
48	pub fn set_window_dimensions(&self, dimensions: Dims2D) {
49		self.0.set_window_dimensions(dimensions);
50	}
51
52	/// Shows a window if it was hidden.
53	/// Windows that were just created are hidden to start.
54	/// This method is necessary to show it to the user.
55	pub fn show(&self) { self.0.show(); }
56}