Skip to main content

Cached

Struct Cached 

Source
pub struct Cached {
    pub rect: Rect,
    pub visible: bool,
    /* private fields */
}
Expand description

A component with memoized geometry, its last placed rectangle, and any in-flight property transitions.

Fields§

§rect: Rect

Last outer rectangle assigned by layout.

§visible: bool

Whether the component participates in layout, paint, and focus.

Implementations§

Source§

impl Cached

Source

pub fn new(comp: Box<dyn Component>) -> Self

Wraps a component with empty geometry caches.

Source

pub fn measure(&mut self, ctx: &UiContext) -> (u16, u16)

Returns memoized outer width bounds, including padding and border.

The process-wide width epoch and the context revision are part of the memo key, so changing the terminal’s Jamo policy or swapping the presentation context remeasures unchanged component trees.

Source

pub fn height(&mut self, ctx: &UiContext, width: u16) -> u16

Returns memoized outer height at width, including padding and border.

Source

pub fn place(&mut self, ctx: &UiContext, rect: Rect)

Stores the outer rectangle and places children inside its content box.

A lift component rests at the bottom of its rectangle; the reserved headroom above is where the chrome rises while hovered.

Source

pub fn paint(&mut self, pc: &mut PaintCtx<'_>)

Paints border and content, then restores this component’s background.

When anim/spin properties are live, sampled solid colors are swapped into the props for the duration of this call and restored afterward, so content and chrome both paint the mid-flight value. Hover chrome follows the pointer or keyboard focus: a ramped hover under a live pointer renders as a tracking glow over the resting chrome, under keyboard focus it blooms from the chrome’s center until it blankets the ring, every other hovered case swaps into the border slot, and lift raises the chrome into the headroom its rectangle reserves, leaving a shadow.

Source

pub const fn invalidate(&mut self)

Invalidates both geometry memos.

Source

pub fn update<R>( &mut self, slot: Slot, f: impl FnOnce(&mut Self) -> (R, bool), ) -> Option<R>

Mutates a component selected by slot and invalidates a dirty ancestor path.

Source

pub fn update_id<R>( &mut self, id: &str, f: impl FnOnce(&mut Self) -> (R, bool), ) -> Option<R>

Mutates a component selected by id and invalidates a dirty ancestor path.

Source

pub fn find_slot(&mut self, slot: Slot) -> Option<&mut Self>

Finds a component by slot without invalidating geometry.

Source

pub fn comp(&self) -> &dyn Component

Borrows the wrapped component.

Source

pub fn comp_mut(&mut self) -> &mut dyn Component

Borrows the wrapped component mutably; callers must invalidate after mutation.

Trait Implementations§

Source§

impl IntoChildren for Cached

Source§

fn extend_children(self, out: &mut Vec<Cached>)

Appends all represented children to out.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Cached

§

impl !Send for Cached

§

impl !Sync for Cached

§

impl !UnwindSafe for Cached

§

impl Freeze for Cached

§

impl Unpin for Cached

§

impl UnsafeUnpin for Cached

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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
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<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. 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.