Class Tree

Namespace
Forma
Assembly
Forma.dll

Hierarchical, column-oriented selection control modeled after Godot's Tree.

[TemplatePart("PART_TreePresenter", typeof(Container), true)]
public sealed class Tree : TemplatedControl, IAddChild<Control>, IAddChild, INotifyPropertyChanged, IDisposable
Inheritance
Tree
Implements
Inherited Members

Constructors

Tree()

public Tree()

Fields

DropSectionNotFound

Godot's sentinel returned when no drop target exists.

public const int DropSectionNotFound = -100

Field Value

int

TreePresenterPartName

public const string TreePresenterPartName = "PART_TreePresenter"

Field Value

string

Properties

AccessibilityRole

public override AccessibilityRole AccessibilityRole { get; }

Property Value

AccessibilityRole

AllowMultiSelect

Legacy convenience alias for SelectMode set to Multi.

public bool AllowMultiSelect { get; set; }

Property Value

bool

AllowReselect

public bool AllowReselect { get; set; }

Property Value

bool

AllowRightMouseSelect

Allows a right pointer press to select an item, matching Godot's allow_rmb_select. Disabled by default.

public bool AllowRightMouseSelect { get; set; }

Property Value

bool

AllowSearch

Enables Godot-style case-insensitive incremental text search for focused tree items.

public bool AllowSearch { get; set; }

Property Value

bool

AutoTooltipEnabled

Uses a cell's text as its tooltip when no explicit cell tooltip is set, matching Godot's set_auto_tooltip().

public bool AutoTooltipEnabled { get; }

Property Value

bool

CanDropDataProvider

Application drop-acceptance hook corresponding to Godot's overridable _can_drop_data().

public Func<Tree, TreeItem, int, Point, object, bool> CanDropDataProvider { get; set; }

Property Value

Func<Tree, TreeItem, int, Point, object, bool>

ColumnResizeEnabled

Enables pointer resizing of visible column-header dividers.

public bool ColumnResizeEnabled { get; set; }

Property Value

bool

ColumnResizeHandleWidth

Screen-space tolerance around a column divider that starts resize capture.

public int ColumnResizeHandleWidth { get; set; }

Property Value

int

ColumnTitlesVisible

public bool ColumnTitlesVisible { get; set; }

Property Value

bool

Columns

public int Columns { get; set; }

Property Value

int

DragAutoScrollBorder

Width in pixels of the top and bottom drag-edge zones.

public int DragAutoScrollBorder { get; set; }

Property Value

int

DragAutoScrollEnabled

Enables vertical edge scrolling while a retained drag is active, corresponding to Godot Tree's themed drag-scroll behavior.

public bool DragAutoScrollEnabled { get; set; }

Property Value

bool

DragAutoScrollSpeed

Maximum vertical auto-scroll speed in pixels per second at an edge.

public float DragAutoScrollSpeed { get; set; }

Property Value

float

DragDataProvider

Application drag-payload hook corresponding to Godot's overridable _get_drag_data(). It receives the hit item and column, which can be null and -1.

public Func<Tree, TreeItem, int, Point, object> DragDataProvider { get; set; }

Property Value

Func<Tree, TreeItem, int, Point, object>

DragUnfoldDelay

Delay before a collapsed drag target unfolds. Godot's themed default is 500 ms.

public TimeSpan DragUnfoldDelay { get; set; }

Property Value

TimeSpan

DragUnfoldingEnabled

Enables delayed expansion when a same-tree drag hovers a collapsed item, matching Godot's drag-unfold policy.

public bool DragUnfoldingEnabled { get; }

Property Value

bool

DropDataHandler

Application drop-delivery hook corresponding to Godot's overridable _drop_data().

public Action<Tree, TreeItem, int, Point, object> DropDataHandler { get; set; }

Property Value

Action<Tree, TreeItem, int, Point, object>

DropModeFlags

Enables item and/or in-between regions returned by GetDropSectionAtPosition(Point).

public TreeDropModeFlags DropModeFlags { get; set; }

Property Value

TreeDropModeFlags

EditCheckboxCellOnlyWhenCheckboxPressed

Allows checkbox cell edits only when the checkbox glyph itself is pressed, matching Godot's checkbox edit policy.

