pub struct ClipStack { /* private fields */ }Expand description
Mutable hierarchical clip stack for paint passes.
Entries are last-in, first-out; this type performs no automatic scope
restoration. Use crate::scene::PaintCtx helpers when closure-based
restoration is required.
§Examples
use ailloli_ui_core::{ClipShape, Rect};
use ailloli_ui_runtime::scene::ClipStack;
let mut stack = ClipStack::new();
stack.push(ClipShape::Rect(Rect::new(0.0, 0.0, 10.0, 10.0)), false);
assert_eq!(stack.snapshot().entries().len(), 1);Implementations§
Source§impl ClipStack
Provides the operations defined for ClipStack.
impl ClipStack
Provides the operations defined for ClipStack.
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates an empty stack.
§Examples
use ailloli_ui_runtime::scene::ClipStack;
assert!(ClipStack::new().is_empty());Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true exactly when the stack contains no entries.
§Examples
use ailloli_ui_runtime::scene::ClipStack;
assert!(ClipStack::default().is_empty());Sourcepub fn push(&mut self, clip: ClipShape, is_window_root: bool)
pub fn push(&mut self, clip: ClipShape, is_window_root: bool)
Pushes an unvalidated clip as the new innermost entry.
§Examples
use ailloli_ui_core::{ClipShape, Rect};
use ailloli_ui_runtime::scene::ClipStack;
let mut stack = ClipStack::new();
stack.push(ClipShape::Rect(Rect::new(0.0, 0.0, 8.0, 8.0)), true);
assert!(stack.snapshot().entries()[0].is_window_root);Sourcepub fn pop(&mut self) -> Option<ClipEntry>
pub fn pop(&mut self) -> Option<ClipEntry>
Removes and returns the innermost entry, or None when empty.
§Examples
use ailloli_ui_runtime::scene::ClipStack;
let mut stack = ClipStack::new();
assert_eq!(stack.pop(), None);Sourcepub fn snapshot(&self) -> ClipStackSnapshot
pub fn snapshot(&self) -> ClipStackSnapshot
Clones the current entries into an immutable snapshot.
§Examples
use ailloli_ui_core::{ClipShape, Rect};
use ailloli_ui_runtime::scene::ClipStack;
let mut stack = ClipStack::new();
stack.push(ClipShape::Rect(Rect::new(0.0, 0.0, 2.0, 2.0)), false);
let snapshot = stack.snapshot();
stack.pop();
assert_eq!(snapshot.entries().len(), 1);Sourcepub fn current(&self) -> Option<ClipShape>
pub fn current(&self) -> Option<ClipShape>
Returns a legacy single-shape representation of the current stack.
See ClipStackSnapshot::single_shape for lossy-stack rules.
§Examples
use ailloli_ui_runtime::scene::ClipStack;
assert_eq!(ClipStack::new().current(), None);Sourcepub fn current_bbox(&self) -> Option<Rect>
pub fn current_bbox(&self) -> Option<Rect>
Returns axis-aligned intersection bounds for the current clip stack.
None represents both an empty stack and disjoint clip bounds; use
Self::is_empty when that distinction matters.
§Examples
use ailloli_ui_core::{ClipShape, Rect};
use ailloli_ui_runtime::scene::ClipStack;
let mut stack = ClipStack::new();
stack.push(ClipShape::Rect(Rect::new(1.0, 2.0, 3.0, 4.0)), false);
assert_eq!(stack.current_bbox(), Some(Rect::new(1.0, 2.0, 3.0, 4.0)));Trait Implementations§
Auto Trait Implementations§
impl Freeze for ClipStack
impl RefUnwindSafe for ClipStack
impl Send for ClipStack
impl Sync for ClipStack
impl Unpin for ClipStack
impl UnwindSafe for ClipStack
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.