Struct ClipStackSnapshot

Source
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.

Source

pub fn empty() -> Self

Returns a snapshot containing no clipping constraints.

§Examples
use ailloli_ui_runtime::scene::ClipStackSnapshot;
assert!(ClipStackSnapshot::empty().is_empty());
Source

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]);
Source

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());
Source

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);
Source

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());
Source

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)));
Source

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));
Source

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

Source§

fn clone(&self) -> ClipStackSnapshot

Returns a copy 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 ClipStackSnapshot

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for ClipStackSnapshot

Source§

fn default() -> ClipStackSnapshot

Returns the “default value” for a type. Read more
Source§

impl PartialEq for ClipStackSnapshot

Source§

fn eq(&self, other: &ClipStackSnapshot) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for ClipStackSnapshot

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<A> IntoClickAction<A> for A
where A: Clone + 'static,

Source§

fn into_click_action(self) -> ClickAction<A>

Implements the into_click_action helper used by this module.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
§

impl<T> Brush for T
where T: Clone + PartialEq + Default + Debug,

§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> Props for T
where T: Clone + 'static,