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
impl ResponsiveLayout
Sourcepub fn new(base: Flex) -> Self
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.
Sourcepub fn at(self, bp: Breakpoint, layout: Flex) -> Self
pub fn at(self, bp: Breakpoint, layout: Flex) -> Self
Set the layout for a specific breakpoint (builder pattern).
Sourcepub fn with_breakpoints(self, breakpoints: Breakpoints) -> Self
pub fn with_breakpoints(self, breakpoints: Breakpoints) -> Self
Override the breakpoint thresholds (builder pattern).
Defaults to Breakpoints::DEFAULT (60/90/120/160).
Sourcepub fn set(&mut self, bp: Breakpoint, layout: Flex)
pub fn set(&mut self, bp: Breakpoint, layout: Flex)
Set the layout for a specific breakpoint (mutating).
Sourcepub fn clear(&mut self, bp: Breakpoint)
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
impl ResponsiveLayout
Sourcepub fn split(&self, area: Rect) -> ResponsiveSplit
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.
Sourcepub fn split_for(&self, bp: Breakpoint, area: Rect) -> ResponsiveSplit
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).
Sourcepub fn classify(&self, width: u16) -> Breakpoint
pub fn classify(&self, width: u16) -> Breakpoint
Get the active breakpoint for a given width.
Sourcepub fn layout_for(&self, bp: Breakpoint) -> &Flex
pub fn layout_for(&self, bp: Breakpoint) -> &Flex
Get the Flex configuration for a given breakpoint.
Sourcepub fn has_explicit(&self, bp: Breakpoint) -> bool
pub fn has_explicit(&self, bp: Breakpoint) -> bool
Whether a specific breakpoint has an explicit (non-inherited) layout.
Sourcepub fn breakpoints(&self) -> Breakpoints
pub fn breakpoints(&self) -> Breakpoints
Get the breakpoint thresholds.
Sourcepub fn constraint_count(&self, bp: Breakpoint) -> usize
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.
Sourcepub fn detect_transition(
&self,
old_width: u16,
new_width: u16,
) -> Option<(Breakpoint, Breakpoint)>
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
impl Clone for ResponsiveLayout
Source§fn clone(&self) -> ResponsiveLayout
fn clone(&self) -> ResponsiveLayout
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more