Skip to main content

ResponsiveLayout

Struct ResponsiveLayout 

Source
pub struct ResponsiveLayout { /* private fields */ }
Expand description

A breakpoint-aware layout that switches Flex configuration at different terminal widths.

Wraps Responsive<Flex> with auto-detection of breakpoints from area width. Each breakpoint tier can define a completely different layout (direction, constraints, gaps, margins).

Implementations§

Source§

impl ResponsiveLayout

Source

pub fn new(base: Flex) -> Self

Create a responsive layout with a base layout for Xs.

All larger breakpoints inherit this layout until explicitly overridden.

Source

pub fn at(self, bp: Breakpoint, layout: Flex) -> Self

Set the layout for a specific breakpoint (builder pattern).

Source

pub fn with_breakpoints(self, breakpoints: Breakpoints) -> Self

Override the breakpoint thresholds (builder pattern).

Defaults to Breakpoints::DEFAULT (60/90/120/160).

Source

pub fn set(&mut self, bp: Breakpoint, layout: Flex)

Set the layout for a specific breakpoint (mutating).

Source

pub fn clear(&mut self, bp: Breakpoint)

Clear the override for a specific breakpoint, reverting to inheritance.

Clearing Xs is a no-op.

Source§

impl ResponsiveLayout

Source

pub fn split(&self, area: Rect) -> ResponsiveSplit

Split the area using auto-detected breakpoint from width.

Classifies area.width into a Breakpoint, resolves the corresponding Flex, and splits the area.

Source

pub fn split_for(&self, bp: Breakpoint, area: Rect) -> ResponsiveSplit

Split the area using an explicit breakpoint.

Use this when you already know the active breakpoint (e.g., from a shared app-level breakpoint state).

Source

pub fn classify(&self, width: u16) -> Breakpoint

Get the active breakpoint for a given width.

Source

pub fn layout_for(&self, bp: Breakpoint) -> &Flex

Get the Flex configuration for a given breakpoint.

Source

pub fn has_explicit(&self, bp: Breakpoint) -> bool

Whether a specific breakpoint has an explicit (non-inherited) layout.

Source

pub fn breakpoints(&self) -> Breakpoints

Get the breakpoint thresholds.

Source

pub fn constraint_count(&self, bp: Breakpoint) -> usize

Number of rects that would be produced for a given breakpoint.

Useful for pre-allocating or checking layout changes without performing the full split.

Source

pub fn detect_transition( &self, old_width: u16, new_width: u16, ) -> Option<(Breakpoint, Breakpoint)>

Check if a width change would cause a breakpoint transition.

Returns Some((old, new)) if the breakpoint changed, None otherwise.

Trait Implementations§

Source§

impl Clone for ResponsiveLayout

Source§

fn clone(&self) -> ResponsiveLayout

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ResponsiveLayout

Source§

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

Formats the value using the given formatter. Read more

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.