Function rerun::external::re_ui::list_item::list_item_scope

source ·
pub fn list_item_scope<R>(
    ui: &mut Ui,
    id_salt: impl Hash,
    content: impl FnOnce(&mut Ui) -> R
) -> R
Expand description

Create a scope in which [ListItem]s can be created.

This scope provides the infrastructure to gather layout statistics from nested list items, compute corresponding layout information, and provide this information to nested list items.

State is loaded against the scope id, and pushed to a global stack, such that calls to this function may be nested. ListItem code will always use the top of the stack as current state.

Layout statistics are accumulated during the frame and stored in egui’s memory against the scope id. Layout information is pushed to a global stack, which is also stored in egui’s memory. This enables nesting list_item_scopes.

Note

  • The scope id is derived from the provided id_salt and combined with the egui::Ui’s id, such that id_salt only needs to be unique within the scope of the parent ui.
  • Creates a new wrapped egui::Ui internally, so it’s safe to modify the ui within the closure.
  • Uses egui::Ui::push_id so two sibling list_item_scope:s with different ids won’t have id clashes within them.
  • The ui.spacing_mut().item_spacing.y is set to 0.0 to remove the default spacing between list items.