sequoia_layout/overflow.rs
1//! Overflow handling modes for content that exceeds its container.
2
3/// How a container handles content that exceeds its bounds.
4#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
5#[non_exhaustive]
6pub enum Overflow {
7 /// Content may draw outside the container.
8 #[default]
9 Visible,
10 /// Content outside the container is clipped.
11 Hidden,
12 /// Content is clipped and can be scrolled by the user.
13 Scroll,
14 /// Content is clipped and scrollable only when it overflows.
15 Auto,
16}
17
18impl Overflow {
19 /// Returns `true` if content outside the container should be clipped.
20 pub fn clips(self) -> bool {
21 matches!(self, Self::Hidden | Self::Scroll | Self::Auto)
22 }
23
24 /// Returns `true` if the container can be scrolled.
25 pub fn is_scrollable(self) -> bool {
26 matches!(self, Self::Scroll | Self::Auto)
27 }
28
29 /// Returns `true` if overflow is visible.
30 pub const fn is_visible(self) -> bool {
31 matches!(self, Self::Visible)
32 }
33}