Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add safe area and document coordinate systems #3890

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
98a9914
Add safe area and document coordinate systems
madsmtm Aug 25, 2024
335a1c6
Attempt to show better show that positions are relative to something
madsmtm Sep 10, 2024
3cd2fa6
Remove extra comment that was more confusing than helpful
madsmtm Sep 10, 2024
9bcd3ff
Improve docs, allow safe area to include transparent title bar
madsmtm Sep 10, 2024
bec2ed1
Use possibly negative values for surface position
madsmtm Sep 10, 2024
81c92eb
Fix safe_area on macOS < 11
madsmtm Sep 10, 2024
d5d8e30
Fix outer_size on iOS
madsmtm Sep 10, 2024
b1fee88
Remove draw.io files from typos check
madsmtm Sep 10, 2024
5df9eb8
Fix doc link
madsmtm Sep 10, 2024
da7942e
Fix SurfaceResized on iOS
madsmtm Sep 10, 2024
9f080a5
Always redraw when the safe area changes
madsmtm Sep 10, 2024
bc12e13
Properly set up typos check
madsmtm Sep 10, 2024
287fd8d
Add Android, Orbital, Web, Windows, Wayland and X11 implementations
madsmtm Sep 10, 2024
ba76cc6
Fix Android inner_position/surface_position name
madsmtm Sep 10, 2024
8561d3b
Fix clippy warning on Windows
madsmtm Sep 10, 2024
feb686a
Fix size of desktop coordinate systems image
madsmtm Sep 10, 2024
e878c59
Note on android that there's events for safe area insets
madsmtm Sep 10, 2024
c7523d4
Add docs on also emitting RedrawRequested when safe area changes
madsmtm Sep 10, 2024
01552d5
Move docs on safe area to # Drawing on the window
madsmtm Sep 11, 2024
45326fb
Remove comment about CSD in safe_area on wayland
madsmtm Sep 11, 2024
c651490
Remove fixmes, use issue to track instead
madsmtm Sep 11, 2024
c1ea82a
Change note on negative surface position
madsmtm Sep 11, 2024
39f40c7
Make safe area position vs. size a bit clearer
madsmtm Sep 11, 2024
131eaa1
Add dot and arrow to the start and end of position indicators
madsmtm Sep 11, 2024
62a95a5
macOS: Guarantee that SurfaceResized is emitted on safe area change
madsmtm Sep 11, 2024
3b3928e
Don't mention Alacritty
madsmtm Sep 11, 2024
992778a
Comment before mobile picture
madsmtm Sep 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,14 @@
//! [`visible` set to `false`][crate::window::WindowAttributes::with_visible] and explicitly make
//! the window visible only once you're ready to render into it.
//!
//! There is another important concept you need to know about when drawing: the "safe area". This
//! can be accessed with [`Window::safe_area`], and describes a rectangle in the surface that is not
//! obscured by notches, the status bar, and so on. You should be drawing your background and
//! non-important content on the entire surface, but restrict important content (such as
//! interactable UIs, text, etc.) to only being drawn inside the safe area.
//!
//! [`Window::safe_area`]: crate::window::Window::safe_area
//!
//! # Coordinate systems
//!
//! Windowing systems use many different coordinate systems, and this is reflected in Winit as well;
Expand All @@ -138,17 +146,13 @@
//! between these three coordinate systems, although you should still strive to handle this, as
//! they're still relevant in more niche area such as Mac Catalyst, or multi-tasking on tablets.
//!
//! There is, however, a different important concept: The "safe area". This can be accessed with
//! [`Window::safe_area`], and describes a rectangle in the surface that is not obscured by notches,
//! the status bar, and so on. You should be drawing your background and non-important content on
//! the entire surface, but restrict important content (such as interactable UIs, text, etc.) to
//! being drawn in the safe area.
//! Note that the safe area (discussed above) is especially important here, since windows on mobile
//! are often full screen, and often the device has notches (as illustrated in the image below).
madsmtm marked this conversation as resolved.
Show resolved Hide resolved
#![doc = concat!("\n\n", include_str!("../docs/res/coordinate-systems-mobile.svg"), "\n\n")] // Rustfmt removes \n, re-add them
//! [`Window::surface_position`]: crate::window::Window::surface_position
//! [`Window::surface_size`]: crate::window::Window::surface_size
//! [`Window::outer_position`]: crate::window::Window::outer_position
//! [`Window::outer_size`]: crate::window::Window::outer_size
//! [`Window::safe_area`]: crate::window::Window::safe_area
//!
//! # UI scaling
//!
Expand Down