Skip to content

Latest commit

 

History

History
359 lines (228 loc) · 23.7 KB

class_tree.rst

File metadata and controls

359 lines (228 loc) · 23.7 KB

Tree

Inherits: Control<class_control> < CanvasItem<class_canvasitem> < Node<class_node> < Object<class_object>

Category: Core

Brief Description

Control to show a tree of items.

Member Functions

bool<class_bool> are_column_titles_visible<class_Tree_are_column_titles_visible> ( ) const
void clear<class_Tree_clear> ( )
TreeItem<class_treeitem> create_item<class_Tree_create_item> ( TreeItem<class_treeitem> parent=NULL )
void ensure_cursor_is_visible<class_Tree_ensure_cursor_is_visible> ( )
bool<class_bool> get_allow_rmb_select<class_Tree_get_allow_rmb_select> ( ) const
int<class_int> get_column_at_pos<class_Tree_get_column_at_pos> ( Vector2<class_vector2> pos ) const
String<class_string> get_column_title<class_Tree_get_column_title> ( int<class_int> column ) const
int<class_int> get_column_width<class_Tree_get_column_width> ( int<class_int> column ) const
int<class_int> get_columns<class_Tree_get_columns> ( ) const
Rect2<class_rect2> get_custom_popup_rect<class_Tree_get_custom_popup_rect> ( ) const
int<class_int> get_drop_mode_flags<class_Tree_get_drop_mode_flags> ( ) const
TreeItem<class_treeitem> get_edited<class_Tree_get_edited> ( ) const
int<class_int> get_edited_column<class_Tree_get_edited_column> ( ) const
Rect2<class_rect2> get_item_area_rect<class_Tree_get_item_area_rect> ( TreeItem<class_treeitem> item, int<class_int> column=-1 ) const
TreeItem<class_treeitem> get_item_at_pos<class_Tree_get_item_at_pos> ( Vector2<class_vector2> pos ) const
TreeItem<class_treeitem> get_next_selected<class_Tree_get_next_selected> ( TreeItem<class_treeitem> from )
int<class_int> get_pressed_button<class_Tree_get_pressed_button> ( ) const
TreeItem<class_treeitem> get_root<class_Tree_get_root> ( )
Vector2<class_vector2> get_scroll<class_Tree_get_scroll> ( ) const
TreeItem<class_treeitem> get_selected<class_Tree_get_selected> ( ) const
int<class_int> get_selected_column<class_Tree_get_selected_column> ( ) const
bool<class_bool> get_single_select_cell_editing_only_when_already_selected<class_Tree_get_single_select_cell_editing_only_when_already_selected> ( ) const
bool<class_bool> is_folding_hidden<class_Tree_is_folding_hidden> ( ) const
void set_allow_rmb_select<class_Tree_set_allow_rmb_select> ( bool<class_bool> allow )
void set_column_expand<class_Tree_set_column_expand> ( int<class_int> column, bool<class_bool> expand )
void set_column_min_width<class_Tree_set_column_min_width> ( int<class_int> column, int<class_int> min_width )
void set_column_title<class_Tree_set_column_title> ( int<class_int> column, String<class_string> title )
void set_column_titles_visible<class_Tree_set_column_titles_visible> ( bool<class_bool> visible )
void set_columns<class_Tree_set_columns> ( int<class_int> amount )
void set_drop_mode_flags<class_Tree_set_drop_mode_flags> ( int<class_int> flags )
void set_hide_folding<class_Tree_set_hide_folding> ( bool<class_bool> hide )
void set_hide_root<class_Tree_set_hide_root> ( bool<class_bool> enable )
void set_select_mode<class_Tree_set_select_mode> ( int<class_int> mode )
void set_single_select_cell_editing_only_when_already_selected<class_Tree_set_single_select_cell_editing_only_when_already_selected> ( bool<class_bool> enable )

Signals

- button_pressed ( Object<class_object> item, int<class_int> column, int<class_int> id ) Emitted when a button on the tree was pressed (see TreeItem.add_button<class_TreeItem_add_button>).

- cell_selected ( ) Emitted when a cell is selected.

  • column_title_pressed ( int<class_int> column )

- custom_popup_edited ( bool<class_bool> arrow_clicked ) Emitted when a cell with the CELL_MODE_CUSTOM is clicked to be edited.

- empty_tree_rmb_selected ( Vector2<class_vector2> pos ) Emitted when the right mouse button is pressed if RMB selection is active and the tree is empty.

- item_activated ( ) Emitted when an item is activated (double-clicked).

- item_collapsed ( Object<class_object> item ) Emitted when an item is collapsed by a click on the folding arrow.

- item_edited ( ) Emitted when an item is editted.

- item_rmb_selected ( Vector2<class_vector2> pos ) Emitted when an item is selected with right mouse button.

- item_selected ( ) Emitted when an item is selected with right mouse button.

  • multi_selected ( Object<class_object> item, int<class_int> column, bool<class_bool> selected )

