Skip to content

Commit 691ba8c

Browse files
committed
docs
1 parent eaf9e63 commit 691ba8c

2 files changed

Lines changed: 27 additions & 3 deletions

File tree

examples/open_parented/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use baseview::dpi::{LogicalSize, PhysicalSize};
1+
use baseview::dpi::LogicalSize;
22
use baseview::{
33
Event, EventStatus, HandlerError, WindowContext, WindowHandle, WindowHandler,
44
WindowOpenOptions, WindowSize,
@@ -55,7 +55,7 @@ impl WindowHandler for ParentWindowHandler {
5555
}
5656

5757
let child_size =
58-
PhysicalSize::new(new_size.physical.width / 2, new_size.physical.height / 2);
58+
LogicalSize::new(new_size.logical.width / 2., new_size.logical.height / 2.);
5959
self.child_window.suggest_scale_factor(new_size.scale_factor)?;
6060
self.child_window.resize(child_size.into())?;
6161
Ok(())

src/window.rs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,41 @@ impl WindowHandle {
2525
self.window_handle.size()
2626
}
2727

28+
/// Resizes the window to the given [`Size`].
29+
///
30+
/// The `size` can be provided in either physical or logical pixels.
2831
pub fn resize(&self, size: Size) -> Result<(), Error> {
2932
self.window_handle.resize(size)?;
3033
Ok(())
3134
}
3235

36+
/// Suggests a fallback scale factor, if Baseview couldn't get one from the platform.
37+
///
38+
/// If the platform does already provide an accurate scaling factor, this doesn't do anything.
39+
///
40+
/// If the given fallback scale factor is actually useful and different from the current one
41+
/// (1.0 by default), this will resize and redraw the window accordingly.
42+
///
43+
/// # Platform compatibility notes.
44+
///
45+
/// On Win32, this is used if running on early versions of Windows 10 (or earlier).
46+
///
47+
/// On X11, this is used if no `Xft.dpi`setting is set.
48+
///
49+
/// On macOS, this is always a no-op.
3350
pub fn suggest_scale_factor(&self, scale_factor: f64) -> Result<(), Error> {
3451
self.window_handle.suggest_scale_factor(scale_factor)?;
3552
Ok(())
3653
}
3754

38-
/// Close the window
55+
/// Closes and destroys the window.
56+
///
57+
/// This releases all resources the window uses.
58+
///
59+
/// It is guaranteed that no other objects (e.g. the parent window) are used by this window after
60+
/// this call.
61+
///
62+
/// Calling this method is more explicit, but otherwise identical to just dropping this [`WindowHandle`].
3963
pub fn close(self) {
4064
drop(self)
4165
}

0 commit comments

Comments
 (0)