TreeItem.xml 20 KB

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