dear_imgui_rs/widget/tree/token.rs
1use crate::sys;
2use crate::ui::Ui;
3
4/// Tracks a tree node that can be popped by calling `.pop()` or by dropping
5#[must_use]
6pub struct TreeNodeToken<'ui> {
7 _ui: &'ui Ui,
8}
9
10impl<'ui> TreeNodeToken<'ui> {
11 /// Creates a new tree node token
12 pub(super) fn new(ui: &'ui Ui) -> Self {
13 TreeNodeToken { _ui: ui }
14 }
15
16 /// Pops the tree node
17 pub fn pop(self) {
18 // The drop implementation will handle the actual popping
19 }
20}
21
22impl Drop for TreeNodeToken<'_> {
23 fn drop(&mut self) {
24 self._ui
25 .run_with_bound_context(|| unsafe { sys::igTreePop() });
26 }
27}