pub struct WindowInsets {
pub padding: Insets,
pub view_insets: Insets,
pub view_padding: Insets,
}Expand description
The window insets, split by nature: padding is the area permanently
taken by the system (status and navigation bars, the notch — all static), while
view_insets is the area covered by transient UI, chiefly the soft
keyboard. Avoiding the keyboard means keeping content clear of
WindowInsets::safe.
Fields§
§padding: InsetsPermanent system areas (bars, notch) that are still worth avoiding: the
intrusions, less whatever view_insets already covers.
Zero at the bottom while the keyboard is up, because the navigation bar it hides is not an edge anything needs to stay clear of any more. Padding a screen by it as well would leave a strip of nothing between the content and the keyboard.
view_insets: InsetsTransient areas (the soft keyboard); in practice only the bottom moves.
Measured from the window edge, so it already includes whatever bar it covers.
view_padding: InsetsThe intrusions ignoring anything transient: what the notch and the bars take whether or not the keyboard is over them.
The one that does not move when the keyboard opens, which is why a layout that
must not shift reads this rather than padding.
Implementations§
Source§impl WindowInsets
impl WindowInsets
Sourcepub const ZERO: WindowInsets
pub const ZERO: WindowInsets
No insets at all.
Sourcepub const fn bars(intrusions: Insets) -> WindowInsets
pub const fn bars(intrusions: Insets) -> WindowInsets
The intrusions of a surface with nothing transient over them: the bars and the notch, and no keyboard.
Here so that nobody has to assemble the three by hand and get them disagreeing.
padding and view_padding are the same thing while there is no keyboard, and
a hand-written literal that says otherwise describes a surface no platform can
report.
Sourcepub fn safe(&self) -> Insets
pub fn safe(&self) -> Insets
The total area to avoid: the per-side maximum of the two kinds. The keyboard covers the navigation bar, so they are not added together.
Sourcepub fn from_baseline(baseline: Insets, current: Insets) -> WindowInsets
pub fn from_baseline(baseline: Insets, current: Insets) -> WindowInsets
Splits raw insets into (padding, view_insets) given a keyboard-free
reference. A bottom excess beyond that reference signals the keyboard;
view_insets.bottom then measures the total occlusion from the window
edge, bar included. That is what makes combining the two with max
correct.
Trait Implementations§
Source§impl Clone for WindowInsets
impl Clone for WindowInsets
Source§fn clone(&self) -> WindowInsets
fn clone(&self) -> WindowInsets
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more