Skip to main content

SizeConstraints

Struct SizeConstraints 

Source
pub struct SizeConstraints {
    pub min: Option<LogicalSize>,
    pub max: Option<LogicalSize>,
    pub aspect: Option<AspectRatio>,
}
Expand description

Limits the window system should enforce on an interactive resize.

All three are hints in the strict sense: a tiling window manager honours none of them, and Wayland has no aspect hint at all. Consumers must stay correct when they are ignored — which for aspect means letterboxing in-renderer with AspectRatio::fit, the universal fallback.

Fields§

§min: Option<LogicalSize>

Smallest client area the user may resize to.

§max: Option<LogicalSize>

Largest client area the user may resize to.

§aspect: Option<AspectRatio>

Ratio the client area should keep during a resize.

Honoured natively only where ShellCaps::ASPECT_HINT_HONORED is set. Where it is not, a backend picks the nearest aspect-correct size it is allowed to pick and the renderer letterboxes the remainder.

Implementations§

Source§

impl SizeConstraints

Source

pub const NONE: Self

No constraints at all.

Source

pub const fn min(size: LogicalSize) -> Self

Constraints with a minimum size and nothing else.

Source

pub const fn with_aspect(self, aspect: AspectRatio) -> Self

These constraints with an aspect lock added.

Source

pub fn apply(&self, size: PhysicalSize, scale_factor: f64) -> PhysicalSize

Applies the constraints to a physical size, as a backend that cannot delegate to the window system would.

Clamping happens before the aspect fit, so the result never exceeds max. It can fall below min when an aspect lock demands it: a size that violates the aspect ratio is visibly wrong, while one a few pixels under the minimum is not, and something has to give when the two disagree.

HeadlessShell applies this, which is what makes constraint behaviour testable without a window manager.

Trait Implementations§

Source§

impl Clone for SizeConstraints

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for SizeConstraints

Source§

impl Debug for SizeConstraints

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SizeConstraints

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for SizeConstraints

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for SizeConstraints

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.