public bool EditCheckboxCellOnlyWhenCheckboxPressed { get; }

Property Value

bool

FoldingHidden

Hides folding arrows and disables their pointer toggle region, matching Godot's set_hide_folding().

public bool FoldingHidden { get; }

Property Value

bool

Font

public SpriteFont Font { get; set; }

Property Value

SpriteFont

HideRoot

public bool HideRoot { get; set; }

Property Value

bool

HorizontalScrollEnabled

Enables Tree horizontal scrolling, matching Godot's set_h_scroll_enabled().

public bool HorizontalScrollEnabled { get; }

Property Value

bool

IncrementalSearchText

public string IncrementalSearchText { get; }

Property Value

string

IncrementalSearchTimeout

Maximum interval between typed characters that belong to the same incremental search.

public TimeSpan IncrementalSearchTimeout { get; set; }

Property Value

TimeSpan

Indent

public float Indent { get; set; }

Property Value

float

IsHorizontalScrollBarVisible

Whether the retained horizontal scrollbar is currently visible for overflowing Tree columns.

public bool IsHorizontalScrollBarVisible { get; }

Property Value

bool

IsTouchDragDecelerating

public bool IsTouchDragDecelerating { get; }

Property Value

bool

IsTouchDragging

public bool IsTouchDragging { get; }

Property Value

bool

IsVerticalScrollBarVisible

Whether the retained vertical scrollbar is currently visible for overflowing Tree rows.

public bool IsVerticalScrollBarVisible { get; }

Property Value

bool

ItemHeight

public float ItemHeight { get; set; }

Property Value

float

RangeStepRepeatDelay

Initial hold duration before an editable numeric range stepper repeats, matching Godot's 600 ms default.

public TimeSpan RangeStepRepeatDelay { get; set; }

Property Value

TimeSpan

RangeStepRepeatInterval

Repeat cadence for a held numeric range stepper, matching Godot's 50 ms default.

public TimeSpan RangeStepRepeatInterval { get; set; }

Property Value

TimeSpan

RecursiveFoldingEnabled

Allows Shift-clicking a folding arrow to collapse or expand every descendant, matching Godot's recursive folding policy.

public bool RecursiveFoldingEnabled { get; }

Property Value

bool

RootItems

public IReadOnlyList<TreeItem> RootItems { get; }

Property Value

IReadOnlyList<TreeItem>

ScrollHintHeight

Height in pixels of each retained top or bottom scroll hint.

public int ScrollHintHeight { get; set; }

Property Value

int

ScrollHintMode

Configures Godot-style top/bottom overflow indicators.

public TreeScrollHintMode ScrollHintMode { get; }

Property Value

TreeScrollHintMode

SelectMode

Configures single-cell, full-row, or multi-cell selection, matching Godot's select_mode.

public TreeSelectMode SelectMode { get; set; }

Property Value

TreeSelectMode

SelectedColumn

public int SelectedColumn { get; }

Property Value

int

SelectedItem

public TreeItem SelectedItem { get; }

Property Value

TreeItem

SelfDragDropEnabled

Enables retained same-tree drag reparenting. Godot applications commonly provide their own payload policy through the Control drag/drop virtuals, so this is opt-in.

public bool SelfDragDropEnabled { get; set; }

Property Value

bool

TileScrollHint

Retains Godot's texture tiling policy for themed scroll hints. The default retained solid hint does not tile.

public bool TileScrollHint { get; }

Property Value

bool

TouchDragSpeed

public float TouchDragSpeed { get; }

Property Value

float

UIFont

public UIFont UIFont { get; set; }

Property Value

UIFont

VerticalScrollEnabled

Enables Tree vertical scrolling, matching Godot's set_v_scroll_enabled().

public bool VerticalScrollEnabled { get; }

Property Value

bool

Methods

AreColumnTitlesVisible()

public bool AreColumnTitlesVisible()

Returns

bool

ArrangeChildren()

protected override void ArrangeChildren()

BeginTouchDragScroll()

Begins a retained vertical touch drag, mirroring Godot's touchscreen mouse-press handling in Tree::gui_input.

public void BeginTouchDragScroll()

