use crate::Id;
use crate::sys;
use crate::ui::Ui;
use super::{TreeNode, TreeNodeFlags, TreeNodeId, TreeNodeToken};
impl Ui {
pub fn tree_node<I, T>(&self, id: I) -> Option<TreeNodeToken<'_>>
where
I: Into<TreeNodeId<T>>,
T: AsRef<str>,
{
self.tree_node_config(id).push()
}
pub fn tree_node_config<I, T>(&self, id: I) -> TreeNode<'_, T>
where
I: Into<TreeNodeId<T>>,
T: AsRef<str>,
{
TreeNode::new(id.into(), self)
}
#[doc(alias = "CollapsingHeader")]
pub fn collapsing_header(&self, label: impl AsRef<str>, flags: TreeNodeFlags) -> bool {
let label_ptr = self.scratch_txt(label);
unsafe { sys::igCollapsingHeader_TreeNodeFlags(label_ptr, flags.bits()) }
}
#[doc(alias = "CollapsingHeader")]
pub fn collapsing_header_with_visible(
&self,
label: impl AsRef<str>,
visible: &mut bool,
flags: TreeNodeFlags,
) -> bool {
let label_ptr = self.scratch_txt(label);
unsafe { sys::igCollapsingHeader_BoolPtr(label_ptr, visible as *mut bool, flags.bits()) }
}
#[doc(alias = "GetTreeNodeToLabelSpacing")]
pub fn tree_node_to_label_spacing(&self) -> f32 {
unsafe { sys::igGetTreeNodeToLabelSpacing() }
}
#[doc(alias = "TreeNodeGetOpen")]
pub fn tree_node_get_open(&self, storage_id: Id) -> bool {
unsafe { sys::igTreeNodeGetOpen(storage_id.raw()) }
}
}