Constructs a new BaseCollectionViewLayout.
Padding between cells.
Map of cell indices to cell instances.
Size of each cell as [width, height].
Indicates 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 managing reusable nodes.
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.
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. Handles any necessary initialization or state updates for the row.
Called when the row exits the screen. Handles any necessary cleanup or state updates for the row.
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 horizontal row at the specified virtual position. Delegates to the base implementation for rendering logic.
The render event containing virtual position and other details.
Renders the row as a hidden row (to be implemented by subclasses).
Shows placeholder cells (not implemented).
HorizontalRowLayout
is a specialized implementation ofBaseCollectionViewLayout
designed to handle horizontal layouts for rows in a collection view. It manages the rendering, lifecycle events, and layout calculations for horizontally arranged rows.