Add safe area and document coordinate systems (#3890)
Added `Window::safe_area`, which describes the area of the surface that is unobstructed by notches, bezels etc. The drawing code in the examples have been updated to draw a star inside the safe area, and the plain background outside of it. Also renamed `Window::inner_position` to `Window::surface_position`, and changed it to from screen coordinates to window coordinates, to better align how these coordinate systems work together. Finally, added some SVG images and documentation to describe how all of this works. This is fully implemented on macOS and iOS, and partially on the web. Co-authored-by: daxpedda <daxpedda@gmail.com>
This commit is contained in:
parent
d0c6c34eaa
commit
dbcdb6f1b4
30 changed files with 797 additions and 212 deletions
11
src/event.rs
11
src/event.rs
|
|
@ -156,7 +156,10 @@ pub enum WindowEvent {
|
|||
/// [`Window::surface_size`]: crate::window::Window::surface_size
|
||||
SurfaceResized(PhysicalSize<u32>),
|
||||
|
||||
/// The position of the window has changed. Contains the window's new position.
|
||||
/// The position of the window has changed.
|
||||
///
|
||||
/// Contains the window's new position in desktop coordinates (can also be retrieved with
|
||||
/// [`Window::outer_position`]).
|
||||
///
|
||||
/// ## Platform-specific
|
||||
///
|
||||
|
|
@ -469,13 +472,15 @@ pub enum WindowEvent {
|
|||
|
||||
/// Emitted when a window should be redrawn.
|
||||
///
|
||||
/// This gets triggered in two scenarios:
|
||||
/// This gets triggered in a few scenarios:
|
||||
/// - The OS has performed an operation that's invalidated the window's contents (such as
|
||||
/// resizing the window).
|
||||
/// resizing the window, or changing [the safe area]).
|
||||
/// - The application has explicitly requested a redraw via [`Window::request_redraw`].
|
||||
///
|
||||
/// Winit will aggregate duplicate redraw requests into a single event, to
|
||||
/// help avoid duplicating rendering work.
|
||||
///
|
||||
/// [the safe area]: crate::window::Window::safe_area
|
||||
RedrawRequested,
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue