ListView

ceramic.Entityceramic.Visualceramic.Quadceramic.Layerceramic.Viewelements.ListView (Class)
Implements: tracker.Observable

A comprehensive list view with sorting, item management, and interaction features.

ListView provides a feature-rich interface for displaying and managing lists of data. It supports various operations including sorting, item selection, locking/unlocking, duplication, and deletion. The view uses a CollectionView internally for efficient scrolling and item recycling.

Features:

  • Dynamic item lists with automatic updates
  • Sortable items with drag-and-drop reordering
  • Item selection with visual feedback
  • Lock/unlock functionality for individual items
  • Item duplication and deletion operations
  • Two item height modes (small and large)
  • Scroll control with optional scrollbar
  • Theme integration and styling
  • Event-driven architecture for item operations
  • Integration with WindowItem for window management

Example usage:

var items = ["Item 1", "Item 2", "Item 3"];
var listView = new ListView(items);
listView.trashable = true;
listView.sortable = true;
listView.onTrashItem(this, (index) -> {
    items.splice(index, 1);
});

Static Members

elements
CELL_HEIGHT_SMALL: Int

Standard height for small list items (30 pixels)


elements
CELL_HEIGHT_LARGE: Int

Standard height for large list items (39 pixels)

Instance Members

elements
observedDirty: Bool

Default is false, automatically set to true when any of this instance's observable variables has changed.


elements
collectionView: CellCollectionView

The internal collection view that handles item display and scrolling


The data source providing item data to the collection view


elements
theme: Theme

Custom theme override for this list view


elements
items: Array<Dynamic>

The array of items to display in the list


elements
selectedIndex: Int

Index of the currently selected item (-1 for no selection)


elements
trashable: Bool

Whether items can be deleted/trashed


elements
lockable: Bool

Whether items can be locked/unlocked


elements
duplicable: Bool

Whether items can be duplicated


elements
sortable: Bool

Whether items can be reordered via drag and drop


elements
smallItems: Bool

Whether to use small item height (30px) instead of large (39px)


elements
scrollEnabled: Bool

Whether scrolling is enabled for the list


elements
windowItem: WindowItem

Optional WindowItem for window-specific list management. Used for coordinating list operations within a window context.


elements
autoCheckLocked: Bool

Whether to automatically check and update item locked states


elements
invalidateTheme(): Void

elements
invalidateItems(): Void

elements
invalidateSelectedIndex(): Void

elements
invalidateTrashable(): Void

elements
invalidateLockable(): Void

elements
invalidateDuplicable(): Void

elements
invalidateSortable(): Void

elements
invalidateSmallItems(): Void

elements
invalidateScrollEnabled(): Void

elements
new(items: Array<Dynamic>): Void

Creates a new ListView instance.

Initializes the list view with the provided items array and sets up the internal collection view, data source, and automatic update handlers.

Name Type Description
items Array<Dynamic> The initial array of items to display

Private Members

elements
unobservedTheme: Theme

elements
unobservedItems: Array<Dynamic>

elements
unobservedSelectedIndex: Int

elements
unobservedTrashable: Bool

elements
unobservedLockable: Bool

elements
unobservedDuplicable: Bool

elements
unobservedSortable: Bool

elements
unobservedSmallItems: Bool

elements
unobservedScrollEnabled: Bool

elements
emitObservedDirty(instance: ListView, fromSerializedField: Bool): Void

Event when any observable value as changed on this instance.

Name Type
instance ListView
fromSerializedField Bool

elements
emitMoveItemAboveItem(itemIndex: Int, otherItemIndex: Int): Void

Emitted when an item should be moved above another item in the list

Name Type
itemIndex Int
otherItemIndex Int

elements
emitMoveItemBelowItem(itemIndex: Int, otherItemIndex: Int): Void

Emitted when an item should be moved below another item in the list

Name Type
itemIndex Int
otherItemIndex Int

elements
emitTrashItem(itemIndex: Int): Void

Emitted when an item should be deleted/trashed

Name Type
itemIndex Int

elements
emitLockItem(itemIndex: Int): Void

Emitted when an item should be locked

Name Type
itemIndex Int

elements
emitUnlockItem(itemIndex: Int): Void

Emitted when an item should be unlocked

Name Type
itemIndex Int

elements
emitDuplicateItem(itemIndex: Int): Void

Emitted when an item should be duplicated

Name Type
itemIndex Int

elements
emitThemeChange(current: Theme, previous: Theme): Void

Event when theme field changes.

Name Type
current Theme
previous Theme

elements
emitItemsChange(current: Array<Dynamic>, previous: Array<Dynamic>): Void

Event when items field changes.

Name Type
current Array<Dynamic>
previous Array<Dynamic>

elements
emitSelectedIndexChange(current: Int, previous: Int): Void

Event when selectedIndex field changes.

Name Type
current Int
previous Int

elements
emitTrashableChange(current: Bool, previous: Bool): Void

Event when trashable field changes.

Name Type
current Bool
previous Bool

elements
emitLockableChange(current: Bool, previous: Bool): Void

Event when lockable field changes.

Name Type
current Bool
previous Bool

elements
emitDuplicableChange(current: Bool, previous: Bool): Void

Event when duplicable field changes.

Name Type
current Bool
previous Bool

elements
emitSortableChange(current: Bool, previous: Bool): Void

Event when sortable field changes.

Name Type
current Bool
previous Bool

elements
emitSmallItemsChange(current: Bool, previous: Bool): Void

Event when smallItems field changes.

Name Type
current Bool
previous Bool

elements
emitScrollEnabledChange(current: Bool, previous: Bool): Void

Event when scrollEnabled field changes.

Name Type
current Bool
previous Bool

elements
updateFromScrollEnabled(): Void

Updates scroll behavior based on the scrollEnabled property.

Enables or disables scrolling and scrollbar visibility based on the current scrollEnabled setting.


elements
updateFromItems(): Void

Updates the collection view when items change.

Reloads the collection view data and ensures proper layout and scrolling when the items array or related properties change.


elements
layout(): Void

Overrides layout to properly size the collection view.

Ensures the collection view matches the size of this ListView.


elements
checkLockedIfNeeded(delta: Float): Void

Checks item locked states if auto-checking is enabled.

Called every frame to update locked states when autoCheckLocked is true.

Name Type Description
delta Float Time elapsed since last frame

elements
didEmitLockItem(itemIndex: Int): Void

Called after a lock item event is emitted.

Triggers a check of all item locked states to update the UI.

Name Type Description
itemIndex Int The index of the item that was locked

elements
didEmitUnlockItem(itemIndex: Int): Void

Called after an unlock item event is emitted.

Triggers a check of all item locked states to update the UI.

Name Type Description
itemIndex Int The index of the item that was unlocked

elements
checkLocked(): Void

Checks and updates the locked state of all visible items.

Iterates through all visible cell views and updates their locked state based on the 'locked' property of their corresponding items. Automatically deselects any item that becomes locked.

Metadata

Name Parameters
:build tracker.macros.ObservableMacro.build()
:autoBuild tracker.macros.ObservableMacro.build()
:build ceramic.macros.EntityMacro.buildForCompletion()
:autoBuild ceramic.macros.EntityMacro.buildForCompletion()
:build tracker.macros.EventsMacro.build()
:autoBuild tracker.macros.EventsMacro.build()
:allow elements.ListViewDataSource