Skip to main content

FileBrowser

Struct FileBrowser 

Source
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

Source

pub const TYPE_AHEAD_RESET: f64 = 1.0

How long type-ahead’s prefix lasts after the last key, in seconds.

Source

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.

Source

pub fn with_modes(self, modes: ViewModes) -> Self

Source

pub fn with_thumbnails(self, provider: Arc<dyn ThumbnailProvider>) -> Self

Source

pub fn with_select(self, select: SelectMode) -> Self

Source

pub fn with_selection_policy(self, policy: SelectionPolicy) -> Self

Lets the person select what policy says, from the start.

Source

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).

Source

pub fn selection_policy(&self) -> SelectionPolicy

What can be selected.

Source

pub fn with_filter(self, filter: EntryFilter) -> Self

Shows only the entries filter passes, from the start.

Source

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.

Source

pub fn filter(&self) -> &EntryFilter

Source

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.

Source

pub fn query(&self) -> &str

The fuzzy query the entries shown match.

Source

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.

Source

pub fn with_sort(self, sort: PickerSort) -> Self

Sorts the entries by sort from the start: by name upwards unless told otherwise.

Source

pub fn with_folders_first(self, on: bool) -> Self

Whether folders come before files whatever the order (they do unless told otherwise).

Source

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.

Source

pub fn sort(&self) -> PickerSort

Source

pub fn set_folders_first(&mut self, on: bool)

Folders before files in every order, or among them.

Source

pub fn folders_first(&self) -> bool

Source

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.

Source

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.

Source

pub fn grouped(&self) -> bool

Source

pub fn group_of(&self, path: &Path) -> Option<&FileGroup>

The group an entry heads, as last found.

Source

pub fn groups_pending(&self) -> bool

Whether the groups of what was listed are still being looked for.

Source

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”.

Source

pub fn id(&self) -> Id

Source

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.

Source

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).

Source

pub fn peek(&self) -> Option<&Column>

The focused folder’s listing, as a mode that shows the path is given it.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn reach(&mut self, reach: &Reach)

Shows another place, an entry of it focused (and selected, as a click selects it).

Source

pub fn quick_look(&self) -> bool

Whether quick look is open.

Source

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.

Source

pub fn place(&self) -> &Path

Source

pub fn open(&mut self, place: impl Into<PathBuf>)

Shows another place; the selection and the focus are left behind.

Source

pub fn set_show_hidden(&mut self, on: bool)

Lists hidden entries too (a name starting with .), or leaves them out (the default); the place is listed again when it changes.

Source

pub fn show_hidden(&self) -> bool

Whether hidden entries are listed.

Source

pub fn reload(&mut self)

Lists the place again, keeping the selection and the focus by path.

Source

pub fn pump(&mut self)

Takes what the listing delivered.

Source

pub fn loading(&self) -> bool

Whether the listing is still under way.

Source

pub fn error(&self) -> Option<&SourceError>

Source

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.

Source

pub fn entries(&self) -> &[SourceEntry]

The entries shown, in order: a group’s members are not among them (FileBrowser::group_of).

Source

pub fn selection(&self) -> &Selection

Source

pub fn focus(&self) -> Option<&Path>

Source

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.

Source

pub fn modes(&self) -> Vec<String>

The modes this browser offers, in the switcher’s order.

Source

pub fn mode(&self) -> &str

Source

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.

Source

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).

Source

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.

Source

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.

Source

pub fn set_resize(&mut self, resize: GridResize)

FileBrowser::with_resize on a browser already made.

Source

pub fn resize(&self) -> GridResize

What the zoom means when the grid is resized.

Source

pub fn set_zoom(&mut self, zoom: ThumbZoom)

Sets the thumbnails’ zoom; it survives a resize.

Source

pub fn set_thumbnails_per_row(&mut self, per_row: u32)

This many thumbnails per row (one: a thumbnail across).

Source

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).

Source

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.

Source

pub fn key(&mut self, key: ModeKey, shift: bool) -> bool

Moves the focus by a key, as the mode’s layout says.

Source

pub fn select_all(&mut self)

Selects every entry shown the policy accepts (several only); with SelectionPolicy::keeps_filtered, those set aside stay selected.

Source

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.

Source

pub fn mode_infos(&self) -> Vec<ModeInfo>

What each of its modes is, in the switcher’s order.

Source

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.

Source

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.

Source

pub fn show(&mut self, ui: &mut Ui) -> BrowserOutput

Draws the toolbar’s mode switcher and the entries.

Trait Implementations§

Source§

impl Debug for FileBrowser

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

§

fn simd_from(_simd: S, value: T) -> T

§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

§

fn simd_into(self, simd: S) -> T

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

§

impl<T> WasmNotSend for T
where T: Send,