pub struct Painter(/* private fields */);Expand description
A component’s line back to the view that paints it.
Component state that outlives a render — a hover fade, a gesture — has to
name its view, because event-dispatch context cannot resolve one and the
only alternative left is refreshing the whole window. Holding a Painter
is what makes the two sanctioned frame requests reachable, and it is the
one surface to review when asking who in the library can ask for a frame.
Implementations§
Source§impl Painter
impl Painter
Sourcepub fn of<T: 'static>(cx: &Context<'_, T>) -> Self
pub fn of<T: 'static>(cx: &Context<'_, T>) -> Self
The view this render belongs to. Take it once, where the state is built, and keep it for as long as the state lives.
Sourcepub fn lease(self, fps: f32, until: Duration, cx: &mut App)
pub fn lease(self, fps: f32, until: Duration, cx: &mut App)
Claim fps redraws a second, lapsing until from now unless something
renews it. One timer serves the whole app: it wakes only when a view is
owed a frame, notifies that view alone, and parks when the last claim
lapses.
This is the drive for any repeating animation, yours included. gpui’s
with_animation(…).repeat() asks the window for a frame at the
display’s rate for as long as it stays mounted, and one such element is
enough to hold the whole window there.
Renew it from render — that is what makes a claim self-cancelling,
since an element that unmounts stops renewing and drops off. The rate is
a per-view minimum of everything claiming it, so a 60fps claim never
drags a 30fps one up with it.
Trait Implementations§
impl Copy for Painter
impl Eq for Painter
impl StructuralPartialEq for Painter
Auto Trait Implementations§
impl Freeze for Painter
impl RefUnwindSafe for Painter
impl Send for Painter
impl Sync for Painter
impl Unpin for Painter
impl UnsafeUnpin for Painter
impl UnwindSafe for Painter
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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