CanDropData(Point, object)

Returns whether this control accepts the supplied data at the screen position.

public override bool CanDropData(Point position, object data)

Parameters

position Point
data object

Returns

bool

CancelTouchDragScroll()

Cancels an in-progress touch drag immediately, mirroring Godot's Tree release/cleanup paths.

public void CancelTouchDragScroll()

Clear()

public void Clear()

ClearIncrementalSearch()

Clears the current incremental search prefix.

public void ClearIncrementalSearch()

CreateItem(TreeItem, int)

public TreeItem CreateItem(TreeItem parent = null, int index = -1)

Parameters

parent TreeItem
index int

Returns

TreeItem

DeselectAll()

Clears every selected cell and navigation cursor, matching Godot's deselect_all().

public void DeselectAll()

DropData(Point, object)

Receives data accepted by CanDropData(Point, object).

public override void DropData(Point position, object data)

Parameters

position Point
data object

EditSelected(bool)

Opens the selected editable cell for application-provided editing, matching Godot's edit_selected().

public bool EditSelected(bool forceEdit = false)

Parameters

forceEdit bool

Returns

bool

EndTouchDragScroll()

Ends a retained touch drag, entering inertial deceleration when speed is nonzero like Godot's release handling.

public void EndTouchDragScroll()

EnsureCursorIsVisible()

Reveals the active selection cursor, matching Godot's ensure_cursor_is_visible().

public void EnsureCursorIsVisible()

GetButtonIdAtPosition(Point)

Returns the action-button ID at a screen position, or -1 when the position does not hit a visible action button.

public int GetButtonIdAtPosition(Point position)

Parameters

position Point

Returns

int

GetColumnAtPosition(Point)

Returns the column of the visible item at a screen position, or -1 when none is present.

public int GetColumnAtPosition(Point position)

Parameters

position Point

Returns

int

GetColumnExpandRatio(int)

public int GetColumnExpandRatio(int column)

Parameters

column int

Returns

int

GetColumnMinimumWidth(int)

public int GetColumnMinimumWidth(int column)

Parameters

column int

Returns

int

GetColumnTitle(int)

public string GetColumnTitle(int column)

Parameters

column int

Returns

string

GetColumnTitleAlignment(int)

public HorizontalAlignment GetColumnTitleAlignment(int column)

Parameters

column int

Returns

HorizontalAlignment

GetColumnTitleDirection(int)

public TextDirection GetColumnTitleDirection(int column)

Parameters

column int

Returns

TextDirection

GetColumnTitleLanguage(int)

public string GetColumnTitleLanguage(int column)

Parameters

column int

Returns

string

GetColumnTitleTooltipText(int)

public string GetColumnTitleTooltipText(int column)

Parameters

column int

Returns

string

GetColumnWidth(int)

Returns the current rendered width of a column, matching Godot's get_column_width().

public int GetColumnWidth(int column)

Parameters

column int

Returns

int

GetCustomPopupRect()

Returns the edited custom cell's rectangle for application popup placement, matching Godot's get_custom_popup_rect().

public Rectangle GetCustomPopupRect()

Returns

Rectangle

GetDragData(Point)

Returns data to drag, or null to decline starting a drag.

public override object GetDragData(Point position)

Parameters

position Point

Returns

object

GetDropSectionAtPosition(Point)

Returns Godot's drop section (-1 before, 0 on, 1 after, 2 as first child), or DropSectionNotFound.

public int GetDropSectionAtPosition(Point position)

Parameters

position Point

Returns

int

GetEdited()

Returns the cell currently opened for editing, matching Godot's get_edited().

public TreeItem GetEdited()

Returns

TreeItem

GetEditedColumn()

public int GetEditedColumn()

Returns

int

GetHScrollBar()

Returns the retained horizontal scrollbar, matching Godot's get_h_scroll_bar().

public HScrollBar GetHScrollBar()

Returns

HScrollBar

GetItemAreaRectangle(TreeItem, int, int)

Returns the on-screen rectangle for an item's cell or a cell action button.

public Rectangle GetItemAreaRectangle(TreeItem item, int column = -1, int button = -1)

Parameters

item TreeItem
column int
button int