Numeric Constants

  • SELECT_SINGLE = 0
  • SELECT_ROW = 1
  • SELECT_MULTI = 2
  • DROP_MODE_DISABLED = 0
  • DROP_MODE_ON_ITEM = 1
  • DROP_MODE_INBETWEEN = 2

Description

This shows a tree of items that can be selected, expanded and collapsed. The tree can have multiple columns with custom controls like text editing, buttons and popups. It can be useful for structural displaying and interactions.

Trees are built via code, using TreeItem<class_treeitem> objects to create the structure. They have a single root but multiple root can be simulated if a dummy hidden root is added.

func _ready():
    var tree = Tree.new()
    var root = tree.create_item()
    tree.set_hide_root(true)
    var child1 = tree.create_item(root)
    var child2 = tree.create_item(root)
    var subchild1 = tree.create_item(child1)
    subchild1.set_text(0, "Subchild1")

Member Function Description

  • bool<class_bool> are_column_titles_visible ( ) const

Get whether the column titles are being shown.

  • void clear ( )

Clear the tree. This erases all of the items.

  • TreeItem<class_treeitem> create_item ( TreeItem<class_treeitem> parent=NULL )

Create an item in the tree and add it as the last child of parent. If parent is not given, it will be added as the last child of the root, or it'll the be the root itself if the tree is empty.

  • void ensure_cursor_is_visible ( )

Make the current selected item visible. This will scroll the tree to make sure the selected item is in sight.

  • bool<class_bool> get_allow_rmb_select ( ) const

Get whether a right click can select items.

  • int<class_int> get_column_at_pos ( Vector2<class_vector2> pos ) const

Get the column index under the given point.

  • String<class_string> get_column_title ( int<class_int> column ) const

Get the title of the given column.

  • int<class_int> get_column_width ( int<class_int> column ) const

Get the width of the given column in pixels.

  • int<class_int> get_columns ( ) const

Get the amount of columns.

  • Rect2<class_rect2> get_custom_popup_rect ( ) const

Get the rectangle for custom popups. Helper to create custom cell controls that display a popup. See TreeItem.set_cell_mode<class_TreeItem_set_cell_mode>.

  • int<class_int> get_drop_mode_flags ( ) const

Get the flags of the current drop mode.

  • TreeItem<class_treeitem> get_edited ( ) const

Get the current edited item. This is only available for custom cell mode.

  • int<class_int> get_edited_column ( ) const

Get the column of the cell for the current edited icon. This is only available for custom cell mode.

  • Rect2<class_rect2> get_item_area_rect ( TreeItem<class_treeitem> item, int<class_int> column=-1 ) const

Get the rectangle area of the the specified item. If column is specified, only get the position and size of that column, otherwise get the rectangle containing all columns.

  • TreeItem<class_treeitem> get_item_at_pos ( Vector2<class_vector2> pos ) const

Get the tree item at the specified position (relative to the tree origin position).

  • TreeItem<class_treeitem> get_next_selected ( TreeItem<class_treeitem> from )

Get the next selected item after the given one.

  • int<class_int> get_pressed_button ( ) const

Get the index of the last pressed button.

  • TreeItem<class_treeitem> get_root ( )

Get the root item of the tree.

  • Vector2<class_vector2> get_scroll ( ) const

Get the current scrolling position.

  • TreeItem<class_treeitem> get_selected ( ) const

Get the currently selected item.

  • int<class_int> get_selected_column ( ) const

Get the column number of the current selection.

  • bool<class_bool> get_single_select_cell_editing_only_when_already_selected ( ) const

Get whether the editing of a cell should only happen when it is already selected.

  • bool<class_bool> is_folding_hidden ( ) const

Get whether the folding arrow is hidden.

  • void set_allow_rmb_select ( bool<class_bool> allow )

Set whether or not a right mouse button click can select items.

  • void set_column_expand ( int<class_int> column, bool<class_bool> expand )

Set whether a column will have the "Expand" flag of Control<class_control>.

  • void set_column_min_width ( int<class_int> column, int<class_int> min_width )

Set the minimum width of a column.

  • void set_column_title ( int<class_int> column, String<class_string> title )

Set the title of a column.

  • void set_column_titles_visible ( bool<class_bool> visible )

Set whether the column titles visibility.

  • void set_columns ( int<class_int> amount )

Set the amount of columns.

  • void set_drop_mode_flags ( int<class_int> flags )

Set the drop mode as an OR combination of flags. See DROP_MODE\_\* constants.

  • void set_hide_folding ( bool<class_bool> hide )

Set whether the folding arrow should be hidden.

  • void set_hide_root ( bool<class_bool> enable )

Set whether the root of the tree should be hidden.

  • void set_select_mode ( int<class_int> mode )

Set the selection mode. Use one of the SELECT\_\* constants.

  • void set_single_select_cell_editing_only_when_already_selected ( bool<class_bool> enable )

Set whether the editing of a cell should only happen when it is already selected.