Skip to main content

LayoutGeometry

Struct LayoutGeometry 

Source
pub struct LayoutGeometry {
    pub content_box: Rect,
    pub padding_box: Rect,
    pub border_box: Rect,
    pub margin_box: Rect,
    pub scroll_bounds: Size,
    pub scroll_offset: Point,
    pub has_scroll: (bool, bool),
}
Expand description

The concentric boxes and scroll metrics forming the CSS Box Model for an element.

Fields§

§content_box: Rect

Content box (where inner text and child elements reside).

§padding_box: Rect

Padding box (content box expanded by padding insets).

§border_box: Rect

Border box (padding box expanded by border widths). This is the primary rectangle used for element rendering and layout bounds.

§margin_box: Rect

Margin box (border box expanded by margin insets).

§scroll_bounds: Size

Total scrollable content extent (width, height) enclosing all overflowing children.

§scroll_offset: Point

Current scroll offset (scroll_x, scroll_y).

§has_scroll: (bool, bool)

Whether element has scrollable overflow along (horizontal, vertical) axes.

Implementations§

Source§

impl LayoutGeometry

Source

pub fn is_finite(&self) -> bool

Returns true if all concentric boxes contain strictly finite coordinates.

Source

pub fn sanitize(&mut self)

Sanitizes all concentric rectangles to strictly finite values.

Source

pub fn max_scroll(&self) -> Point

Returns the maximum allowable scroll offset (max_x, max_y).

Source

pub fn is_scroll_container(&self) -> bool

Returns true if this element is an active scroll container.

Source

pub fn clamp_scroll_offset(&self, offset: Point) -> Point

Clamps a candidate scroll offset to valid bounds [0, max_scroll].

Source

pub fn from_border_box( border_box: Rect, padding: EdgeInsets<f32>, border: EdgeInsets<f32>, margin: EdgeInsets<f32>, ) -> Self

Computes concentric boxes from a given border_box and padding/border/margin insets.

Source

pub fn from_border_box_with_scroll( border_box: Rect, padding: EdgeInsets<f32>, border: EdgeInsets<f32>, margin: EdgeInsets<f32>, scroll_offset: Point, ) -> Self

Computes concentric boxes while preserving the specified scroll offset.

Source

pub fn translate(&mut self, dx: f32, dy: f32)

Translates all concentric rectangles by (dx, dy).

Source

pub fn snap_to_pixel(&mut self)

Snaps all concentric rectangles to Chromium subpixel coordinates.

Source

pub fn snap_to_scale(&mut self, scale: f32)

Snaps all concentric rectangles against a device scale factor.

Trait Implementations§

Source§

impl Clone for LayoutGeometry

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 LayoutGeometry

Source§

impl Debug for LayoutGeometry

Source§

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

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

impl Default for LayoutGeometry

Source§

fn default() -> Self

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

impl PartialEq for LayoutGeometry

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 LayoutGeometry

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.