Expand description
UI panels laid out in one world and drawn in another. UI panels laid out in one world and drawn in another.
A unlit3d::ui::UiPanel can only be built where its egui::Context runs: the
callback is handed a &mut egui::Ui, which belongs to the pass building it,
so it cannot be carried to another thread. A UI whose panels belong to one
world and whose drawing belongs to another therefore crosses the boundary as
data: the panelβs world lays the frame out and tessellates it, and the
drawing world uploads and records what comes back.
The handover is one way: the panel world sends a job carrying an
unlit3d::ui::ExternalFrame to the world holding the
unlit3d::ui::UiSource, which keeps it in a slot and draws it. A settled
panel sends nothing, so the frame already there keeps being drawn. What comes
back is the target the drawing side draws at, published from the source into
a Snapshot the panel world subscribes to, so a
frame is laid out at the size and density it will be drawn at.
No frame is laid out before the drawing side has drawn once: until then there is no target, and a frame laid out at a guessed size would be dropped by the source rather than drawn.
The two sides hold separate contexts. Sharing one would have both worlds
writing eguiβs memory and its font atlas, and egui treats one run_ui call
as one whole frame, so two worlds running it against one context would
interleave two frames into one. Their texture ids both start at zero, which
the drawing side handles by keying textures by origin and id: nothing
renumbers them.
Re-exportsΒ§
use core::time::Duration;πuse crate::job::Job;πuse crate::job::JobSender;πuse crate::job::SendError;πuse unlit_ecs::World;πuse unlit3d::frame::Frame;πuse unlit3d::input::InputEvent;πuse unlit3d::input::InputEvents;πuse unlit3d::relay::SnapshotReader;πuse unlit3d::source::Source;πuse unlit3d::ui::ExternalFrame;πuse unlit3d::ui::UiSource;πuse unlit3d::ui::UiTarget;πuse unlit3d::ui::egui;πuse unlit3d::ui::lay_out;πuse unlit3d::ui::raw_input;π
StructsΒ§
- UiPanel
Host - A worldβs panel publishing: the context its panels are built in, where its frames are sent and the target it lays out against.
FunctionsΒ§
- panel_
frame_ job - Hand
frameto the UI source of the world this job runs in.