TreeItem

Inherits: Object

控件 Tree 中的单个项目。

描述

控件Tree中的单个项目。可以有子级TreeItem, 样式, 以及包含按钮。

您可以使用Object.free删除TreeItem

属性

bool

collapsed

int

custom_minimum_height

bool

disable_folding

方法

void

add_button ( int column, Texture button, int button_idx=-1, bool disabled=false, String tooltip=”” )

Variant

call_recursive ( String method, … ) vararg

void

clear_custom_bg_color ( int column )

void

clear_custom_color ( int column )

void

deselect ( int column )

void

erase_button ( int column, int button_idx )

Texture

get_button ( int column, int button_idx ) const

int

get_button_count ( int column ) const

String

get_button_tooltip ( int column, int button_idx ) const

TreeCellMode

get_cell_mode ( int column ) const

TreeItem

get_children ( )

Color

get_custom_bg_color ( int column ) const

Color

get_custom_color ( int column ) const

bool

get_expand_right ( int column ) const

Texture

get_icon ( int column ) const

int

get_icon_max_width ( int column ) const

Color

get_icon_modulate ( int column ) const

Rect2

get_icon_region ( int column ) const

Variant

get_metadata ( int column ) const

TreeItem

get_next ( )

TreeItem

get_next_visible ( bool wrap=false )

TreeItem

get_parent ( )

TreeItem

get_prev ( )

TreeItem

get_prev_visible ( bool wrap=false )

float

get_range ( int column ) const

Dictionary

get_range_config ( int column )

String

get_suffix ( int column ) const

String

get_text ( int column ) const

TextAlign

get_text_align ( int column ) const

String

get_tooltip ( int column ) const

bool

is_button_disabled ( int column, int button_idx ) const

bool

is_checked ( int column ) const

bool

is_custom_set_as_button ( int column ) const

bool

is_editable ( int column )

bool

is_selectable ( int column ) const

bool

is_selected ( int column )

void

move_to_bottom ( )

void

move_to_top ( )

void

remove_child ( Object child )

void

select ( int column )

void

set_button ( int column, int button_idx, Texture button )

void

set_button_disabled ( int column, int button_idx, bool disabled )

void

set_cell_mode ( int column, TreeCellMode mode )

void

set_checked ( int column, bool checked )

void

set_custom_as_button ( int column, bool enable )

void

set_custom_bg_color ( int column, Color color, bool just_outline=false )

void

set_custom_color ( int column, Color color )

void

set_custom_draw ( int column, Object object, String callback )

void

set_editable ( int column, bool enabled )

void

set_expand_right ( int column, bool enable )

void

set_icon ( int column, Texture texture )

void

set_icon_max_width ( int column, int width )

void

set_icon_modulate ( int column, Color modulate )

void

set_icon_region ( int column, Rect2 region )

void

set_metadata ( int column, Variant meta )

void

set_range ( int column, float value )

void

set_range_config ( int column, float min, float max, float step, bool expr=false )

void

set_selectable ( int column, bool selectable )

void

set_suffix ( int column, String text )

void

set_text ( int column, String text )

void

set_text_align ( int column, TextAlign text_align )

void

set_tooltip ( int column, String tooltip )

枚举

enum TreeCellMode:

  • CELL_MODE_STRING = 0 —- 单元包含字符串。

  • CELL_MODE_CHECK = 1 —- 单元格包含复选框。

  • CELL_MODE_RANGE = 2 —- 单元包含一个范围。

  • CELL_MODE_ICON = 3 —- 单元包含图标。

  • CELL_MODE_CUSTOM = 4


enum TextAlign:

  • ALIGN_LEFT = 0 —- 将文本向左对齐。参阅set_text_align()

  • ALIGN_CENTER = 1 —- 将文本居中。参阅set_text_align()

  • ALIGN_RIGHT = 2 —- 将文本向右对齐。参阅set_text_align()

属性说明

Setter

set_collapsed(value)

Getter

is_collapsed()

如果true,TreeItem树项被折叠。


  • int custom_minimum_height

Setter

set_custom_minimum_height(value)

Getter

get_custom_minimum_height()

自定义最小高度。


  • bool disable_folding

Setter

set_disable_folding(value)

Getter

is_folding_disabled()

如果true,则TreeItem树项禁用折叠。

方法说明

column 列添加一个带有 Texture button 的按钮。 button_idx 索引用于在调用其他方法时标识按钮。如果未指定,则使用下一个可用索引,可以通过在此方法之后调用 get_button_count 来检索该索引。可选,该按钮可以 disabled 和具有 tooltip


在实际的TreeItem树项及其子项上递归地调用method。以逗号分隔的列表形式传递参数。


  • void clear_custom_bg_color ( int column )

重置指定列默认的背景颜色。


  • void clear_custom_color ( int column )

重置指定列默认的颜色。


  • void deselect ( int column )

取消选择指定列。


  • void erase_button ( int column, int button_idx )

