pub struct UiPanelHost {
ctx: Context,
time: f64,
render: JobSender,
screen: SnapshotReader<UiTarget>,
slot: usize,
event_scratch: Vec<Event>,
input_scratch: Vec<InputEvent>,
laid_out_at: Option<UiTarget>,
repaint_at: Option<f64>,
}Expand description
A world’s panel publishing: the context its panels are built in, where its frames are sent and the target it lays out against.
Spawn it in the world holding the panels. Nothing drives this from outside: the world ticks it, the way it ticks any other behaviour, and each tick that produced a frame sends it to the drawing world. A tick that could not change the picture — a settled panel, no input, the same target — sends nothing, so an idle UI costs nothing.
The context, its font atlas and its memory belong to this world and stay there: what crosses to the drawing side is the laid-out frame, which carries no borrow of any of them.
Fields§
§ctx: ContextThe context the panels in this world are built in.
time: f64The frame time this host has been driven through, in seconds.
egui’s animations are paced by it, so a run that steps the same deltas draws the same picture however long those steps took: an animation is over after a number of frames rather than after an amount of wall clock, which is what lets a snapshot of a panel be compared.
render: JobSenderThe queue of the world that draws the frames.
screen: SnapshotReader<UiTarget>The target the drawing side last drew at.
slot: usizeWhich slot this world’s frames go in.
event_scratch: Vec<Event>The events of the frame being laid out, reclaimed from egui once the pass is over so the next frame reuses the allocation.
input_scratch: Vec<InputEvent>The world’s events for the frame being laid out, copied out of its buffer before anything is laid out so the allocation is reused.
laid_out_at: Option<UiTarget>The target the last frame was laid out at, or None before there is
one.
The first tick always lays a frame out, and a tick whose target differs lays one out again however settled the panel is: the drawing side drops a frame laid out at another size, and this is what replaces it. A frame the drawing world’s queue refused leaves this behind, so the next tick sends it again.
repaint_at: Option<f64>The moment, in this host’s own time, at which the last frame laid out asked to be laid out again: a frame that named a moment rather than asking for the next possible pass.
Implementations§
Source§impl UiPanelHost
impl UiPanelHost
Sourcepub fn new(
render: JobSender,
screen: SnapshotReader<UiTarget>,
slot: usize,
) -> Self
pub fn new( render: JobSender, screen: SnapshotReader<UiTarget>, slot: usize, ) -> Self
Publish world’s panels into slot slot of the world behind
render, against the target screen carries.
Sourcepub fn context(&self) -> &Context
pub fn context(&self) -> &Context
The context the panels in this world are built in, for setting its style or fonts up before the first frame is laid out.
Sourcepub fn publish(&mut self, world: &World, frame: &Frame)
pub fn publish(&mut self, world: &World, frame: &Frame)
Lay out this tick’s frame and send it to the drawing world, if it could differ from the one that world holds.
The frame is laid out here rather than where it is drawn because only this world holds the panels and their context. A tick lays one out when something could have changed the picture: the drawing side has not been seen yet, the target moved, input arrived, or the last frame asked to be laid out again — either at once or once a delay it named has elapsed. Anything else draws the same picture, so nothing is laid out and nothing is sent.
A frame the drawing world’s queue refused is sent again on the next tick. A frame whose queue is closed has nowhere to go and is forgotten: the drawing world is gone.
The events are this world’s own, read from its InputEvents: a panel
sees exactly what the rest of the world sees on the same tick.
frame is the frame being stepped, and its duration is what moves this
host’s own clock on. egui paces its animations by that clock, so a panel
animated across a run of frames looks the same at the same frame however
long the run took: a capture compared against a stored picture does not
depend on how busy the machine was. A frame that named a moment to be
laid out again is due once the clock has reached it.
Auto Trait Implementations§
impl !RefUnwindSafe for UiPanelHost
impl !UnwindSafe for UiPanelHost
impl Forget for UiPanelHost
impl Freeze for UiPanelHost
impl Send for UiPanelHost
impl Sync for UiPanelHost
impl Unpin for UiPanelHost
impl UnsafeUnpin for UiPanelHost
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
impl<T> Component for Twhere
T: 'static,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§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§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
impl<T> MaybeSync for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<F, T, S> SimdInto<T, S> for Fwhere
T: SimdFrom<F, S>,
S: Simd,
impl<F, T, S> SimdInto<T, S> for Fwhere
T: SimdFrom<F, S>,
S: Simd,
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.