s&box docs
API ReferenceSandbox.UI

public abstract class Sandbox.UI.BaseVirtualPanel : Sandbox.UI.Panel

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

Constructors

Showing 1 constructors

protected BaseVirtualPanel()

Initializes the base virtual panel with default styles.

Methods

Showing 15 methods

public void AddItem(object item)

Adds a single item and marks the panel for rebuild.

Parameters

  • item: The item to append.

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

public void Clear()

Clears all items and destroys created panels.

protected virtual void FinalLayoutChildren(Vector2 offset)

Final layout pass for child panels and scroll bounds.

Parameters

  • offset: Layout offset.

protected virtual float GetTotalHeight(int itemCount)

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

Parameters

  • itemCount: Number of items.

Returns

Total height in layout units.

protected virtual void GetVisibleRange(int first, int pastEnd)

Gets the range of visible item indices.

Parameters

  • first: First visible index (inclusive).
  • pastEnd: Past-the-end index (exclusive).

public bool HasData(int i)

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

Parameters

  • i: Item index.

Returns

True if within bounds; otherwise false.

public void InsertItem(int index, object item)

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

Parameters

  • index: The zero-based index at which item should be inserted.
  • item: The item to insert.

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

Positions a panel at the specified index.

Parameters

  • index: Item index.
  • panel: Panel to position.

public void RemoveAt(int index)

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

Parameters

  • index: The zero-based index of the item to remove.

public bool RemoveItem(object item)

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

Parameters

  • item: The item to remove.

Returns

True if item was found and removed; otherwise false.

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

public virtual void Tick()

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

protected virtual bool UpdateLayout()

Updates the layout and returns true if the layout changed.

Returns

True if layout was updated; otherwise false.

protected virtual void UpdateLayoutSpacing(Vector2 spacing)

Updates the layout spacing based on CSS gaps.

Parameters

  • spacing: The spacing vector from CSS.

Properties

Showing 6 properties

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

Template used to render an item into a cell panel.

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

Gets the number of items in the panel.

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

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.

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

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

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

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

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

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

Metadata

FieldValue
NamespaceSandbox.UI
Typeclass
AssemblySandbox.Engine
Doc IDT:Sandbox.UI.BaseVirtualPanel

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