Returns

Rectangle

GetItemAtPosition(Point)

Returns the visible item at a screen position, matching Godot's get_item_at_position().

public TreeItem GetItemAtPosition(Point position)

Parameters

position Point

Returns

TreeItem

GetItemOffset(TreeItem)

Returns an item's unscrolled top offset inside the retained Tree, or zero when it is not reachable in the expanded hierarchy.

public int GetItemOffset(TreeItem item)

Parameters

item TreeItem

Returns

int

GetItemWithMetadata(object, int)

Finds the first item in tree order with matching cell metadata, matching Godot's get_item_with_metadata().

public TreeItem GetItemWithMetadata(object metadata, int column = -1)

Parameters

metadata object
column int

Returns

TreeItem

GetItemWithText(string)

Finds the first visible item with exactly matching text in any column, matching Godot's get_item_with_text().

public TreeItem GetItemWithText(string text)

Parameters

text string

Returns

TreeItem

GetLastItem()

Returns the deepest final child of the root while it remains expanded, matching Godot's get_last_item().

public TreeItem GetLastItem()

Returns

TreeItem

GetNextSelected(TreeItem)

Returns the next selected item in complete tree order after from, matching Godot's get_next_selected().

public TreeItem GetNextSelected(TreeItem from = null)

Parameters

from TreeItem

Returns

TreeItem

GetNextVisible(TreeItem, bool)

Returns the next rendered tree item after item.

public TreeItem GetNextVisible(TreeItem item, bool wrap = false)

Parameters

item TreeItem
wrap bool

Returns

TreeItem

GetPressedButton()

Returns the index of the action button held by the current pointer gesture, or -1.

public int GetPressedButton()

Returns

int

GetRangeEditorLineEdit()

Returns the numeric text entry owned by GetRangeEditorPopup().

public LineEdit GetRangeEditorLineEdit()

Returns

LineEdit

GetRangeEditorPopup()

Returns the retained inline editor used by editable numeric range cells.

public PopupPanel GetRangeEditorPopup()

Returns

PopupPanel

GetRangeEditorSlider()

Returns the slider synchronized with GetRangeEditorLineEdit().

public HSlider GetRangeEditorSlider()

Returns

HSlider

GetRangePopup()

Returns the retained option menu used by editable labeled range cells.

public PopupMenu GetRangePopup()

Returns

PopupMenu

Remarks

Godot owns this popup internally; exposing it here permits host styling and deterministic inspection.

GetRoot()

Returns the first root item, matching Godot's get_root().

public TreeItem GetRoot()

Returns

TreeItem

GetScroll()

Returns the retained scroll position, matching Godot's get_scroll().

public Vector2 GetScroll()

Returns

Vector2

GetScrollHintMode()

public TreeScrollHintMode GetScrollHintMode()

Returns

TreeScrollHintMode

GetSelectMode()

public TreeSelectMode GetSelectMode()

Returns

TreeSelectMode

GetSelected()

public TreeItem GetSelected()

Returns

TreeItem

GetSelectedColumn()

public int GetSelectedColumn()

Returns

int

GetStringEditorLineEdit()

Returns the single-line editor used for a Tree string cell without edit_multiline.

public LineEdit GetStringEditorLineEdit()

Returns

LineEdit

GetStringEditorPopup()

Returns the popup that hosts editable string Tree cells.

public PopupPanel GetStringEditorPopup()

Returns

PopupPanel

GetStringEditorTextEdit()

Returns the multiline editor used for a Tree string cell with edit_multiline.

public TextEdit GetStringEditorTextEdit()

Returns

TextEdit

GetTooltip(Point)

Returns the tooltip at a global pointer position. Override to provide dynamic help text.

public override string GetTooltip(Point position)

Parameters

position Point

Returns

string

GetVScrollBar()

Returns the retained vertical scrollbar, matching Godot's get_v_scroll_bar().

public VScrollBar GetVScrollBar()

Returns

VScrollBar

IsAnythingSelected()

Returns whether the Tree has a selection cursor, matching Godot's is_anything_selected().

public bool IsAnythingSelected()

Returns

bool

IsAutoTooltipEnabled()

public bool IsAutoTooltipEnabled()

