Class NestedListViewController<TData, TItem, TIndex>
Extended ListViewController for representing nested/hierarchical data
Inherited Members
Namespace: Unity.ListViewFramework
Syntax
public abstract class NestedListViewController<TData, TItem, TIndex> : ListViewController<TData, TItem, TIndex>, IScrollHandler, IEventSystemHandler where TData : class, INestedListViewItemData<TData, TIndex> where TItem : class, INestedListViewItem<TData, TIndex>
Type Parameters
Name | Description |
---|---|
TData | The type of object in the list of data |
TItem | The base type of all list items |
TIndex | The type which is used as a unique index to map data to list items |
Fields
m_ExpandedDataLength
The total height of all list rows, taking into account which rows are expanded
Declaration
protected float m_ExpandedDataLength
Field Value
Type | Description |
---|---|
Single |
m_ExpandStates
Dictionary of item expanded state, keyed by index
Declaration
protected readonly Dictionary<TIndex, bool> m_ExpandStates
Field Value
Type | Description |
---|---|
Dictionary<TIndex, Boolean> |
m_UpdateStack
Re-usable stack of "stack frame" structs for recursive loop unwinding
Declaration
protected readonly Stack<NestedListViewController<TData, TItem, TIndex>.UpdateData> m_UpdateStack
Field Value
Type | Description |
---|---|
Stack<NestedListViewController.UpdateData<>> |
Properties
data
The list of data
Declaration
public override List<TData> data { get; set; }
Property Value
Type | Description |
---|---|
List<TData> |
Overrides
listHeight
The total height of all list rows, used to determine the maximum amount of scroll offset before snapping back
Declaration
protected override float listHeight { get; }
Property Value
Type | Description |
---|---|
Single |
Overrides
Methods
Awake()
Called when the script instance is being loaded
Declaration
protected override void Awake()
Overrides
GetExpanded(TIndex)
Get the expanded state for the item at the given index
Declaration
protected bool GetExpanded(TIndex index)
Parameters
Type | Name | Description |
---|---|---|
TIndex | index | The index for which to get the expanded state |
Returns
Type | Description |
---|---|
Boolean | The expanded state for the given index |
GetNewItem(TData, out TItem)
Get a view item for a given datum, either from its template's pool, or by creating a new one
Declaration
protected override bool GetNewItem(TData datum, out TItem item)
Parameters
Type | Name | Description |
---|---|---|
TData | datum | The datum for the desired view item |
TItem | item | The view item |
Returns
Type | Description |
---|---|
Boolean | True if a new item was instantiated, false if the view item came from the item pool |
Overrides
RecycleChildren(TData)
Recycle the list items for all children of the given datum
Declaration
protected void RecycleChildren(TData datum)
Parameters
Type | Name | Description |
---|---|---|
TData | datum | The datum whose children to recycle |
ScrollToIndex(TData, TIndex, ref Single)
Scroll the list to the item at the given index
Declaration
protected void ScrollToIndex(TData container, TIndex targetIndex, ref float scrollHeight)
Parameters
Type | Name | Description |
---|---|---|
TData | container | The container data within which to search |
TIndex | targetIndex | The index for which to search |
Single | scrollHeight | The offset to which the list will be scrolled |
SetExpanded(TIndex, Boolean)
Set the expanded state for the item at the given index
Declaration
protected void SetExpanded(TIndex index, bool expanded)
Parameters
Type | Name | Description |
---|---|---|
TIndex | index | The index for which to set the expanded state |
Boolean | expanded | The expanded state to set at the given index |
ToggleExpanded(TData)
Toggle the expanded state of the given datum
Declaration
protected virtual void ToggleExpanded(TData datum)
Parameters
Type | Name | Description |
---|---|---|
TData | datum | The datum whose expanded state will be toggled |
UpdateItems()
Called by UpdateView to update the list items
Declaration
protected override void UpdateItems()
Overrides
UpdateNestedItem(TData, Int32, Single, Int32, ref Boolean)
Update a visible list item
Declaration
protected virtual void UpdateNestedItem(TData datum, int order, float offset, int depth, ref bool doneSettling)
Parameters
Type | Name | Description |
---|---|---|
TData | datum | The datum representing this list item |
Int32 | order | The order of this item, among the other visible items |
Single | offset | The offset at which to position this item |
Int32 | depth | The level of nesting |
Boolean | doneSettling | Whether all items are done settling |
UpdateNestedItems(ref Int32, ref Single, ref Boolean, Int32)
Called by UpdateItems to update the list of nested items
Declaration
protected virtual void UpdateNestedItems(ref int order, ref float offset, ref bool doneSettling, int depth = 0)
Parameters
Type | Name | Description |
---|---|---|
Int32 | order | The order of the starting item item |
Single | offset | The offset of the starting item |
Boolean | doneSettling | Whether all items are done settling |
Int32 | depth | The level of nesting |