1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
use crate::{
    widgets::{NcTreeItem, NcTreeItemCbUnsafe, NcTreeOptions},
    NcDim,
};

#[allow(unused_imports)]
use crate::widgets::NcTree;

/// # `NcTreeOptions` constructors
impl NcTreeOptions {
    /// New NcTreeOptions for [`NcTree`].
    pub fn new(items: &[NcTreeItem], indentcols: NcDim) -> Self {
        Self::with_all_args(items, items.len(), None, indentcols, 0)
    }

    /// New NcTreeOptions for [`NcTree`], with all args.
    pub fn with_all_args(
        // top-level nctree_item array
        items: &[NcTreeItem],

        // size of |items|
        count: usize,

        // item callback function
        // TODO: use NcTreeItemCb and convert to NcTreeItemCbUnsafe
        nctreecb: Option<NcTreeItemCbUnsafe>,

        // columns to indent per level of hierarchy
        indentcols: NcDim,

        // bitfield of `NCTREE_OPTION_*` (there's none for now)
        flags: u64,
    ) -> Self {
        Self {
            items: items as *const _ as *const NcTreeItem,
            count: count as u32,
            nctreecb,
            indentcols: indentcols as i32,
            flags,
        }
    }
}