Skip to content
pixi-silk
GitHub repository
Interface

TreeAdapter

import type { TreeAdapter } from 'pixi-silk/ui/layers';

How a LayerTree reads and changes your data. Only getChildren and getName are required. The tree never holds its own copy of the data, so it can show a Pixi scene graph, a document model or a state store.

Children come in display order: the first child is the top row, so list the front-most layer first.

Type Parameters#

Type Parameter
T

Methods#

canHaveChildren()?#

optional canHaveChildren(node: T): boolean;

True when other nodes can be dropped inside. Default: when it has children.

Parameters#

ParameterType
nodeT

Returns#

boolean


getChildren()#

getChildren(node: T): readonly T[];

The children of node, in display order.

Parameters#

ParameterType
nodeT

Returns#

readonly T[]


getIcon()?#

optional getIcon(node: T): LayerIcon | null;

The icon of the row. Default none.

Parameters#

ParameterType
nodeT

Returns#

LayerIcon | null


getName()#

getName(node: T): string;

The name shown in the row.

Parameters#

ParameterType
nodeT

Returns#

string


getParent()?#

optional getParent(node: T): T | null;

The parent of node, or null for the root. Without it the tree searches from the root.

Parameters#

ParameterType
nodeT

Returns#

T | null


isLocked()?#

optional isLocked(node: T): boolean;

True when the node is locked. Without it, the row has no lock toggle.

Parameters#

ParameterType
nodeT

Returns#

boolean


isVisible()?#

optional isVisible(node: T): boolean;

True when the node shows. Without it, the row has no eye toggle.

Parameters#

ParameterType
nodeT

Returns#

boolean


move()?#

optional move(
   node: T, 
   parent: T, 
   index: number
): void;

Moves node under parent at index in display order, counted without node itself. Without it, rows cannot be dragged.

Parameters#

ParameterType
nodeT
parentT
indexnumber

Returns#

void


setLocked()?#

optional setLocked(node: T, locked: boolean): void;

Sets the lock of node. Needed for the lock toggle to work.

Parameters#

ParameterType
nodeT
lockedboolean

Returns#

void


setName()?#

optional setName(node: T, name: string): void;

Renames node. Without it, double click, Enter and F2 do nothing.

Parameters#

ParameterType
nodeT
namestring

Returns#

void


setVisible()?#

optional setVisible(node: T, visible: boolean): void;

Shows or hides node. Needed for the eye toggle to work.

Parameters#

ParameterType
nodeT
visibleboolean

Returns#

void