TreeItem.xml 20 KB

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