pub struct Visibility { /* private fields */ }Expand description
Breakpoint-aware visibility rule.
Encodes which breakpoints a widget should be visible at.
Use with filter_rects to reclaim space from
hidden widgets during layout.
Implementations§
Source§impl Visibility
impl Visibility
Source§impl Visibility
impl Visibility
Sourcepub const fn visible_above(bp: Breakpoint) -> Self
pub const fn visible_above(bp: Breakpoint) -> Self
Visible at the given breakpoint and all larger ones.
Example: visible_above(Md) → visible at Md, Lg, Xl.
Sourcepub const fn visible_below(bp: Breakpoint) -> Self
pub const fn visible_below(bp: Breakpoint) -> Self
Visible at the given breakpoint and all smaller ones.
Example: visible_below(Md) → visible at Xs, Sm, Md.
Sourcepub const fn only(bp: Breakpoint) -> Self
pub const fn only(bp: Breakpoint) -> Self
Visible at exactly one breakpoint.
Sourcepub fn at(breakpoints: &[Breakpoint]) -> Self
pub fn at(breakpoints: &[Breakpoint]) -> Self
Visible at the specified breakpoints.
Hidden at the given breakpoint and all smaller ones (visible above).
Example: hidden_below(Md) → hidden at Xs, Sm; visible at Md, Lg, Xl.
Hidden at the given breakpoint and all larger ones (visible below).
Example: hidden_above(Md) → visible at Xs, Sm; hidden at Md, Lg, Xl.
Source§impl Visibility
impl Visibility
Sourcepub const fn is_visible(self, bp: Breakpoint) -> bool
pub const fn is_visible(self, bp: Breakpoint) -> bool
Whether the widget is visible at the given breakpoint.
Whether the widget is hidden at the given breakpoint.
Sourcepub const fn is_always(self) -> bool
pub const fn is_always(self) -> bool
Whether the widget is always visible (at every breakpoint).
Sourcepub const fn is_never(self) -> bool
pub const fn is_never(self) -> bool
Whether the widget is never visible (hidden at every breakpoint).
Sourcepub const fn visible_count(self) -> u32
pub const fn visible_count(self) -> u32
Count of breakpoints where this is visible.
Sourcepub fn visible_breakpoints(self) -> impl Iterator<Item = Breakpoint>
pub fn visible_breakpoints(self) -> impl Iterator<Item = Breakpoint>
Iterator over breakpoints where visible.
Source§impl Visibility
impl Visibility
Sourcepub fn filter_rects<'a>(
visibilities: &'a [Visibility],
rects: &'a [Rect],
bp: Breakpoint,
) -> Vec<(usize, Rect)>
pub fn filter_rects<'a>( visibilities: &'a [Visibility], rects: &'a [Rect], bp: Breakpoint, ) -> Vec<(usize, Rect)>
Filter a list of rects, keeping only those whose visibility allows the given breakpoint.
Returns (index, rect) pairs for visible items. The index is the
original position in the input, useful for mapping back to widget state.
This achieves space reclamation: hidden widgets don’t get any layout area.
Sourcepub fn count_visible(visibilities: &[Visibility], bp: Breakpoint) -> usize
pub fn count_visible(visibilities: &[Visibility], bp: Breakpoint) -> usize
Count how many items are visible at a given breakpoint.
Trait Implementations§
Source§impl Clone for Visibility
impl Clone for Visibility
Source§fn clone(&self) -> Visibility
fn clone(&self) -> Visibility
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more