Constructs a new BaseCollectionViewLayout.
Padding between cells.
Map of cell indices to cell instances.
Size of each cell as [width, height].
Whether this layout is enabled.
Injected font manager for font lookups.
Height of the header.
Header label node, if present.
Injected instance pool for cell reuse.
Injected node pool for node reuse.
Number of columns in the row.
Array of currently rendered cells.
The row this layout manages.
The content data for the row.
The settings for the row.
The current screen position (y offset).
The current virtual scroll position.
Horizontal offset for content.
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 label for the row based on settings.
Configures row settings based on content.
The row content.
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 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.
Private
getPrivate
Retrieves 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 focus information for a given cell index.
The cell index.
The desired position for the next item.
Focus info object.
Determines the index of an item based on a key press event.
The key that was pressed. Expected values are Key.Left
or Key.Right
.
A boolean indicating if the key press is a long press.
The index of the item to focus on. Returns 0
if the left key is long pressed,
the last item index if the right key is long pressed, or the clamped index
based on the current focused index and the key pressed. Returns -1
for unsupported keys.
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.
The cell index.
The desired position for the next item.
The offset to apply.
The [x, y] position or undefined if out of bounds.
Gets the virtual position for a given cell index and position.
The cell index.
The desired position (start, middle, end).
The virtual position.
Determines if this layout handles the given key press.
The key pressed.
Whether the key press is a long press.
True if handled, false otherwise.
Determines if a cell index is visible on screen at the given virtual position.
The cell index.
The virtual position.
True if the cell is on screen, 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. 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.
Renders the row and its cells at the given position.
The render event.
Renders the row as a hidden row (to be implemented by subclasses).
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.