Returns

bool

IsColumnClippingContent(int)

public bool IsColumnClippingContent(int column)

Parameters

column int

Returns

bool

IsColumnExpanding(int)

public bool IsColumnExpanding(int column)

Parameters

column int

Returns

bool

IsDragUnfoldingEnabled()

public bool IsDragUnfoldingEnabled()

Returns

bool

IsEditCheckboxCellOnlyWhenCheckboxPressed()

public bool IsEditCheckboxCellOnlyWhenCheckboxPressed()

Returns

bool

IsEditing()

public bool IsEditing()

Returns

bool

IsFoldingHidden()

public bool IsFoldingHidden()

Returns

bool

IsHorizontalScrollEnabled()

public bool IsHorizontalScrollEnabled()

Returns

bool

IsRecursiveFoldingEnabled()

public bool IsRecursiveFoldingEnabled()

Returns

bool

IsRootHidden()

public bool IsRootHidden()

Returns

bool

IsScrollHintTiled()

public bool IsScrollHintTiled()

Returns

bool

IsVerticalScrollEnabled()

public bool IsVerticalScrollEnabled()

Returns

bool

OnTemplateApplied()

protected override void OnTemplateApplied()

ScrollToItem(TreeItem, bool)

Scrolls as little as necessary to reveal an item, matching Godot's scroll_to_item().

public void ScrollToItem(TreeItem item, bool centerOnItem = false)

Parameters

item TreeItem
centerOnItem bool

SearchItemText(string, out int, bool)

Finds the next visible item whose cell starts with text, wrapping from the active selection as Godot's search_item_text() does.

public TreeItem SearchItemText(string text, out int column, bool selectable = false)

Parameters

text string
column int
selectable bool

Returns

TreeItem

Select(TreeItem, int, bool)

public void Select(TreeItem item, int column = 0, bool emit = true)

Parameters

item TreeItem
column int
emit bool

SetAutoTooltip(bool)

public void SetAutoTooltip(bool enabled)

Parameters

enabled bool

SetColumnClipContent(int, bool)

Clips icons, text, buttons, and custom drawing to a column's cell bounds, matching Godot's set_column_clip_content().

public void SetColumnClipContent(int column, bool clip)

Parameters

column int
clip bool

SetColumnCustomMinimumWidth(int, int)

public void SetColumnCustomMinimumWidth(int column, int minimumWidth)

Parameters

column int
minimumWidth int

SetColumnExpand(int, bool)

public void SetColumnExpand(int column, bool expand)

Parameters

column int
expand bool

SetColumnExpandRatio(int, int)

public void SetColumnExpandRatio(int column, int ratio)

Parameters

column int
ratio int

SetColumnTitle(int, string)

public void SetColumnTitle(int column, string title)

Parameters

column int
title string

SetColumnTitleAlignment(int, HorizontalAlignment)

public void SetColumnTitleAlignment(int column, HorizontalAlignment alignment)

Parameters

column int
alignment HorizontalAlignment

SetColumnTitleDirection(int, TextDirection)

Sets the shaping direction for a column title, matching Godot's set_column_title_direction().

public void SetColumnTitleDirection(int column, TextDirection direction)

Parameters

column int
direction TextDirection

Remarks

Direction is retained for the text renderer. The default SpriteFont renderer does not yet provide Godot's Unicode/bidi shaping behavior.

SetColumnTitleLanguage(int, string)

Sets the BCP-47 language hint for a column title, matching Godot's set_column_title_language().

public void SetColumnTitleLanguage(int column, string language)

Parameters

column int
language string

Remarks

The hint is retained for shaped-text capable renderers; the default SpriteFont renderer does not yet use language-specific shaping.

SetColumnTitleTooltipText(int, string)

public void SetColumnTitleTooltipText(int column, string tooltip)

Parameters

column int
tooltip string

SetColumnTitlesVisible(bool)

public void SetColumnTitlesVisible(bool visible)

Parameters

visible bool

SetEditCheckboxCellOnlyWhenCheckboxPressed(bool)

public void SetEditCheckboxCellOnlyWhenCheckboxPressed(bool enabled)

Parameters

enabled bool

SetEnableDragUnfolding(bool)

