Tree.xml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="Tree" inherits="Control" category="Core" version="3.0.alpha.custom_build">
  3. <brief_description>
  4. Control to show a tree of items.
  5. </brief_description>
  6. <description>
  7. 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 structured displays and interactions.
  8. Trees are built via code, using [TreeItem] objects to create the structure. They have a single root but multiple roots can be simulated if a dummy hidden root is added.
  9. [codeblock]
  10. func _ready():
  11. var tree = Tree.new()
  12. var root = tree.create_item()
  13. tree.set_hide_root(true)
  14. var child1 = tree.create_item(root)
  15. var child2 = tree.create_item(root)
  16. var subchild1 = tree.create_item(child1)
  17. subchild1.set_text(0, "Subchild1")
  18. [/codeblock]
  19. </description>
  20. <tutorials>
  21. </tutorials>
  22. <demos>
  23. </demos>
  24. <methods>
  25. <method name="are_column_titles_visible" qualifiers="const">
  26. <return type="bool">
  27. </return>
  28. <description>
  29. Returns [code]true[/code] if the column titles are being shown.
  30. </description>
  31. </method>
  32. <method name="clear">
  33. <return type="void">
  34. </return>
  35. <description>
  36. Clears the tree. This removes all items.
  37. </description>
  38. </method>
  39. <method name="create_item">
  40. <return type="Object">
  41. </return>
  42. <argument index="0" name="parent" type="Object" default="null">
  43. </argument>
  44. <description>
  45. Create an item in the tree and add it as the last child of [code]parent[/code]. If parent is not given, it will be added as the root's last child, or it'll the be the root itself if the tree is empty.
  46. </description>
  47. </method>
  48. <method name="ensure_cursor_is_visible">
  49. <return type="void">
  50. </return>
  51. <description>
  52. Makes the currently selected item visible. This will scroll the tree to make sure the selected item is visible.
  53. </description>
  54. </method>
  55. <method name="get_allow_reselect" qualifiers="const">
  56. <return type="bool">
  57. </return>
  58. <description>
  59. Returns [code]true[/code] if a cell that is currently already selected may be selected again.
  60. </description>
  61. </method>
  62. <method name="get_allow_rmb_select" qualifiers="const">
  63. <return type="bool">
  64. </return>
  65. <description>
  66. Returns [code]true[/code] if a right click can select items.
  67. </description>
  68. </method>
  69. <method name="get_column_at_position" qualifiers="const">
  70. <return type="int">
  71. </return>
  72. <argument index="0" name="position" type="Vector2">
  73. </argument>
  74. <description>
  75. Returns the column index under the given point.
  76. </description>
  77. </method>
  78. <method name="get_column_title" qualifiers="const">
  79. <return type="String">
  80. </return>
  81. <argument index="0" name="column" type="int">
  82. </argument>
  83. <description>
  84. Returns the column's title.
  85. </description>
  86. </method>
  87. <method name="get_column_width" qualifiers="const">
  88. <return type="int">
  89. </return>
  90. <argument index="0" name="column" type="int">
  91. </argument>
  92. <description>
  93. Returns the column's width in pixels.
  94. </description>
  95. </method>
  96. <method name="get_columns" qualifiers="const">
  97. <return type="int">
  98. </return>
  99. <description>
  100. Returns the amount of columns.
  101. </description>
  102. </method>
  103. <method name="get_custom_popup_rect" qualifiers="const">
  104. <return type="Rect2">
  105. </return>
  106. <description>
  107. Returns the rectangle for custom popups. Helper to create custom cell controls that display a popup. See [method TreeItem.set_cell_mode].
  108. </description>
  109. </method>
  110. <method name="get_drop_mode_flags" qualifiers="const">
  111. <return type="int">
  112. </return>
  113. <description>
  114. Returns the current drop mode's flags.
  115. </description>
  116. </method>
  117. <method name="get_drop_section_at_position" qualifiers="const">
  118. <return type="int">
  119. </return>
  120. <argument index="0" name="position" type="Vector2">
  121. </argument>
  122. <description>
  123. </description>
  124. </method>
  125. <method name="get_edited" qualifiers="const">
  126. <return type="TreeItem">
  127. </return>
  128. <description>
  129. Returns the currently edited item. This is only available for custom cell mode.
  130. </description>
  131. </method>
  132. <method name="get_edited_column" qualifiers="const">
  133. <return type="int">
  134. </return>
  135. <description>
  136. Returns the column for the currently edited item. This is only available for custom cell mode.
  137. </description>
  138. </method>
  139. <method name="get_item_area_rect" qualifiers="const">
  140. <return type="Rect2">
  141. </return>
  142. <argument index="0" name="item" type="Object">
  143. </argument>
  144. <argument index="1" name="column" type="int" default="-1">
  145. </argument>
  146. <description>
  147. Returns the rectangle area for the specified item. If column is specified, only get the position and size of that column, otherwise get the rectangle containing all columns.
  148. </description>
  149. </method>
  150. <method name="get_item_at_position" qualifiers="const">
  151. <return type="TreeItem">
  152. </return>
  153. <argument index="0" name="position" type="Vector2">
  154. </argument>
  155. <description>
  156. Returns the tree item at the specified position (relative to the tree origin position).
  157. </description>
  158. </method>
  159. <method name="get_next_selected">
  160. <return type="TreeItem">
  161. </return>
  162. <argument index="0" name="from" type="Object">
  163. </argument>
  164. <description>
  165. Returns the next selected item after the given one.
  166. </description>
  167. </method>
  168. <method name="get_pressed_button" qualifiers="const">
  169. <return type="int">
  170. </return>
  171. <description>
  172. Returns the last pressed button's index.
  173. </description>
  174. </method>
  175. <method name="get_root">
  176. <return type="TreeItem">
  177. </return>
  178. <description>
  179. Returns the tree's root item.
  180. </description>
  181. </method>
  182. <method name="get_scroll" qualifiers="const">
  183. <return type="Vector2">
  184. </return>
  185. <description>
  186. Returns the current scrolling position.
  187. </description>
  188. </method>
  189. <method name="get_selected" qualifiers="const">
  190. <return type="TreeItem">
  191. </return>
  192. <description>
  193. Returns the currently selected item.
  194. </description>
  195. </method>
  196. <method name="get_selected_column" qualifiers="const">
  197. <return type="int">
  198. </return>
  199. <description>
  200. Returns the current selection's column.
  201. </description>
  202. </method>
  203. <method name="is_folding_hidden" qualifiers="const">
  204. <return type="bool">
  205. </return>
  206. <description>
  207. Returns [code]true[/code] if the folding arrow is hidden.
  208. </description>
  209. </method>
  210. <method name="set_allow_reselect">
  211. <return type="void">
  212. </return>
  213. <argument index="0" name="allow" type="bool">
  214. </argument>
  215. <description>
  216. If [code]true[/code] the currently selected cell may be selected again.
  217. </description>
  218. </method>
  219. <method name="set_allow_rmb_select">
  220. <return type="void">
  221. </return>
  222. <argument index="0" name="allow" type="bool">
  223. </argument>
  224. <description>
  225. If [code]true[/code] a right mouse button click can select items.
  226. </description>
  227. </method>
  228. <method name="set_column_expand">
  229. <return type="void">
  230. </return>
  231. <argument index="0" name="column" type="int">
  232. </argument>
  233. <argument index="1" name="expand" type="bool">
  234. </argument>
  235. <description>
  236. If [code]true[/code] the column will have the "Expand" flag of [Control].
  237. </description>
  238. </method>
  239. <method name="set_column_min_width">
  240. <return type="void">
  241. </return>
  242. <argument index="0" name="column" type="int">
  243. </argument>
  244. <argument index="1" name="min_width" type="int">
  245. </argument>
  246. <description>
  247. Set the minimum width of a column.
  248. </description>
  249. </method>
  250. <method name="set_column_title">
  251. <return type="void">
  252. </return>
  253. <argument index="0" name="column" type="int">
  254. </argument>
  255. <argument index="1" name="title" type="String">
  256. </argument>
  257. <description>
  258. Set the title of a column.
  259. </description>
  260. </method>
  261. <method name="set_column_titles_visible">
  262. <return type="void">
  263. </return>
  264. <argument index="0" name="visible" type="bool">
  265. </argument>
  266. <description>
  267. If [code]true[/code] column titles are visible.
  268. </description>
  269. </method>
  270. <method name="set_columns">
  271. <return type="void">
  272. </return>
  273. <argument index="0" name="amount" type="int">
  274. </argument>
  275. <description>
  276. Set the amount of columns.
  277. </description>
  278. </method>
  279. <method name="set_drop_mode_flags">
  280. <return type="void">
  281. </return>
  282. <argument index="0" name="flags" type="int">
  283. </argument>
  284. <description>
  285. Set the drop mode as an OR combination of flags. See [code]DROP_MODE_*[/code] constants.
  286. </description>
  287. </method>
  288. <method name="set_hide_folding">
  289. <return type="void">
  290. </return>
  291. <argument index="0" name="hide" type="bool">
  292. </argument>
  293. <description>
  294. If [code]true[/code] the folding arrow is hidden.
  295. </description>
  296. </method>
  297. <method name="set_hide_root">
  298. <return type="void">
  299. </return>
  300. <argument index="0" name="enable" type="bool">
  301. </argument>
  302. <description>
  303. If [code]true[/code] the tree's root is hidden.
  304. </description>
  305. </method>
  306. <method name="set_select_mode">
  307. <return type="void">
  308. </return>
  309. <argument index="0" name="mode" type="int" enum="Tree.SelectMode">
  310. </argument>
  311. <description>
  312. Allow single or multiple selection. See the [code]SELECT_*[/code] constants.
  313. </description>
  314. </method>
  315. </methods>
  316. <signals>
  317. <signal name="button_pressed">
  318. <argument index="0" name="item" type="Object">
  319. </argument>
  320. <argument index="1" name="column" type="int">
  321. </argument>
  322. <argument index="2" name="id" type="int">
  323. </argument>
  324. <description>
  325. Emitted when a button on the tree was pressed (see [method TreeItem.add_button]).
  326. </description>
  327. </signal>
  328. <signal name="cell_selected">
  329. <description>
  330. Emitted when a cell is selected.
  331. </description>
  332. </signal>
  333. <signal name="column_title_pressed">
  334. <argument index="0" name="column" type="int">
  335. </argument>
  336. <description>
  337. Emitted when a column's title is pressed.
  338. </description>
  339. </signal>
  340. <signal name="custom_popup_edited">
  341. <argument index="0" name="arrow_clicked" type="bool">
  342. </argument>
  343. <description>
  344. Emitted when a cell with the [code]CELL_MODE_CUSTOM[/code] is clicked to be edited.
  345. </description>
  346. </signal>
  347. <signal name="empty_tree_rmb_selected">
  348. <argument index="0" name="position" type="Vector2">
  349. </argument>
  350. <description>
  351. Emitted when the right mouse button is pressed if RMB selection is active and the tree is empty.
  352. </description>
  353. </signal>
  354. <signal name="item_activated">
  355. <description>
  356. Emitted when an item is activated (double-clicked).
  357. </description>
  358. </signal>
  359. <signal name="item_collapsed">
  360. <argument index="0" name="item" type="Object">
  361. </argument>
  362. <description>
  363. Emitted when an item is collapsed by a click on the folding arrow.
  364. </description>
  365. </signal>
  366. <signal name="item_custom_button_pressed">
  367. <description>
  368. </description>
  369. </signal>
  370. <signal name="item_double_clicked">
  371. <description>
  372. Emitted when an item is double clicked.
  373. </description>
  374. </signal>
  375. <signal name="item_edited">
  376. <description>
  377. Emitted when an item is edited.
  378. </description>
  379. </signal>
  380. <signal name="item_rmb_edited">
  381. <description>
  382. Emitted when an item is edited using the right mouse button.
  383. </description>
  384. </signal>
  385. <signal name="item_rmb_selected">
  386. <argument index="0" name="position" type="Vector2">
  387. </argument>
  388. <description>
  389. Emitted when an item is selected with right mouse button.
  390. </description>
  391. </signal>
  392. <signal name="item_selected">
  393. <description>
  394. Emitted when an item is selected with right mouse button.
  395. </description>
  396. </signal>
  397. <signal name="multi_selected">
  398. <argument index="0" name="item" type="Object">
  399. </argument>
  400. <argument index="1" name="column" type="int">
  401. </argument>
  402. <argument index="2" name="selected" type="bool">
  403. </argument>
  404. <description>
  405. Emitted instead of [code]item_selected[/code] when [code]select_mode[/code] is [code]SELECT_MULTI[/code].
  406. </description>
  407. </signal>
  408. </signals>
  409. <constants>
  410. <constant name="SELECT_SINGLE" value="0">
  411. Allow selection of a single item at a time.
  412. </constant>
  413. <constant name="SELECT_ROW" value="1">
  414. </constant>
  415. <constant name="SELECT_MULTI" value="2">
  416. Allow selection of multiple items at the same time.
  417. </constant>
  418. <constant name="DROP_MODE_DISABLED" value="0">
  419. </constant>
  420. <constant name="DROP_MODE_ON_ITEM" value="1">
  421. </constant>
  422. <constant name="DROP_MODE_INBETWEEN" value="2">
  423. </constant>
  424. </constants>
  425. <theme_items>
  426. <theme_item name="arrow" type="Texture">
  427. </theme_item>
  428. <theme_item name="arrow_collapsed" type="Texture">
  429. </theme_item>
  430. <theme_item name="bg" type="StyleBox">
  431. </theme_item>
  432. <theme_item name="bg_focus" type="StyleBox">
  433. </theme_item>
  434. <theme_item name="button_margin" type="int">
  435. </theme_item>
  436. <theme_item name="button_pressed" type="StyleBox">
  437. </theme_item>
  438. <theme_item name="checked" type="Texture">
  439. </theme_item>
  440. <theme_item name="cursor" type="StyleBox">
  441. </theme_item>
  442. <theme_item name="cursor_color" type="Color">
  443. </theme_item>
  444. <theme_item name="cursor_unfocused" type="StyleBox">
  445. </theme_item>
  446. <theme_item name="custom_button" type="StyleBox">
  447. </theme_item>
  448. <theme_item name="custom_button_font_highlight" type="Color">
  449. </theme_item>
  450. <theme_item name="custom_button_hover" type="StyleBox">
  451. </theme_item>
  452. <theme_item name="custom_button_pressed" type="StyleBox">
  453. </theme_item>
  454. <theme_item name="draw_relationship_lines" type="int">
  455. </theme_item>
  456. <theme_item name="drop_position_color" type="Color">
  457. </theme_item>
  458. <theme_item name="font" type="Font">
  459. </theme_item>
  460. <theme_item name="font_color" type="Color">
  461. </theme_item>
  462. <theme_item name="font_color_selected" type="Color">
  463. </theme_item>
  464. <theme_item name="guide_color" type="Color">
  465. </theme_item>
  466. <theme_item name="guide_width" type="int">
  467. </theme_item>
  468. <theme_item name="hseparation" type="int">
  469. </theme_item>
  470. <theme_item name="item_margin" type="int">
  471. </theme_item>
  472. <theme_item name="relationship_line_color" type="Color">
  473. </theme_item>
  474. <theme_item name="scroll_border" type="int">
  475. </theme_item>
  476. <theme_item name="scroll_speed" type="int">
  477. </theme_item>
  478. <theme_item name="select_arrow" type="Texture">
  479. </theme_item>
  480. <theme_item name="selected" type="StyleBox">
  481. </theme_item>
  482. <theme_item name="selected_focus" type="StyleBox">
  483. </theme_item>
  484. <theme_item name="selection_color" type="Color">
  485. </theme_item>
  486. <theme_item name="title_button_color" type="Color">
  487. </theme_item>
  488. <theme_item name="title_button_font" type="Font">
  489. </theme_item>
  490. <theme_item name="title_button_hover" type="StyleBox">
  491. </theme_item>
  492. <theme_item name="title_button_normal" type="StyleBox">
  493. </theme_item>
  494. <theme_item name="title_button_pressed" type="StyleBox">
  495. </theme_item>
  496. <theme_item name="unchecked" type="Texture">
  497. </theme_item>
  498. <theme_item name="updown" type="Texture">
  499. </theme_item>
  500. <theme_item name="vseparation" type="int">
  501. </theme_item>
  502. </theme_items>
  503. </class>