API ReferenceSandbox.UI

BaseVirtualPanelclass

Base class for virtualized, scrollable panels that only create item panels when visible.

objectPanelBaseVirtualPanel
Namespace
Sandbox.UI
Assembly
Sandbox.Engine
Declaration
public abstract class Sandbox.UI.BaseVirtualPanel : Sandbox.UI.Panel

Constructors1

Showing 1 constructors

protected BaseVirtualPanel()PROTECTEDCONSTRUCTOR

Initializes the base virtual panel with default styles.

Methods15

Showing 15 methods

public void AddItem(object item)PUBLIC

Adds a single item and marks the panel for rebuild.

ParameterTypeDescription
itemobjectThe item to append.
Returns:void

public void AddItems(System.Collections.Generic.IEnumerable`1<object> items)PUBLIC

ParameterTypeDescription
itemsIEnumerable<object>
Returns:void

public void Clear()PUBLIC

Clears all items and destroys created panels.

Returns:void

protected virtual void FinalLayoutChildren(Vector2 offset)PROTECTEDVIRTUAL

Final layout pass for child panels and scroll bounds.

ParameterTypeDescription
offsetVector2Layout offset.
Returns:void

protected virtual float GetTotalHeight(int itemCount)PROTECTEDVIRTUAL

Gets the total height needed to display the specified number of items.

ParameterTypeDescription
itemCountintNumber of items.
Returns:floatTotal height in layout units.

protected virtual void GetVisibleRange(int first, int pastEnd)PROTECTEDVIRTUAL

Gets the range of visible item indices.

ParameterTypeDescription
firstintFirst visible index (inclusive).
pastEndintPast-the-end index (exclusive).
Returns:void

public bool HasData(int i)PUBLIC

Returns true if `i` is a valid item index.

ParameterTypeDescription
iintItem index.
Returns:boolTrue if within bounds; otherwise false.

public void InsertItem(int index, object item)PUBLIC

Inserts an item at the specified index and marks the panel for rebuild.

ParameterTypeDescription
indexintThe zero-based index at which item should be inserted.
itemobjectThe item to insert.
Returns:void

protected virtual void PositionPanel(int index, Sandbox.UI.Panel panel)PROTECTEDVIRTUAL

Positions a panel at the specified index.

ParameterTypeDescription
indexintItem index.
panelPanelPanel to position.
Returns:void

public void RemoveAt(int index)PUBLIC

Removes the item at the specified index and marks the panel for rebuild.

ParameterTypeDescription
indexintThe zero-based index of the item to remove.
Returns:void

public bool RemoveItem(object item)PUBLIC

Removes the first occurrence of a specific item and marks the panel for rebuild.

ParameterTypeDescription
itemobjectThe item to remove.
Returns:boolTrue if item was found and removed; otherwise false.

public void SetItems(System.Collections.Generic.IEnumerable`1<object> enumerable)PUBLIC

ParameterTypeDescription
enumerableIEnumerable<object>
Returns:void

public virtual void Tick()PUBLICVIRTUALPER-FRAME

Per-frame update: adjusts spacing from CSS, updates layout, creates/destroys visible panels.

Returns:void

protected virtual bool UpdateLayout()PROTECTEDVIRTUALPER-FRAME

Updates the layout and returns true if the layout changed.

Returns:boolTrue if layout was updated; otherwise false.

protected virtual void UpdateLayoutSpacing(Vector2 spacing)PROTECTEDVIRTUALPER-FRAME

Updates the layout spacing based on CSS gaps.

ParameterTypeDescription
spacingVector2The spacing vector from CSS.
Returns:void

Properties6

Showing 6 properties

public Microsoft.AspNetCore.Components.RenderFragment`1<object> Sandbox.UI.BaseVirtualPanel.Item { get; set; }PUBLICGETSET

Template used to render an item into a cell panel.

Returns:RenderFragment<object>

public int Sandbox.UI.BaseVirtualPanel.ItemCount { get; set; }PUBLICGETSET

Gets the number of items in the panel.

Returns:int

public System.Collections.Generic.IEnumerable`1<object> Sandbox.UI.BaseVirtualPanel.Items { get; set; }PUBLICGETSET

Replaces the current items. Only triggers a rebuild if the sequence is actually different. When set to an IList (like List), changes to the source list will be automatically detected.

Returns:IEnumerable<object>

public bool Sandbox.UI.BaseVirtualPanel.NeedsRebuild { get; set; }PUBLICGETSET

When true, forces a layout rebuild on the next `Sandbox.UI.BaseVirtualPanel.Tick`.

Returns:bool

public System.Action`2<Sandbox.UI.Panel,object> Sandbox.UI.BaseVirtualPanel.OnCreateCell { get; set; }PUBLICGETSET

Called when a cell is created. Allows you to fill the cell in

Returns:Action<Panel,object>

public System.Action Sandbox.UI.BaseVirtualPanel.OnLastCell { get; set; }PUBLICGETSET

Called when the last cell has been viewed. This allows you to view more.

Returns:Action

On this page

Constructorsprotected BaseVirtualPanel()Methodspublic System.Void AddItem(System.Object item)public System.Void AddItems(System.Collections.Generic.IEnumerable`1<System.Object> items)public System.Void Clear()protected virtual System.Void FinalLayoutChildren(Vector2 offset)protected virtual System.Single GetTotalHeight(System.Int32 itemCount)protected virtual System.Void GetVisibleRange(System.Int32 first, System.Int32 pastEnd)public System.Boolean HasData(System.Int32 i)public System.Void InsertItem(System.Int32 index, System.Object item)protected virtual System.Void PositionPanel(System.Int32 index, Sandbox.UI.Panel panel)public System.Void RemoveAt(System.Int32 index)public System.Boolean RemoveItem(System.Object item)public System.Void SetItems(System.Collections.Generic.IEnumerable`1<System.Object> enumerable)public virtual System.Void Tick()protected virtual System.Boolean UpdateLayout()protected virtual System.Void UpdateLayoutSpacing(Vector2 spacing)Propertiespublic Microsoft.AspNetCore.Components.RenderFragment`1<System.Object> Sandbox.UI.BaseVirtualPanel.Item { get; set; }public System.Int32 Sandbox.UI.BaseVirtualPanel.ItemCount { get; set; }public System.Collections.Generic.IEnumerable`1<System.Object> Sandbox.UI.BaseVirtualPanel.Items { get; set; }public System.Boolean Sandbox.UI.BaseVirtualPanel.NeedsRebuild { get; set; }public System.Action`2<Sandbox.UI.Panel,System.Object> Sandbox.UI.BaseVirtualPanel.OnCreateCell { get; set; }public System.Action Sandbox.UI.BaseVirtualPanel.OnLastCell { get; set; }Metadata