public void SetEnableDragUnfolding(bool enabled)

Parameters

enabled bool

SetEnableRecursiveFolding(bool)

public void SetEnableRecursiveFolding(bool enabled)

Parameters

enabled bool

SetHideFolding(bool)

public void SetHideFolding(bool hidden)

Parameters

hidden bool

SetHideRoot(bool)

public void SetHideRoot(bool hidden)

Parameters

hidden bool

SetHorizontalScrollEnabled(bool)

public void SetHorizontalScrollEnabled(bool enabled)

Parameters

enabled bool

SetScrollHintMode(TreeScrollHintMode)

public void SetScrollHintMode(TreeScrollHintMode mode)

Parameters

mode TreeScrollHintMode

SetSelectMode(TreeSelectMode)

public void SetSelectMode(TreeSelectMode mode)

Parameters

mode TreeSelectMode

SetSelected(TreeItem, int)

Compatibility method for Godot's set_selected(); it replaces the existing selection.

public void SetSelected(TreeItem item, int column = 0)

Parameters

item TreeItem
column int

SetTileScrollHint(bool)

public void SetTileScrollHint(bool enabled)

Parameters

enabled bool

SetVerticalScrollEnabled(bool)

public void SetVerticalScrollEnabled(bool enabled)

Parameters

enabled bool

TouchDragScrollBy(float, float)

Applies relative vertical touch motion and its instantaneous velocity, mirroring Godot's gui_input drag accumulation.

public void TouchDragScrollBy(float relativeMotion, float velocity)

Parameters

relativeMotion float
velocity float

Events

ButtonClicked

Raised when an enabled TreeItem action button is clicked. Arguments are item, column, and button id.

public event Action<Tree, TreeItem, int, int> ButtonClicked

Event Type

Action<Tree, TreeItem, int, int>

CellSelected

public event Action<Tree, TreeItem, int> CellSelected

Event Type

Action<Tree, TreeItem, int>

CheckPropagatedToItem

Raised for each item affected by PropagateCheck(int, bool), matching Godot's check_propagated_to_item signal.

public event Action<Tree, TreeItem, int> CheckPropagatedToItem

Event Type

Action<Tree, TreeItem, int>

ColumnResized

Raised after an interactive column-header resize changes the retained minimum width.

public event Action<Tree, int, int> ColumnResized

Event Type

Action<Tree, int, int>

ColumnTitleClicked

Raised on left or right release over a visible column title, corresponding to Godot's column_title_clicked(column, mouse_button_index) signal.

public event Action<Tree, int, PointerButton> ColumnTitleClicked

Event Type

Action<Tree, int, PointerButton>

CustomPopupEdited

Raised when a custom cell requests an application popup, matching Godot's custom_popup_edited signal. Query the edited-cell methods for context.

public event Action<Tree, bool> CustomPopupEdited

Event Type

Action<Tree, bool>

ItemActivated

public event Action<Tree, TreeItem> ItemActivated

Event Type

Action<Tree, TreeItem>

ItemCollapsed

public event Action<Tree, TreeItem> ItemCollapsed

Event Type

Action<Tree, TreeItem>

ItemDropped

Raised after an opt-in same-tree drag successfully changes hierarchy. Arguments are dragged item, target item, and drop section.

public event Action<Tree, TreeItem, TreeItem, int> ItemDropped

Event Type

Action<Tree, TreeItem, TreeItem, int>

ItemEdited

public event Action<Tree, TreeItem, int> ItemEdited

Event Type

Action<Tree, TreeItem, int>

ItemMouseSelected

Raised when item selection is initiated with a pointer button, corresponding to Godot's item_mouse_selected(mouse_position, mouse_button_index) signal.

public event Action<Tree, Point, PointerButton> ItemMouseSelected

Event Type

Action<Tree, Point, PointerButton>

ItemSelected

public event Action<Tree, TreeItem> ItemSelected

Event Type

Action<Tree, TreeItem>

MultiSelected

Raised when a cell is selected or deselected in multi-select mode. The final argument is the new selected state.

public event Action<Tree, TreeItem, int, bool> MultiSelected

Event Type

Action<Tree, TreeItem, int, bool>