Constructs a new BaseCollectionViewLayout.
The background rectangle for the layout.
Map of cell indices to cell instances.
Current header style key for component-based headers.
The debug label for the layout.
Whether this layout is enabled.
Injected font manager for font lookups.
Whether this layout has a header.
Header fragment for component-based headers.
Header label node, if present.
Injected instance pool for cell reuse.
The last updated visible cells virtual position.
Injected node pool for node reuse.
The callback to invoke when the row is released.
The callback to invoke at the end of row layout rendering.
The callback to invoke at the start of row layout rendering.
Array of currently rendered cells.
The row this layout manages.
The current screen position (y offset).
Injected view fragment provider for component-based headers.
The current virtual scroll position.
Returns the number of items in the row.
Assigns a row to this layout and configures cell and header settings.
The row to assign.
Calculates and updates the visible cells based on the given virtual position WHEN SCROLLING UP AND DOWN
The virtual position to calculate the visible cells from.
This method determines the range of cells that should be visible within the viewport, configures and renders them, and removes any cells that are no longer visible.
The method performs the following steps:
Configures the header for the row based on settings. Supports both legacy single-label headers and new component-based headers.
Converts placeholder cells to real cells (to be implemented by subclasses).
Retrieves a cell at the specified index. If the cell does not exist, it reserves a new cell from the instancePool, sets it to visible, assigns the index, and stores it in the cellsByIndex array.
The pool key is normally the row's cellSettingsKey (or loadingCellStyleKey for loading placeholders). When the
row has useMixedCellStyleKeys, each item may supply its own cellSettingsKey so different cells in the same row
can use different styles.
The index of the cell to retrieve.
The cell at the specified index, or a newly reserved cell if it did not exist.
Gets the cell index at a given virtual position.
The virtual position.
The cell index.
PrivategetPrivateRetrieves and configures cells for the currently visible items in the collection view.
This method checks if the row is in a loading state and shows placeholders if true. Otherwise, it iterates over the visible items, configures each cell, and adds it to the rendered cells array.
Gets the width for a specific cell index.
The cell index.
The cell width.
Gets the item index whose center is closest to the stored focused cell X position. Used for FocusOnClosestItem strategy.
The item index closest to the stored X position.
PrivategetDerives the view status a cell at the given index should have right now, from the collection view's focus state rather than whatever status the cell last wore. This is what lets retained/pooled cells self-heal: the focused cell picks up Focused when it materializes (even if focus was applied while it was off-screen), and any other cell sheds a stale Focused left over from focus-index desync during animations.
The focused cell is identified via the collection view's committed focusedIndices (the per-row focusedIndex can lag behind during animation completions). An existing FocusFootprint is preserved (see below) rather than re-derived.
The cell index.
The status the cell currently wears (used to preserve footprints).
Returns the horizontal content extent in physical layout coordinates.
Gets the virtual position for a given cell index and position.
The cell index.
The virtual position.
Returns the initial horizontal offset that exposes logical item zero.
Returns the largest valid horizontal scroll offset for this row.
Gets the next item index when moving vertically within row. Override this function if your row has more than one item per sub-row, and you want to move to the next item when moving vertically. That is, for rows containing one line of items (for instance, HorizontalRow), the method returns -1 (because the next or previous line of items does not exist)
1 for up, 1 for down
Gets the next page item index when moving horizontally within row. Override this function if your row has more than one item per sub-row, and you want to move to the next page item when moving horizontally.
1 for left, 1 for right
The index of the next page item.
Gets the rendered cell at the specified index.
The cell index.
The rendered cell, if any.
Gets the rendered cell at a given virtual position.
The virtual position.
The rendered cell.
Calculates the on-screen position for a cell index, accounting for the current horizontal scroll (virtualPosition). Used by pointer/touch focus so the focus indicator follows the item to its scrolled location rather than its release point. The returned X is clamped to the visible viewport so the indicator never renders past the row edges. Assumes a horizontal layout; subclasses may override.
The cell index.
The base offset to apply ([x, y]); offset[0] is the minimum X, offset[1] is the Y.
The clamped [x, y] screen position, or undefined if the index is out of bounds.
Gets the target item index in the horizontal direction.
1 for left, 1 for right
Whether the key press is a long press.
The index of the target item.
Returns the [x, y] virtual position within this row necessary to bring the target item index
into view according to the requested position strategy. Base implementation returns a default
x using xOffset and a y based on the row's rendered list position and screen position.
Specialized layouts should override this to provide accurate item positions.
Returns the vertical position of the item index.
The item index.
The vertical position of the item index. The same as getVerticalCorrectedPositionForItemIndex, but without the screen position offset.
Gets the virtual vertical position for a specific row index related to the row header.
The item index.
The virtual vertical position for the row.
Gets the virtual row index for the target index.
The target index.
The virtual row index.
Gets the number of virtual rows in the layout.
The number of virtual rows in the layout.
Determines if a cell index is in the modified floating focus area at the given virtual position. The modified floating focus area is the floating focus area without the xOffset. This is used for horizontal scrolling with floating focus.
The cell index.
The virtual position.
True if the cell is in the modified floating focus area, false otherwise.
Called when the row enters the screen. Prepares visible cells and header.
Called when the row exits the screen. Releases all rendered cells and hides the header.
Called before the layout is released back to the pool. Releases all cells, resets virtual position, and clears rendered cells.
Called before the layout is reused from the pool. Resets virtual position, clears rendered cells, and hides the header.
Refreshes only compatibility-installed direction members after a locale change.
PrivatereleaseRenders the row and its cells at the given position.
The render event.
Renders the row as a hidden row (to be implemented by subclasses).
Determines if the visible cells should be recalculated.
The virtual screen y position.
True if the visible cells should be recalculated, false otherwise.
Shows placeholder cells (not implemented).
BaseCollectionViewLayout provides core logic for laying out and managing cells in a collection view row. Handles cell pooling, rendering, focus, and header configuration.