pub struct ClipStackSnapshot { /* private fields */ }Expand description
Immutable view of the active clip stack for one paint layer.
Entry order is outermost to innermost. Snapshots own a cloned vector and do
not change if the originating ClipStack is later mutated.
§Examples
use ailloli_ui_runtime::scene::ClipStackSnapshot;
let snapshot = ClipStackSnapshot::empty();
assert!(snapshot.entries().is_empty());Implementations§
Source§impl ClipStackSnapshot
Provides the operations defined for ClipStackSnapshot.
impl ClipStackSnapshot
Provides the operations defined for ClipStackSnapshot.
Sourcepub fn empty() -> Self
pub fn empty() -> Self
Returns a snapshot containing no clipping constraints.
§Examples
use ailloli_ui_runtime::scene::ClipStackSnapshot;
assert!(ClipStackSnapshot::empty().is_empty());Sourcepub fn from_entries(entries: Vec<ClipEntry>) -> Self
pub fn from_entries(entries: Vec<ClipEntry>) -> Self
Takes ownership of entries in their existing outer-to-inner order.
Empty, duplicate, and mutually disjoint shapes are accepted.
§Examples
use ailloli_ui_core::{ClipShape, Rect};
use ailloli_ui_runtime::scene::{ClipEntry, ClipStackSnapshot};
let entry = ClipEntry::new(ClipShape::Rect(Rect::new(0.0, 0.0, 10.0, 10.0)), false);
assert_eq!(ClipStackSnapshot::from_entries(vec![entry]).entries(), &[entry]);Sourcepub fn from_clip(clip: Option<ClipShape>, is_window_root: bool) -> Self
pub fn from_clip(clip: Option<ClipShape>, is_window_root: bool) -> Self
Builds an empty or single-entry snapshot from an optional shape.
is_window_root is ignored when clip is None.
§Examples
use ailloli_ui_runtime::scene::ClipStackSnapshot;
assert!(ClipStackSnapshot::from_clip(None, true).is_empty());Sourcepub fn entries(&self) -> &[ClipEntry]
pub fn entries(&self) -> &[ClipEntry]
Borrows entries in outer-to-inner order without allocating.
§Examples
use ailloli_ui_core::{ClipShape, Rect};
use ailloli_ui_runtime::scene::ClipStackSnapshot;
let snapshot = ClipStackSnapshot::from_clip(
Some(ClipShape::Rect(Rect::new(0.0, 0.0, 5.0, 6.0))), false,
);
assert_eq!(snapshot.entries().len(), 1);Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true exactly when there are no clip entries.
§Examples
use ailloli_ui_runtime::scene::ClipStackSnapshot;
assert!(ClipStackSnapshot::default().is_empty());Sourcepub fn scissor_rect(&self) -> Option<Rect>
pub fn scissor_rect(&self) -> Option<Rect>
Returns the axis-aligned intersection of all clip bounding rectangles.
The result is used as a coarse GPU scissor; it does not preserve rounded
corners. None means either no clip or an empty intersection, so callers
needing to distinguish those cases must also inspect Self::is_empty.
§Examples
use ailloli_ui_core::{ClipShape, Rect};
use ailloli_ui_runtime::scene::{ClipEntry, ClipStackSnapshot};
let snapshot = ClipStackSnapshot::from_entries(vec![
ClipEntry::new(ClipShape::Rect(Rect::new(0.0, 0.0, 10.0, 10.0)), false),
ClipEntry::new(ClipShape::Rect(Rect::new(5.0, 2.0, 10.0, 4.0)), false),
]);
assert_eq!(snapshot.scissor_rect(), Some(Rect::new(5.0, 2.0, 5.0, 4.0)));Sourcepub fn single_shape(&self) -> Option<ClipShape>
pub fn single_shape(&self) -> Option<ClipShape>
Returns one representable clip shape for legacy callers.
Empty snapshots return None, one entry preserves its exact shape, and
two or more rectangles collapse to their intersection. Any multi-entry
stack containing a rounded rectangle returns None because flattening
it would lose shape or root metadata.
§Examples
use ailloli_ui_core::{ClipShape, Rect};
use ailloli_ui_runtime::scene::ClipStackSnapshot;
let shape = ClipShape::RoundRect { rect: Rect::new(0.0, 0.0, 20.0, 10.0), radius: 3.0 };
assert_eq!(ClipStackSnapshot::from_clip(Some(shape), true).single_shape(), Some(shape));Sourcepub fn contains_point(&self, px: f32, py: f32) -> bool
pub fn contains_point(&self, px: f32, py: f32) -> bool
Tests whether every clip shape contains a logical-pixel point.
An empty snapshot contains every point (vacuous intersection). Shape
boundary and non-finite-coordinate behavior comes from [ClipShape].
§Examples
use ailloli_ui_core::{ClipShape, Rect};
use ailloli_ui_runtime::scene::ClipStackSnapshot;
let snapshot = ClipStackSnapshot::from_clip(
Some(ClipShape::Rect(Rect::new(0.0, 0.0, 10.0, 10.0))), false,
);
assert!(snapshot.contains_point(4.0, 5.0));
assert!(!snapshot.contains_point(14.0, 5.0));Trait Implementations§
Source§impl Clone for ClipStackSnapshot
impl Clone for ClipStackSnapshot
Source§fn clone(&self) -> ClipStackSnapshot
fn clone(&self) -> ClipStackSnapshot
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ClipStackSnapshot
impl Debug for ClipStackSnapshot
Source§impl Default for ClipStackSnapshot
impl Default for ClipStackSnapshot
Source§fn default() -> ClipStackSnapshot
fn default() -> ClipStackSnapshot
Source§impl PartialEq for ClipStackSnapshot
impl PartialEq for ClipStackSnapshot
impl StructuralPartialEq for ClipStackSnapshot
Auto Trait Implementations§
impl Freeze for ClipStackSnapshot
impl RefUnwindSafe for ClipStackSnapshot
impl Send for ClipStackSnapshot
impl Sync for ClipStackSnapshot
impl Unpin for ClipStackSnapshot
impl UnwindSafe for ClipStackSnapshot
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<A> IntoClickAction<A> for Awhere
A: Clone + 'static,
impl<A> IntoClickAction<A> for Awhere
A: Clone + 'static,
Source§fn into_click_action(self) -> ClickAction<A>
fn into_click_action(self) -> ClickAction<A>
Implements the into_click_action helper used by this module.