pub struct FileBrowser { /* private fields */ }Expand description
The file browser: entries from a FileSource, shown by a
ViewMode chosen in its toolbar (or with Ctrl+1 to Ctrl+9), kept
per dialog in the host’s store when drawn with FileBrowser::show_in.
Need (dialog): a file or folder picker.
Implementations§
Source§impl FileBrowser
impl FileBrowser
Sourcepub const TYPE_AHEAD_RESET: f64 = 1.0
pub const TYPE_AHEAD_RESET: f64 = 1.0
How long type-ahead’s prefix lasts after the last key, in seconds.
Sourcepub fn new(
id: impl Hash + Debug,
source: Arc<dyn FileSource>,
place: impl Into<PathBuf>,
) -> Self
pub fn new( id: impl Hash + Debug, source: Arc<dyn FileSource>, place: impl Into<PathBuf>, ) -> Self
A browser of place, keyed by id (its mode is remembered under it),
in the first mode of the default registry.
pub fn with_modes(self, modes: ViewModes) -> Self
pub fn with_thumbnails(self, provider: Arc<dyn ThumbnailProvider>) -> Self
pub fn with_select(self, select: SelectMode) -> Self
Sourcepub fn with_selection_policy(self, policy: SelectionPolicy) -> Self
pub fn with_selection_policy(self, policy: SelectionPolicy) -> Self
Lets the person select what policy says, from the start.
Sourcepub fn set_selection_policy(&mut self, policy: SelectionPolicy)
pub fn set_selection_policy(&mut self, policy: SelectionPolicy)
What can be selected: which kind of entry, one or several. What the selection holds against it leaves it (the first entry kept, for one).
Sourcepub fn selection_policy(&self) -> SelectionPolicy
pub fn selection_policy(&self) -> SelectionPolicy
What can be selected.
Sourcepub fn with_filter(self, filter: EntryFilter) -> Self
pub fn with_filter(self, filter: EntryFilter) -> Self
Shows only the entries filter passes, from the start.
Sourcepub fn set_filter(&mut self, filter: EntryFilter)
pub fn set_filter(&mut self, filter: EntryFilter)
Shows only the entries filter passes (by extension, by kind): the
others leave FileBrowser::entries, the selection and the focus,
and come back when the filter lets them.
pub fn filter(&self) -> &EntryFilter
Sourcepub fn set_query(&mut self, query: &str)
pub fn set_query(&mut self, query: &str)
Shows only the entries a fuzzy query matches (a group by its members’ names too), best first, equals in the browser’s order; the focus goes to the best. An empty query shows them all again, in that order.
Sourcepub fn with_marks(
self,
marks: impl Fn(&SourceEntry) -> EntryMarks + Send + Sync + 'static,
) -> Self
pub fn with_marks( self, marks: impl Fn(&SourceEntry) -> EntryMarks + Send + Sync + 'static, ) -> Self
Marks entries as the application sees them: badges on their cells
and after their names, said to assistive technology with the name,
and dimmed entries (a photo already imported). Every mode that
draws through the browser’s PlainDrawer shows them.
Sourcepub fn with_sort(self, sort: PickerSort) -> Self
pub fn with_sort(self, sort: PickerSort) -> Self
Sorts the entries by sort from the start: by name upwards unless
told otherwise.
Sourcepub fn with_folders_first(self, on: bool) -> Self
pub fn with_folders_first(self, on: bool) -> Self
Whether folders come before files whatever the order (they do unless told otherwise).
Sourcepub fn set_sort(&mut self, sort: PickerSort)
pub fn set_sort(&mut self, sort: PickerSort)
The entries’ order: by name, when they last changed, when they were
taken (SourceEntry::taken, else when they last changed), size or
type, up or down. What has no value in that order goes last either
way, and names settle ties. The toolbar’s sort menu sets it too, in
every mode that does not order by time on its own (an agenda). The
selection and the focus stay on their entries, and the focus is
brought into view.
pub fn sort(&self) -> PickerSort
Sourcepub fn set_folders_first(&mut self, on: bool)
pub fn set_folders_first(&mut self, on: bool)
Folders before files in every order, or among them.
pub fn folders_first(&self) -> bool
Sourcepub fn with_grouping(self, groupings: Groupings) -> Self
pub fn with_grouping(self, groupings: Groupings) -> Self
Files that go together are one entry, by these groupings
(super::groups; an application’s Files::groupings):
a RAW with its sidecars and its JPEG shows as the RAW, its members’
badges on it (+XMP +JPEG), named for screen readers (“Grouped with
…”), and showing its first member’s thumbnail when it has none of its
own. The members leave FileBrowser::entries; the group of an entry
is FileBrowser::group_of. The groups are found as the listing’s
pages come, a large place’s off the interface thread. egui-pop declares
no grouping: what goes together is the application’s rule.
Sourcepub fn set_grouped(&mut self, on: bool)
pub fn set_grouped(&mut self, on: bool)
Groups files, with groupings declared, or lets each be an entry of its own (they are grouped unless told otherwise). The toolbar’s sort menu turns it too. A member selected or focused leaves it for its group’s entry.
pub fn grouped(&self) -> bool
Sourcepub fn group_of(&self, path: &Path) -> Option<&FileGroup>
pub fn group_of(&self, path: &Path) -> Option<&FileGroup>
The group an entry heads, as last found.
Sourcepub fn groups_pending(&self) -> bool
pub fn groups_pending(&self) -> bool
Whether the groups of what was listed are still being looked for.
Sourcepub fn set_selection(&mut self, paths: impl IntoIterator<Item = PathBuf>)
pub fn set_selection(&mut self, paths: impl IntoIterator<Item = PathBuf>)
Selects these entries alone (the first of them with
SelectMode::One); the paths not listed are dropped, the focus
stays. An application’s own “select all of that day”.
pub fn id(&self) -> Id
Sourcepub fn with_root(self, root: impl Into<PathBuf>) -> Self
pub fn with_root(self, root: impl Into<PathBuf>) -> Self
The topmost folder a mode that shows the path goes up to (and Left goes back to); the file system’s root when not set.
Sourcepub fn ancestors(&self) -> &[Column]
pub fn ancestors(&self) -> &[Column]
The ancestors’ listings, the topmost first, as a mode that shows the path is given them (kept only while such a mode is shown).
Sourcepub fn peek(&self) -> Option<&Column>
pub fn peek(&self) -> Option<&Column>
The focused folder’s listing, as a mode that shows the path is given it.
Sourcepub fn with_drops(
self,
accept: impl Fn(&DropOffer) -> bool + Send + Sync + 'static,
) -> Self
pub fn with_drops( self, accept: impl Fn(&DropOffer) -> bool + Send + Sync + 'static, ) -> Self
Takes drops: files and folders dragged from inside the application
(a DraggedPaths payload of egui::DragAndDrop) or from the system
(egui’s hovered and dropped files, where the platform gives them). A
drop goes to a folder entry under the pointer, else to the folder
shown, else to one of the application’s own targets
(FileBrowser::with_drop_targets); accept says whether that
target takes it, shown while hovering, and an accepted drop comes
out as BrowserOutput::dropped. A folder never takes itself or a
folder it holds.
Sourcepub fn with_drop_targets(self, targets: Vec<AppDropTarget>) -> Self
pub fn with_drop_targets(self, targets: Vec<AppDropTarget>) -> Self
The application’s own drop targets, drawn as zones under the
toolbar (an import’s “Add to the catalogue”); taken only with
FileBrowser::with_drops.
Sourcepub fn drop_hover(&self) -> Option<&(DropOffer, bool)>
pub fn drop_hover(&self) -> Option<&(DropOffer, bool)>
What a drag over the browser would do, as last drawn: the offer and
whether its target takes it. None when nothing is dragged over it.
Sourcepub fn travel(&mut self, travel: Travel) -> bool
pub fn travel(&mut self, travel: Travel) -> bool
Leaves the place as a mode’s key asks: into the focused folder, or
back to the parent. true when the place changed.
Sourcepub fn reach(&mut self, reach: &Reach)
pub fn reach(&mut self, reach: &Reach)
Shows another place, an entry of it focused (and selected, as a click selects it).
Sourcepub fn quick_look(&self) -> bool
pub fn quick_look(&self) -> bool
Whether quick look is open.
Sourcepub fn set_quick_look(&mut self, open: bool)
pub fn set_quick_look(&mut self, open: bool)
Opens or closes quick look, a large view of the focused entry over
the entries (Ctrl+Y, or Space while an entry has the focus);
nothing opens without a focused entry.
pub fn place(&self) -> &Path
Sourcepub fn open(&mut self, place: impl Into<PathBuf>)
pub fn open(&mut self, place: impl Into<PathBuf>)
Shows another place; the selection and the focus are left behind.
Lists hidden entries too (a name starting with .), or leaves them
out (the default); the place is listed again when it changes.
Whether hidden entries are listed.
pub fn error(&self) -> Option<&SourceError>
Sourcepub fn filtered_out_count(&self) -> usize
pub fn filtered_out_count(&self) -> usize
How many entries listed the filter or the query hide: an empty view with some is “no results”, without any an empty place.
Sourcepub fn entries(&self) -> &[SourceEntry]
pub fn entries(&self) -> &[SourceEntry]
The entries shown, in order: a group’s members are not among them
(FileBrowser::group_of).
pub fn selection(&self) -> &Selection
pub fn focus(&self) -> Option<&Path>
Sourcepub fn set_focus(&mut self, path: Option<&Path>)
pub fn set_focus(&mut self, path: Option<&Path>)
Focuses an entry, by path, or nothing; the selection stays. A path not listed leaves the focus as it is.
pub fn mode(&self) -> &str
Sourcepub fn set_mode(&mut self, id: &str) -> bool
pub fn set_mode(&mut self, id: &str) -> bool
Shows the entries in another mode, keeping the selection and the
focus; false when no such mode is registered.
Sourcepub fn set_thumbnail_size(&mut self, side: f32)
pub fn set_thumbnail_size(&mut self, side: f32)
A size of thumbnails in points (an older setting’s): the next draw
turns it into the count per row it gives there (ThumbZoom).
Sourcepub fn zoom(&self) -> ThumbZoom
pub fn zoom(&self) -> ThumbZoom
The thumbnails’ zoom: how many fill a row, or under
GridResize::FixedSize their size in points once drawn. What
an application keeps to show the grid as the person left it.
Sourcepub fn with_resize(self, resize: GridResize) -> Self
pub fn with_resize(self, resize: GridResize) -> Self
What the zoom means when the grid is resized
(GridResize::PerRow by default): a count per row, or a size
that keeps the thumbnails’ size and adds columns.
Sourcepub fn set_resize(&mut self, resize: GridResize)
pub fn set_resize(&mut self, resize: GridResize)
FileBrowser::with_resize on a browser already made.
Sourcepub fn resize(&self) -> GridResize
pub fn resize(&self) -> GridResize
What the zoom means when the grid is resized.
Sourcepub fn set_thumbnails_per_row(&mut self, per_row: u32)
pub fn set_thumbnails_per_row(&mut self, per_row: u32)
This many thumbnails per row (one: a thumbnail across).
Sourcepub fn focus_on(&mut self, path: &Path, extend: bool)
pub fn focus_on(&mut self, path: &Path, extend: bool)
Focuses an entry, by path; with extend, selects the range from the
anchor (several only).
Sourcepub fn click(&mut self, path: &Path, modifiers: Modifiers)
pub fn click(&mut self, path: &Path, modifiers: Modifiers)
What a click does: selects that entry alone, or with Ctrl adds or takes it away, or with Shift selects the range.
Sourcepub fn key(&mut self, key: ModeKey, shift: bool) -> bool
pub fn key(&mut self, key: ModeKey, shift: bool) -> bool
Moves the focus by a key, as the mode’s layout says.
Sourcepub fn select_all(&mut self)
pub fn select_all(&mut self)
Selects every entry shown the policy accepts (several only); with
SelectionPolicy::keeps_filtered, those set aside stay selected.
Sourcepub fn type_ahead(&mut self, text: &str, now: f64) -> bool
pub fn type_ahead(&mut self, text: &str, now: f64) -> bool
Type-ahead: text typed at now (seconds). The focus goes to the
first entry whose name starts with the prefix; one letter typed
again goes round the entries that start with it.
Sourcepub fn mode_infos(&self) -> Vec<ModeInfo>
pub fn mode_infos(&self) -> Vec<ModeInfo>
What each of its modes is, in the switcher’s order.
Sourcepub fn set_mode_index(&mut self, n: usize) -> bool
pub fn set_mode_index(&mut self, n: usize) -> bool
Shows the n-th mode (from 1, in the switcher’s order), as
Ctrl+n does; false when there is none or it is shown already.
Sourcepub fn show_in(
&mut self,
ui: &mut Ui,
app: &AppHandle,
dialog: &str,
) -> BrowserOutput
pub fn show_in( &mut self, ui: &mut Ui, app: &AppHandle, dialog: &str, ) -> BrowserOutput
Draws it as FileBrowser::show, its mode kept in the host’s store
under dialog (the last used for that dialog: a request’s purpose,
a window’s name), read when it is first drawn.
Sourcepub fn show(&mut self, ui: &mut Ui) -> BrowserOutput
pub fn show(&mut self, ui: &mut Ui) -> BrowserOutput
Draws the toolbar’s mode switcher and the entries.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FileBrowser
impl !RefUnwindSafe for FileBrowser
impl Send for FileBrowser
impl !Sync for FileBrowser
impl Unpin for FileBrowser
impl UnsafeUnpin for FileBrowser
impl !UnwindSafe for FileBrowser
Blanket Implementations§
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<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’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>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more