dear_imgui_rs/widget/tree/
entry.rs1use crate::Id;
2use crate::sys;
3use crate::ui::Ui;
4
5use super::{TreeNode, TreeNodeFlags, TreeNodeId, TreeNodeToken};
6
7impl Ui {
9 pub fn tree_node<I, T>(&self, id: I) -> Option<TreeNodeToken<'_>>
16 where
17 I: Into<TreeNodeId<T>>,
18 T: AsRef<str>,
19 {
20 self.tree_node_config(id).push()
21 }
22
23 pub fn tree_node_config<I, T>(&self, id: I) -> TreeNode<'_, T>
29 where
30 I: Into<TreeNodeId<T>>,
31 T: AsRef<str>,
32 {
33 TreeNode::new(id.into(), self)
34 }
35
36 #[doc(alias = "CollapsingHeader")]
38 pub fn collapsing_header(&self, label: impl AsRef<str>, flags: TreeNodeFlags) -> bool {
39 let label_ptr = self.scratch_txt(label);
40 self.run_with_bound_context(|| unsafe {
41 sys::igCollapsingHeader_TreeNodeFlags(label_ptr, flags.bits())
42 })
43 }
44
45 #[doc(alias = "CollapsingHeader")]
51 pub fn collapsing_header_with_visible(
52 &self,
53 label: impl AsRef<str>,
54 visible: &mut bool,
55 flags: TreeNodeFlags,
56 ) -> bool {
57 let label_ptr = self.scratch_txt(label);
58 self.run_with_bound_context(|| unsafe {
59 sys::igCollapsingHeader_BoolPtr(label_ptr, visible as *mut bool, flags.bits())
60 })
61 }
62
63 #[doc(alias = "GetTreeNodeToLabelSpacing")]
65 pub fn tree_node_to_label_spacing(&self) -> f32 {
66 self.run_with_bound_context(|| unsafe { sys::igGetTreeNodeToLabelSpacing() })
67 }
68
69 #[doc(alias = "TreeNodeGetOpen")]
71 pub fn tree_node_get_open(&self, storage_id: Id) -> bool {
72 self.run_with_bound_context(|| unsafe { sys::igTreeNodeGetOpen(storage_id.raw()) })
73 }
74}