pub struct FileBrowser { /* private fields */ }Expand description
An explorer of folders and files: a breadcrumb that goes back, a header that sorts, and a
list of any length with icon, name, size and date. The entries are data from the app, which
answers on_navigate and on_open with another
folder; it never touches the file system, so it serves a backup on a server as well as a disk.
A click selects alone, Ctrl or Cmd adds, and Shift takes a range. The arrows, Home and End
move, Space adds, Enter opens, and Backspace goes up.
use ravenrs_widgets::{FileBrowser, FileEntry, Ui};
let browser = FileBrowser::new(
["Backups", "2026"],
vec![FileEntry::folder("October"), FileEntry::file("notes.txt", 2048)],
)
.on_open(|entry| println!("{}", entry.name))
.on_navigate(|depth| println!("{depth}"));
let mut ui = Ui::new(browser, ravenrs_style::Theme::raven_dark());
ui.update();Implementations§
Source§impl FileBrowser
impl FileBrowser
Sourcepub fn new(
path: impl IntoIterator<Item = impl Into<String>>,
entries: impl Into<Rc<[FileEntry]>>,
) -> FileBrowser
pub fn new( path: impl IntoIterator<Item = impl Into<String>>, entries: impl Into<Rc<[FileEntry]>>, ) -> FileBrowser
The folder at path, from the root, with entries inside it. Keep the entries in an
Rc between builds when they are many: they are sorted again only when they are not the
same ones.
Sourcepub fn selection(self, selection: Binding<BTreeSet<String>>) -> FileBrowser
pub fn selection(self, selection: Binding<BTreeSet<String>>) -> FileBrowser
The ids of the selected entries, to read and to change from outside.
Sourcepub fn sort(self, sort: Binding<FileSort>) -> FileBrowser
pub fn sort(self, sort: Binding<FileSort>) -> FileBrowser
The order, to keep or to set from outside.
Sourcepub fn mode(self, mode: SelectionMode) -> FileBrowser
pub fn mode(self, mode: SelectionMode) -> FileBrowser
How entries can be selected (SelectionMode::Multiple by default).
Called with the depth of the place to go back to, 0 being the root.
Sourcepub fn on_open(self, handler: impl Fn(&FileEntry) + 'static) -> FileBrowser
pub fn on_open(self, handler: impl Fn(&FileEntry) + 'static) -> FileBrowser
Called with an entry on a double click or on Enter.
Sourcepub fn height(self, height: f32) -> FileBrowser
pub fn height(self, height: f32) -> FileBrowser
A fixed height. It takes the height its parent gives it by default.
Trait Implementations§
Source§impl Debug for FileBrowser
impl Debug for FileBrowser
Auto Trait Implementations§
impl !RefUnwindSafe for FileBrowser
impl !Send for FileBrowser
impl !Sync for FileBrowser
impl !UnwindSafe for FileBrowser
impl Freeze for FileBrowser
impl Unpin for FileBrowser
impl UnsafeUnpin for FileBrowser
Blanket Implementations§
impl<T> AutoreleaseSafe for Twhere
T: ?Sized,
impl<T> AutoreleaseSafe for Twhere
T: ?Sized,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<T, U> ToSample<U> for Twhere
U: FromSample<T>,
impl<T, U> ToSample<U> for Twhere
U: FromSample<T>,
fn to_sample_(self) -> U
Source§impl<V> ViewExt for Vwhere
V: View,
impl<V> ViewExt for Vwhere
V: View,
Source§fn padding(self, padding: impl Into<Insets>) -> Styled<Self>
fn padding(self, padding: impl Into<Insets>) -> Styled<Self>
Source§fn background(self, fill: impl Into<Fill>) -> Styled<Self>
fn background(self, fill: impl Into<Fill>) -> Styled<Self>
Source§fn frame(self, width: Option<f32>, height: Option<f32>) -> Styled<Self>
fn frame(self, width: Option<f32>, height: Option<f32>) -> Styled<Self>
None keeps the content size.