TreeItem.xml 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="TreeItem" inherits="Object" version="3.3">
  3. <brief_description>
  4. Control for a single item inside a [Tree].
  5. </brief_description>
  6. <description>
  7. Control for a single item inside a [Tree]. May have child [TreeItem]s and be styled as well as contain buttons.
  8. You can remove a [TreeItem] by using [method Object.free].
  9. </description>
  10. <tutorials>
  11. </tutorials>
  12. <methods>
  13. <method name="add_button">
  14. <return type="void" />
  15. <argument index="0" name="column" type="int" />
  16. <argument index="1" name="button" type="Texture" />
  17. <argument index="2" name="button_idx" type="int" default="-1" />
  18. <argument index="3" name="disabled" type="bool" default="false" />
  19. <argument index="4" name="tooltip" type="String" default="&quot;&quot;" />
  20. <description>
  21. Adds a button with [Texture] [code]button[/code] at column [code]column[/code]. The [code]button_idx[/code] index is used to identify the button when calling other methods. If not specified, the next available index is used, which may be retrieved by calling [method get_button_count] immediately after this method. Optionally, the button can be [code]disabled[/code] and have a [code]tooltip[/code].
  22. </description>
  23. </method>
  24. <method name="call_recursive" qualifiers="vararg">
  25. <return type="Variant" />
  26. <argument index="0" name="method" type="String" />
  27. <description>
  28. Calls the [code]method[/code] on the actual TreeItem and its children recursively. Pass parameters as a comma separated list.
  29. </description>
  30. </method>
  31. <method name="clear_custom_bg_color">
  32. <return type="void" />
  33. <argument index="0" name="column" type="int" />
  34. <description>
  35. Resets the background color for the given column to default.
  36. </description>
  37. </method>
  38. <method name="clear_custom_color">
  39. <return type="void" />
  40. <argument index="0" name="column" type="int" />
  41. <description>
  42. Resets the color for the given column to default.
  43. </description>
  44. </method>
  45. <method name="deselect">
  46. <return type="void" />
  47. <argument index="0" name="column" type="int" />
  48. <description>
  49. Deselects the given column.
  50. </description>
  51. </method>
  52. <method name="erase_button">
  53. <return type="void" />
  54. <argument index="0" name="column" type="int" />
  55. <argument index="1" name="button_idx" type="int" />
  56. <description>
  57. Removes the button at index [code]button_idx[/code] in column [code]column[/code].
  58. </description>
  59. </method>
  60. <method name="get_button" qualifiers="const">
  61. <return type="Texture" />
  62. <argument index="0" name="column" type="int" />
  63. <argument index="1" name="button_idx" type="int" />
  64. <description>
  65. Returns the [Texture] of the button at index [code]button_idx[/code] in column [code]column[/code].
  66. </description>
  67. </method>
  68. <method name="get_button_count" qualifiers="const">
  69. <return type="int" />
  70. <argument index="0" name="column" type="int" />
  71. <description>
  72. Returns the number of buttons in column [code]column[/code]. May be used to get the most recently added button's index, if no index was specified.
  73. </description>
  74. </method>
  75. <method name="get_button_tooltip" qualifiers="const">
  76. <return type="String" />
  77. <argument index="0" name="column" type="int" />
  78. <argument index="1" name="button_idx" type="int" />
  79. <description>
  80. Returns the tooltip string for the button at index [code]button_idx[/code] in column [code]column[/code].
  81. </description>
  82. </method>
  83. <method name="get_cell_mode" qualifiers="const">
  84. <return type="int" enum="TreeItem.TreeCellMode" />
  85. <argument index="0" name="column" type="int" />
  86. <description>
  87. Returns the column's cell mode.
  88. </description>
  89. </method>
  90. <method name="get_children">
  91. <return type="TreeItem" />
  92. <description>
  93. Returns the TreeItem's first child item or a null object if there is none.
  94. </description>
  95. </method>
  96. <method name="get_custom_bg_color" qualifiers="const">
  97. <return type="Color" />
  98. <argument index="0" name="column" type="int" />
  99. <description>
  100. Returns the custom background color of column [code]column[/code].
  101. </description>
  102. </method>
  103. <method name="get_custom_color" qualifiers="const">
  104. <return type="Color" />
  105. <argument index="0" name="column" type="int" />
  106. <description>
  107. Returns the custom color of column [code]column[/code].
  108. </description>
  109. </method>
  110. <method name="get_expand_right" qualifiers="const">
  111. <return type="bool" />
  112. <argument index="0" name="column" type="int" />
  113. <description>
  114. Returns [code]true[/code] if [code]expand_right[/code] is set.
  115. </description>
  116. </method>
  117. <method name="get_icon" qualifiers="const">
  118. <return type="Texture" />
  119. <argument index="0" name="column" type="int" />
  120. <description>
  121. Returns the given column's icon [Texture]. Error if no icon is set.
  122. </description>
  123. </method>
  124. <method name="get_icon_max_width" qualifiers="const">
  125. <return type="int" />
  126. <argument index="0" name="column" type="int" />
  127. <description>
  128. Returns the column's icon's maximum width.
  129. </description>
  130. </method>
  131. <method name="get_icon_modulate" qualifiers="const">
  132. <return type="Color" />
  133. <argument index="0" name="column" type="int" />
  134. <description>
  135. Returns the [Color] modulating the column's icon.
  136. </description>
  137. </method>
  138. <method name="get_icon_region" qualifiers="const">
  139. <return type="Rect2" />
  140. <argument index="0" name="column" type="int" />
  141. <description>
  142. Returns the icon [Texture] region as [Rect2].
  143. </description>
  144. </method>
  145. <method name="get_metadata" qualifiers="const">
  146. <return type="Variant" />
  147. <argument index="0" name="column" type="int" />
  148. <description>
  149. Returns the metadata value that was set for the given column using [method set_metadata].
  150. </description>
  151. </method>
  152. <method name="get_next">
  153. <return type="TreeItem" />
  154. <description>
  155. Returns the next TreeItem in the tree or a null object if there is none.
  156. </description>
  157. </method>
  158. <method name="get_next_visible">
  159. <return type="TreeItem" />
  160. <argument index="0" name="wrap" type="bool" default="false" />
  161. <description>
  162. Returns the next visible TreeItem in the tree or a null object if there is none.
  163. If [code]wrap[/code] is enabled, the method will wrap around to the first visible element in the tree when called on the last visible element, otherwise it returns [code]null[/code].
  164. </description>
  165. </method>
  166. <method name="get_parent">
  167. <return type="TreeItem" />
  168. <description>
  169. Returns the parent TreeItem or a null object if there is none.
  170. </description>
  171. </method>
  172. <method name="get_prev">
  173. <return type="TreeItem" />
  174. <description>
  175. Returns the previous TreeItem in the tree or a null object if there is none.
  176. </description>
  177. </method>
  178. <method name="get_prev_visible">
  179. <return type="TreeItem" />
  180. <argument index="0" name="wrap" type="bool" default="false" />
  181. <description>
  182. Returns the previous visible TreeItem in the tree or a null object if there is none.
  183. If [code]wrap[/code] is enabled, the method will wrap around to the last visible element in the tree when called on the first visible element, otherwise it returns [code]null[/code].
  184. </description>
  185. </method>
  186. <method name="get_range" qualifiers="const">
  187. <return type="float" />
  188. <argument index="0" name="column" type="int" />
  189. <description>
  190. Returns the value of a [constant CELL_MODE_RANGE] column.
  191. </description>
  192. </method>
  193. <method name="get_range_config">
  194. <return type="Dictionary" />
  195. <argument index="0" name="column" type="int" />
  196. <description>
  197. Returns a dictionary containing the range parameters for a given column. The keys are "min", "max", "step", and "expr".
  198. </description>
  199. </method>
  200. <method name="get_suffix" qualifiers="const">
  201. <return type="String" />
  202. <argument index="0" name="column" type="int" />
  203. <description>
  204. Gets the suffix string shown after the column value.
  205. </description>
  206. </method>
  207. <method name="get_text" qualifiers="const">
  208. <return type="String" />
  209. <argument index="0" name="column" type="int" />
  210. <description>
  211. Returns the given column's text.
  212. </description>
  213. </method>
  214. <method name="get_text_align" qualifiers="const">
  215. <return type="int" enum="TreeItem.TextAlign" />
  216. <argument index="0" name="column" type="int" />
  217. <description>
  218. Returns the given column's text alignment.
  219. </description>
  220. </method>
  221. <method name="get_tooltip" qualifiers="const">
  222. <return type="String" />
  223. <argument index="0" name="column" type="int" />
  224. <description>
  225. Returns the given column's tooltip.
  226. </description>
  227. </method>
  228. <method name="is_button_disabled" qualifiers="const">
  229. <return type="bool" />
  230. <argument index="0" name="column" type="int" />
  231. <argument index="1" name="button_idx" type="int" />
  232. <description>
  233. Returns [code]true[/code] if the button at index [code]button_idx[/code] for the given column is disabled.
  234. </description>
  235. </method>
  236. <method name="is_checked" qualifiers="const">
  237. <return type="bool" />
  238. <argument index="0" name="column" type="int" />
  239. <description>
  240. Returns [code]true[/code] if the given column is checked.
  241. </description>
  242. </method>
  243. <method name="is_custom_set_as_button" qualifiers="const">
  244. <return type="bool" />
  245. <argument index="0" name="column" type="int" />
  246. <description>
  247. </description>
  248. </method>
  249. <method name="is_editable">
  250. <return type="bool" />
  251. <argument index="0" name="column" type="int" />
  252. <description>
  253. Returns [code]true[/code] if column [code]column[/code] is editable.
  254. </description>
  255. </method>
  256. <method name="is_selectable" qualifiers="const">
  257. <return type="bool" />
  258. <argument index="0" name="column" type="int" />
  259. <description>
  260. Returns [code]true[/code] if column [code]column[/code] is selectable.
  261. </description>
  262. </method>
  263. <method name="is_selected">
  264. <return type="bool" />
  265. <argument index="0" name="column" type="int" />
  266. <description>
  267. Returns [code]true[/code] if column [code]column[/code] is selected.
  268. </description>
  269. </method>
  270. <method name="move_to_bottom">
  271. <return type="void" />
  272. <description>
  273. Moves this TreeItem to the bottom in the [Tree] hierarchy.
  274. </description>
  275. </method>
  276. <method name="move_to_top">
  277. <return type="void" />
  278. <description>
  279. Moves this TreeItem to the top in the [Tree] hierarchy.
  280. </description>
  281. </method>
  282. <method name="remove_child">
  283. <return type="void" />
  284. <argument index="0" name="child" type="Object" />
  285. <description>
  286. Removes the given child [TreeItem] and all its children from the [Tree]. Note that it doesn't free the item from memory, so it can be reused later. To completely remove a [TreeItem] use [method Object.free].
  287. </description>
  288. </method>
  289. <method name="select">
  290. <return type="void" />
  291. <argument index="0" name="column" type="int" />
  292. <description>
  293. Selects the column [code]column[/code].
  294. </description>
  295. </method>
  296. <method name="set_button">
  297. <return type="void" />
  298. <argument index="0" name="column" type="int" />
  299. <argument index="1" name="button_idx" type="int" />
  300. <argument index="2" name="button" type="Texture" />
  301. <description>
  302. Sets the given column's button [Texture] at index [code]button_idx[/code] to [code]button[/code].
  303. </description>
  304. </method>
  305. <method name="set_button_disabled">
  306. <return type="void" />
  307. <argument index="0" name="column" type="int" />
  308. <argument index="1" name="button_idx" type="int" />
  309. <argument index="2" name="disabled" type="bool" />
  310. <description>
  311. If [code]true[/code], disables the button at index [code]button_idx[/code] in column [code]column[/code].
  312. </description>
  313. </method>
  314. <method name="set_cell_mode">
  315. <return type="void" />
  316. <argument index="0" name="column" type="int" />
  317. <argument index="1" name="mode" type="int" enum="TreeItem.TreeCellMode" />
  318. <description>
  319. Sets the given column's cell mode to [code]mode[/code]. See [enum TreeCellMode] constants.
  320. </description>
  321. </method>
  322. <method name="set_checked">
  323. <return type="void" />
  324. <argument index="0" name="column" type="int" />
  325. <argument index="1" name="checked" type="bool" />
  326. <description>
  327. If [code]true[/code], the column [code]column[/code] is checked.
  328. </description>
  329. </method>
  330. <method name="set_custom_as_button">
  331. <return type="void" />
  332. <argument index="0" name="column" type="int" />
  333. <argument index="1" name="enable" type="bool" />
  334. <description>
  335. </description>
  336. </method>
  337. <method name="set_custom_bg_color">
  338. <return type="void" />
  339. <argument index="0" name="column" type="int" />
  340. <argument index="1" name="color" type="Color" />
  341. <argument index="2" name="just_outline" type="bool" default="false" />
  342. <description>
  343. Sets the given column's custom background color and whether to just use it as an outline.
  344. </description>
  345. </method>
  346. <method name="set_custom_color">
  347. <return type="void" />
  348. <argument index="0" name="column" type="int" />
  349. <argument index="1" name="color" type="Color" />
  350. <description>
  351. Sets the given column's custom color.
  352. </description>
  353. </method>
  354. <method name="set_custom_draw">
  355. <return type="void" />
  356. <argument index="0" name="column" type="int" />
  357. <argument index="1" name="object" type="Object" />
  358. <argument index="2" name="callback" type="String" />
  359. <description>
  360. Sets the given column's custom draw callback to [code]callback[/code] method on [code]object[/code].
  361. The [code]callback[/code] should accept two arguments: the [TreeItem] that is drawn and its position and size as a [Rect2].
  362. </description>
  363. </method>
  364. <method name="set_editable">
  365. <return type="void" />
  366. <argument index="0" name="column" type="int" />
  367. <argument index="1" name="enabled" type="bool" />
  368. <description>
  369. If [code]true[/code], column [code]column[/code] is editable.
  370. </description>
  371. </method>
  372. <method name="set_expand_right">
  373. <return type="void" />
  374. <argument index="0" name="column" type="int" />
  375. <argument index="1" name="enable" type="bool" />
  376. <description>
  377. If [code]true[/code], column [code]column[/code] is expanded to the right.
  378. </description>
  379. </method>
  380. <method name="set_icon">
  381. <return type="void" />
  382. <argument index="0" name="column" type="int" />
  383. <argument index="1" name="texture" type="Texture" />
  384. <description>
  385. Sets the given column's icon [Texture].
  386. </description>
  387. </method>
  388. <method name="set_icon_max_width">
  389. <return type="void" />
  390. <argument index="0" name="column" type="int" />
  391. <argument index="1" name="width" type="int" />
  392. <description>
  393. Sets the given column's icon's maximum width.
  394. </description>
  395. </method>
  396. <method name="set_icon_modulate">
  397. <return type="void" />
  398. <argument index="0" name="column" type="int" />
  399. <argument index="1" name="modulate" type="Color" />
  400. <description>
  401. Modulates the given column's icon with [code]modulate[/code].
  402. </description>
  403. </method>
  404. <method name="set_icon_region">
  405. <return type="void" />
  406. <argument index="0" name="column" type="int" />
  407. <argument index="1" name="region" type="Rect2" />
  408. <description>
  409. Sets the given column's icon's texture region.
  410. </description>
  411. </method>
  412. <method name="set_metadata">
  413. <return type="void" />
  414. <argument index="0" name="column" type="int" />
  415. <argument index="1" name="meta" type="Variant" />
  416. <description>
  417. Sets the metadata value for the given column, which can be retrieved later using [method get_metadata]. This can be used, for example, to store a reference to the original data.
  418. </description>
  419. </method>
  420. <method name="set_range">
  421. <return type="void" />
  422. <argument index="0" name="column" type="int" />
  423. <argument index="1" name="value" type="float" />
  424. <description>
  425. Sets the value of a [constant CELL_MODE_RANGE] column.
  426. </description>
  427. </method>
  428. <method name="set_range_config">
  429. <return type="void" />
  430. <argument index="0" name="column" type="int" />
  431. <argument index="1" name="min" type="float" />
  432. <argument index="2" name="max" type="float" />
  433. <argument index="3" name="step" type="float" />
  434. <argument index="4" name="expr" type="bool" default="false" />
  435. <description>
  436. Sets the range of accepted values for a column. The column must be in the [constant CELL_MODE_RANGE] mode.
  437. If [code]expr[/code] is [code]true[/code], the edit mode slider will use an exponential scale as with [member Range.exp_edit].
  438. </description>
  439. </method>
  440. <method name="set_selectable">
  441. <return type="void" />
  442. <argument index="0" name="column" type="int" />
  443. <argument index="1" name="selectable" type="bool" />
  444. <description>
  445. If [code]true[/code], the given column is selectable.
  446. </description>
  447. </method>
  448. <method name="set_suffix">
  449. <return type="void" />
  450. <argument index="0" name="column" type="int" />
  451. <argument index="1" name="text" type="String" />
  452. <description>
  453. Sets a string to be shown after a column's value (for example, a unit abbreviation).
  454. </description>
  455. </method>
  456. <method name="set_text">
  457. <return type="void" />
  458. <argument index="0" name="column" type="int" />
  459. <argument index="1" name="text" type="String" />
  460. <description>
  461. Sets the given column's text value.
  462. </description>
  463. </method>
  464. <method name="set_text_align">
  465. <return type="void" />
  466. <argument index="0" name="column" type="int" />
  467. <argument index="1" name="text_align" type="int" enum="TreeItem.TextAlign" />
  468. <description>
  469. Sets the given column's text alignment. See [enum TextAlign] for possible values.
  470. </description>
  471. </method>
  472. <method name="set_tooltip">
  473. <return type="void" />
  474. <argument index="0" name="column" type="int" />
  475. <argument index="1" name="tooltip" type="String" />
  476. <description>
  477. Sets the given column's tooltip text.
  478. </description>
  479. </method>
  480. </methods>
  481. <members>
  482. <member name="collapsed" type="bool" setter="set_collapsed" getter="is_collapsed">
  483. If [code]true[/code], the TreeItem is collapsed.
  484. </member>
  485. <member name="custom_minimum_height" type="int" setter="set_custom_minimum_height" getter="get_custom_minimum_height">
  486. The custom minimum height.
  487. </member>
  488. <member name="disable_folding" type="bool" setter="set_disable_folding" getter="is_folding_disabled">
  489. If [code]true[/code], folding is disabled for this TreeItem.
  490. </member>
  491. </members>
  492. <constants>
  493. <constant name="CELL_MODE_STRING" value="0" enum="TreeCellMode">
  494. Cell contains a string.
  495. </constant>
  496. <constant name="CELL_MODE_CHECK" value="1" enum="TreeCellMode">
  497. Cell contains a checkbox.
  498. </constant>
  499. <constant name="CELL_MODE_RANGE" value="2" enum="TreeCellMode">
  500. Cell contains a range.
  501. </constant>
  502. <constant name="CELL_MODE_ICON" value="3" enum="TreeCellMode">
  503. Cell contains an icon.
  504. </constant>
  505. <constant name="CELL_MODE_CUSTOM" value="4" enum="TreeCellMode">
  506. </constant>
  507. <constant name="ALIGN_LEFT" value="0" enum="TextAlign">
  508. Align text to the left. See [code]set_text_align()[/code].
  509. </constant>
  510. <constant name="ALIGN_CENTER" value="1" enum="TextAlign">
  511. Center text. See [code]set_text_align()[/code].
  512. </constant>
  513. <constant name="ALIGN_RIGHT" value="2" enum="TextAlign">
  514. Align text to the right. See [code]set_text_align()[/code].
  515. </constant>
  516. </constants>
  517. </class>