/// Shows the library in a given `Ui`, starting from a given path.
Shows the library in a given `Ui`, starting from a given path.
Shows the library in a given ` Ui ` starting from a given path .
pub fn show(&mut self, ui: &mut Ui, path: PathBuf) -> ShowResult {
        match self {
            // Shows a collapsing drop-down, and loads the folder in case it's clicked.
            Self::UnloadedFolder { name, .. } => {
                *self = Self::LoadedFolder {
                    name: name.clone(),
                    contents: Self::folder_contents(&path).unwrap(),
                };
                self.show(ui, path)
            }
            // Shows a drop-down with all of the files and folders.
            Self::LoadedFolder { name, contents, .. } => ui
                .collapsing(name.clone(), |ui| {
                    let mut res = ShowResult::None;
                    for lib in contents.iter_mut() {
                        let mut new_path = path.clone();
                        new_path.push(lib.path_name());
                        res |= lib.show(ui, new_path);
                    }
                    res
                })
                .body_returned
                .unwrap_or_default(),
            // Shows a button that loads the file if clicked.
            Self::File { name, .. } => {
                let label = PathBuf::from(name as &_)
                    .file_stem()
                    .unwrap()
                    .to_string_lossy()
                    .into_owned();
                if ui.button(label).clicked() {
                    ShowResult::Load(path.into_os_string())
                } else {
                    ShowResult::None
                }
            }
            // Shows any of the special files.
            Self::Special(special) => special.show(ui),
        }
    }
pub fn show ( & mut self , ui : & mut Ui , path : PathBuf ) -> ShowResult { match self { // Shows a collapsing drop-down, and loads the folder in case it's clicked. Self :: UnloadedFolder { name , .. } => { * self = Self :: LoadedFolder { name : name . clone ( ) , contents : Self :: folder_contents ( & path ) . unwrap ( ) , } ; self . show ( ui , path ) } // Shows a drop-down with all of the files and folders. Self :: LoadedFolder { name , contents , .. } => ui . collapsing ( name . clone ( ) , | ui | { let mut res = ShowResult :: None ; for lib in contents . iter_mut ( ) { let mut new_path = path . clone ( ) ; new_path . push ( lib . path_name ( ) ) ; res |= lib . show ( ui , new_path ) ; } res } ) . body_returned . unwrap_or_default ( ) , // Shows a button that loads the file if clicked. Self :: File { name , .. } => { let label = PathBuf :: from ( name as & _ ) . file_stem ( ) . unwrap ( ) . to_string_lossy ( ) . into_owned ( ) ; if ui . button ( label ) . clicked ( ) { ShowResult :: Load ( path . into_os_string ( ) ) } else { ShowResult :: None } } // Shows any of the special files. Self :: Special ( special ) => special . show ( ui ) , } }
Shows the library in a given `Ui`, starting from a given path.
Shows the library in a given ` Ui ` starting from a given path .
&mut self
ui
&mut Ui
path
PathBuf