pub struct ForMarker {
pub array_name: String,
pub body: Vec<Element>,
pub key_field: Option<String>,
pub cached_keys: Vec<String>,
pub virtualized: bool,
pub row_height: f32,
pub win_rows: Vec<(usize, String)>,
pub cascaded_body: Option<Arc<Vec<Element>>>,
pub row_items: Vec<ArrayItem>,
}Expand description
Marker for a <for each="..."> block. The reconciler reads the referenced ArraySignals entry each tick,
expands body once per item (substituting {field} placeholders against the item record), and spawns/despawns child entities to match.
The reconciler compares the key sequence it built last tick with the new one: an unchanged sequence mounts
nothing, an appended prefix spawns only the new rows, a truncated prefix despawns only the trailing rows, and
anything else (reorder, mid-insert, mid-remove) is a full despawn-and-respawn. A row whose key is kept but whose
record changed is updated in place, on the entities it already has. key_field names the record field the keys
come from; without it the item index is the key.
A virtualized block holds its width and height in
StyleOverrides, sized
to every row it could show.
Fields§
§array_name: StringName of the ArraySignals entry to iterate.
body: Vec<Element>Template body - the markup children of the <for> element.
key_field: Option<String>Stable-id field within each record (e.g. "id"). Optional; without
it the reconciler keys rows by item index.
cached_keys: Vec<String>Cache of the keys (or item indices when key_field is absent)
currently materialized as children, so the reconciler can detect
no-op frames without re-walking the body template.
virtualized: bool<for virtualized="true"> opt-in. When set, and when the scene policy
leaves the windowing to the reconciler, it spawns only rows in the
visible scroll window plus a small buffer; each row is
absolute-positioned via inline inset from row_height * row_index.
row_height: f32Per-row pixel height used by the virtualization windowing math.
Required when virtualized = true. Default 32 px when authors
turn on virtualized without specifying row-height.
win_rows: Vec<(usize, String)>Virtualized only: the (row_index, key) pairs currently mounted,
in child-list order (each entry owns body.len() consecutive
children). Spec section 15.3 windowed reuse - a window shift keeps every
row whose (index, key) is unchanged instead of respawning the
whole band.
cascaded_body: Option<Arc<Vec<Element>>>Virtualized only: the body template with the CSS cascade already
applied (cascade-once-per-template). None until first use and
after every stylesheet change; rebuilt lazily by the reconciler.
Skipped (per-row cascade instead) when the template’s id /
class attrs contain {...} placeholders, because then selector
matching depends on per-row substitution results.
row_items: Vec<ArrayItem>The record each mounted row was built from, in the order of
Self::cached_keys (or of Self::win_rows when virtualized).
A kept row whose record no longer matches its entry here has its
placeholders resolved again and written onto the entities it
already has.
Trait Implementations§
Source§impl Component for ForMarker
Required Components: [lumen_core :: style_overrides :: StyleOverrides].
impl Component for ForMarker
Required Components: [lumen_core :: style_overrides :: StyleOverrides].
A component’s Required Components are inserted whenever it is inserted. Note that this will also insert the required components of the required components, recursively, in depth-first order.
Source§const STORAGE_TYPE: StorageType = bevy_ecs::component::StorageType::Table
const STORAGE_TYPE: StorageType = bevy_ecs::component::StorageType::Table
Source§type Mutability = Mutable
type Mutability = Mutable
Component<Mutability = Mutable>],
while immutable components will instead have [Component<Mutability = Immutable>]. Read moreSource§fn register_required_components(
_requiree: ComponentId,
required_components: &mut RequiredComponentsRegistrator<'_, '_>,
)
fn register_required_components( _requiree: ComponentId, required_components: &mut RequiredComponentsRegistrator<'_, '_>, )
Source§fn clone_behavior() -> ComponentCloneBehavior
fn clone_behavior() -> ComponentCloneBehavior
Source§fn relationship_accessor() -> Option<ComponentRelationshipAccessor<Self>>
fn relationship_accessor() -> Option<ComponentRelationshipAccessor<Self>>
ComponentRelationshipAccessor] required for working with relationships in dynamic contexts. Read more§fn on_add() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_add() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
on_add [ComponentHook] for this [Component] if one is defined.§fn on_insert() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_insert() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
on_insert [ComponentHook] for this [Component] if one is defined.§fn on_discard() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_discard() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
on_discard [ComponentHook] for this [Component] if one is defined.§fn on_remove() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_remove() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
on_remove [ComponentHook] for this [Component] if one is defined.§fn on_despawn() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_despawn() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
on_despawn [ComponentHook] for this [Component] if one is defined.§fn map_entities<E>(_this: &mut Self, _mapper: &mut E)where
E: EntityMapper,
fn map_entities<E>(_this: &mut Self, _mapper: &mut E)where
E: EntityMapper,
EntityMapper]. This is used to remap entities in contexts like scenes and entity cloning.
When deriving [Component], this is populated by annotating fields containing entities with #[entities] Read moreAuto Trait Implementations§
impl Freeze for ForMarker
impl RefUnwindSafe for ForMarker
impl Send for ForMarker
impl Sync for ForMarker
impl Unpin for ForMarker
impl UnsafeUnpin for ForMarker
impl UnwindSafe for ForMarker
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<C> Bundle for Cwhere
C: Component,
impl<C> Bundle for Cwhere
C: Component,
fn component_ids( components: &mut ComponentsRegistrator<'_>, ) -> impl Iterator<Item = ComponentId> + use<C>
§fn get_component_ids(
components: &Components,
) -> impl Iterator<Item = Option<ComponentId>>
fn get_component_ids( components: &Components, ) -> impl Iterator<Item = Option<ComponentId>>
Bundle]’s component ids. This will be None if the component has not been registered.