pub struct Id(u64);
egui tracks widgets frame-to-frame using
For instance, if you start dragging a slider one frame, egui stores
Id as the current active id so that next frame when
you move the mouse the same slider changes, even if the mouse has
moved outside the slider.
For some widgets
Ids are also used to persist some state about the
widgets, such as Window position or whether not a collapsing header region is open.
This implies that the
Ids must be unique.
For simple things like sliders and buttons that don’t have any memory and doesn’t move we can use the location of the widget as a source of identity. For instance, a slider only needs a unique and persistent ID while you are dragging the slider. As long as it is still while moving, that is fine.
For things that need to persist state even after moving (windows, collapsing headers) the location of the widgets is obviously not good enough. For instance, a collapsing region needs to remember whether or not it is open even if the layout next frame is different and the collapsing is not lower down on the screen.
Then there are widgets that need no identifiers at all, like labels, because they have no state nor are interacted with.
pub(crate) fn background() -> Self
Generate a new
Id by hashing some source (e.g. a string or integer).