删除列column中索引button_idx处的按钮。


返回在column中索引button_idx按钮的Texture


  • int get_button_count ( int column ) const

返回column中按钮的数量。如果没有指定索引,可以用来获取最近添加的按钮的索引。


  • String get_button_tooltip ( int column, int button_idx ) const

返回在column中索引button_idx按钮的提示信息字符串。


返回该列的单元格模式。


返回TreeItem树项的第一个子项,如果没有,则返回一个空对象。


  • Color get_custom_bg_color ( int column ) const

返回列column的自定义背景颜色。


  • Color get_custom_color ( int column ) const

返回列column的自定义颜色。


  • bool get_expand_right ( int column ) const

如果设置了expand_right,返回true


返回给定列图标的 Texture。如果未设置图标,则出错。


  • int get_icon_max_width ( int column ) const

返回列的图标的最大宽度。


  • Color get_icon_modulate ( int column ) const

返回调制列的图标的Color颜色。


  • Rect2 get_icon_region ( int column ) const

将图标 Texture 区域返回为 Rect2


返回使用 set_metadata 为指定列设置的元数据。


返回树中的下一个TreeItem树项,如果没有,则返回一个空对象。


返回树中下一个可见的TreeItem树项,如果没有,则返回空对象。

如果wrap被启用,当在最后一个可见元素上调用时,该方法将环绕到树中的第一个可见元素,否则它将返回null


返回父级TreeItem树项,如果没有,则返回一个空对象。


返回树中的前一个TreeItem树项,如果没有,则返回一个空对象。


返回树中前一个可见的TreeItem树项,如果没有,则返回null对象。

如果wrap被启用,当在第一个可见元素上调用时,该方法将环绕到树中最后一个可见元素,否则它将返回null


返回 CELL_MODE_RANGE 列的值。


返回包含给定列的范围参数的字典。键是 “min”、”max”、”step “和 “expr”。


获取显示在列值后面的后缀字符串。


返回给定列的文本。


返回给定列的文本对齐方式。


返回给定列的工具提示。


  • bool is_button_disabled ( int column, int button_idx ) const

如果给定列的索引button_idx处的按钮被禁用,返回true


  • bool is_checked ( int column ) const

如果给定的列被选中,返回true


  • bool is_custom_set_as_button ( int column ) const

如果列column是可编辑的,则返回true


  • bool is_selectable ( int column ) const

如果列column是可选择的,则返回true


如果列column被选中,返回true


  • void move_to_bottom ( )

将此TreeItem树项移动到Tree层次结构的底部。


  • void move_to_top ( )

将此TreeItem树项移动到Tree树层次结构的顶部。


  • void remove_child ( Object child )

将给定的子项TreeItem和它的所有子项从Tree中移除。注意,它并未从内存中释放该项,所以之后可重新使用。要完全删除一个TreeItem,请使用Object.free


  • void select ( int column )

选择列column


设置索引button_idx的给定列的按钮buttonTexture


  • void set_button_disabled ( int column, int button_idx, bool disabled )

如果true,则禁用列column中索引button_idx的按钮。


设置给定列的单元格模式为mode。参阅TreeCellMode常量。


  • void set_checked ( int column, bool checked )

如果true,则选中column


  • void set_custom_as_button ( int column, bool enable )

  • void set_custom_bg_color ( int column, Color color, bool just_outline=false )

设置给定列的自定义背景颜色,以及是否只将其作为一个轮廓。


  • void set_custom_color ( int column, Color color )

设置给定列的自定义颜色。


设置给定列的自定义绘制回调到object上的callback回调方法。

callback应该接受两个参数:被绘制的TreeItem树项以及它的位置和大小是一个Rect2


  • void set_editable ( int column, bool enabled )

truecolumn 列可编辑。


  • void set_expand_right ( int column, bool enable )

truecolumn 列将向右扩展。


设置给定列的图标 Texture


  • void set_icon_max_width ( int column, int width )

设置给定列图标的最大宽度。


  • void set_icon_modulate ( int column, Color modulate )

modulate调制给定列的图标。


  • void set_icon_region ( int column, Rect2 region )

设置给定列的图标的纹理区域。


设置给定列的元数据,之后可用 get_metadata 进行检索。例如,这可用于存储对原始数据的引用。


  • void set_range ( int column, float value )

设置 CELL_MODE_RANGE 列的值。


设置列的可接受值的范围。该列必须处于 CELL_MODE_RANGE 模式。

如果 exprtrue,编辑模式滑块将使用指数刻度,与 Range.exp_edit 一样。


  • void set_selectable ( int column, bool selectable )

如果true,给定的列是可选择的。


设置字符串,显示在列的值之后,例如,单位的缩写。


设置给定列的文本值。


设置给定列的文本对齐方式。可能的值,参阅TextAlign


  • void set_tooltip ( int column, String tooltip )

设置给定列的工具提示文本。