pub struct FilePicker {Show 18 fields
pub kind: ChooseKind,
pub dir: PathBuf,
pub filters: Vec<FileFilter>,
pub filter_index: usize,
pub text: String,
pub highlight: usize,
pub selected: BTreeSet<PathBuf>,
pub show_hidden: bool,
pub show_preview: bool,
pub pane_width: f32,
pub view: PickerView,
pub dialog: String,
pub thumbnail_size: f32,
pub sort: PickerSort,
pub folders_first: bool,
pub grouped: bool,
pub fill: bool,
pub error: Option<String>,
/* private fields */
}Expand description
The in-app picker: a folder’s entries, a field that filters them
(fuzzy) or takes a typed path (with completion), places, filters.
Usable on its own: FilePicker::show in any Ui.
Fields§
§kind: ChooseKind§dir: PathBufThe folder shown.
filters: Vec<FileFilter>§filter_index: usizeThe filter in use (filters.len(): all files).
text: StringThe field: a filter, or a path when it holds a separator or starts
with ~.
highlight: usizeThe entry highlighted among those shown: where the arrows are, what the preview is of, and what Enter acts on. The picker’s browser focus, read after each step; set it and the browser focuses that entry at the next.
selected: BTreeSet<PathBuf>What is selected, in the folder shown: files (choosing several), or
one folder (choosing a folder, or saving: Enter goes into it). The
picker’s browser selection, kept to its SelectionPolicy
and read after each step; set it and the browser selects what the
policy lets at the next.
show_preview: boolThe preview pane is shown (with previews, FilePicker::with_previews).
pane_width: f32The preview pane’s width, as wanted: the room in the dialog may hold it smaller.
view: PickerViewHow the entries are shown.
dialog: StringThe dialog its view is kept under (dialog_of).
thumbnail_size: f32The thumbnails’ side in the grid, in points, as last drawn from the
zoom (FilePicker::zoom). Set to another size, it becomes the
zoom at the next draw (the count per row it gives there).
sort: PickerSortThe order of the entries, in the list and in the grid.
folders_first: boolFolders come before files in every order.
grouped: boolFiles that go together are one entry, with groupings declared
(FilePicker::with_grouping) and when opening files.
fill: boolThe list takes the height left in the Ui it is drawn in (a
dialog of a given size), rather than LIST_HEIGHT.
error: Option<String>Why the last Enter did nothing.
Implementations§
Source§impl FilePicker
impl FilePicker
Sourcepub fn new(request: &FileRequest) -> Self
pub fn new(request: &FileRequest) -> Self
A picker for a request, in its folder (else home, else the root), on the system’s file system.
Sourcepub fn new_in(request: &FileRequest, fs: SharedFs) -> Self
pub fn new_in(request: &FileRequest, fs: SharedFs) -> Self
A picker for a request reading from fs, in the request’s folder
(else home, else the root).
Sourcepub fn choices(&self) -> &ChoiceValues
pub fn choices(&self) -> &ChoiceValues
The application’s choices (FileRequest::choice) as they stand: each
id with its value.
Sourcepub fn set_choice(&mut self, id: &str, value: &str) -> Result<(), String>
pub fn set_choice(&mut self, id: &str, value: &str) -> Result<(), String>
Sets one of the application’s choices; refused for an id the request does not have or a value it cannot take.
Sourcepub fn with_previews(self, previews: Previews) -> Self
pub fn with_previews(self, previews: Previews) -> Self
Shows the selected entry’s preview in a pane beside the list,
from these providers (Alt+P hides it).
Sourcepub fn with_resize(self, resize: GridResize) -> Self
pub fn with_resize(self, resize: GridResize) -> Self
What its grid’s zoom means when the grid is resized
(browser::GridResize::PerRow by default).
Sourcepub fn resize(&self) -> GridResize
pub fn resize(&self) -> GridResize
What its grid’s zoom means when the grid is resized.
Sourcepub fn with_grouping(self, groupings: Groupings) -> Self
pub fn with_grouping(self, groupings: Groupings) -> Self
Sourcepub fn group_of(&self, path: &Path) -> Option<&FileGroup>
pub fn group_of(&self, path: &Path) -> Option<&FileGroup>
The group a file heads, in the folder as last listed.
Sourcepub fn highlighted(&mut self) -> Option<Entry>
pub fn highlighted(&mut self) -> Option<Entry>
The entry the preview is of: the highlighted one.
Sourcepub fn file_system(&self) -> &SharedFs
pub fn file_system(&self) -> &SharedFs
Where it reads.
Sourcepub fn go_back(&mut self) -> bool
pub fn go_back(&mut self) -> bool
Goes back to the folder shown before; says whether there was one.
Sourcepub fn go_forward(&mut self) -> bool
pub fn go_forward(&mut self) -> bool
Goes forward to the folder gone back from; says whether there was one.
Sourcepub fn entries(&mut self) -> Vec<Entry>
pub fn entries(&mut self) -> Vec<Entry>
The folder’s entries in the picker’s order, those the filter accepts
(folders whatever the filter; none but folders when choosing a folder),
hidden ones only when asked, those the field’s text matches best first.
The folder is listed through a browser::FileBrowser, off the
interface thread on the system’s file system: its entries come in over
the next frames.
Sourcepub fn loading(&self) -> bool
pub fn loading(&self) -> bool
Whether the folder’s listing, or its groups, are still under way.
Sourcepub fn set_grouped(&mut self, on: bool)
pub fn set_grouped(&mut self, on: bool)
Groups files or leaves each its own entry: the highlight stays on its entry, or goes to the group that takes it in, and a member selected leaves the selection for what its group’s entry stands for.
Sourcepub fn set_sort(&mut self, sort: PickerSort)
pub fn set_sort(&mut self, sort: PickerSort)
Takes another order; the highlighted entry stays highlighted, wherever it lands, and comes into view.
Sourcepub fn set_folders_first(&mut self, on: bool)
pub fn set_folders_first(&mut self, on: bool)
Keeps folders first, or sorts them among the files; the highlighted entry stays highlighted, wherever it lands, and comes into view.
Sourcepub fn edit_path(&mut self)
pub fn edit_path(&mut self)
Ctrl+L: the folder goes into the field, as a path to edit, and the field takes the focus; a path already typed stays. Saving, the name stays at the path’s end with its stem selected, and comes back if the path leads to another folder instead.
Sourcepub fn typed_path(&self) -> PathBuf
pub fn typed_path(&self) -> PathBuf
The field as a path: ~ is home, a relative path is in the
folder.
Sourcepub fn visible(&mut self) -> Vec<Entry>
pub fn visible(&mut self) -> Vec<Entry>
The entries shown: entries, the field’s text ranking
them.
Sourcepub fn completions(&self) -> Vec<String>
pub fn completions(&self) -> Vec<String>
What a typed path may complete to: the names in its folder its last part starts (folders end with a separator).
Sourcepub fn complete(&mut self) -> bool
pub fn complete(&mut self) -> bool
Completes the typed path (Tab): to the only completion, else to what every completion shares. Says whether the text changed.
Sourcepub fn activate(&mut self) -> Option<PickerAnswer>
pub fn activate(&mut self) -> Option<PickerAnswer>
Enter: into a folder, or the choice. Saving, the folder selected goes first: otherwise the field’s name is what Enter takes.
Sourcepub fn set_filter(&mut self, index: usize)
pub fn set_filter(&mut self, index: usize)
Takes another filter (filters.len(): all files). Saving, a name
whose extension one of the request’s filters names takes the new
filter’s first, unless the new filter accepts it too; an extension
no filter names is the person’s and stays, and so does the name
under a filter without extensions.
Sourcepub fn begin_new_folder(&mut self) -> Result<(), String>
pub fn begin_new_folder(&mut self) -> Result<(), String>
Asks the new folder’s name, in a row under the folder: Enter makes it, Escape closes the row. Without a file system that can make one, the reason is the picker’s error, and the result.
Sourcepub fn create_folder(&mut self, name: &str) -> Result<PathBuf, String>
pub fn create_folder(&mut self, name: &str) -> Result<PathBuf, String>
Makes a folder in the one shown, and goes into it. A refusal is the picker’s error, and the result.
Sourcepub fn accept(&mut self) -> Option<PickerAnswer>
pub fn accept(&mut self) -> Option<PickerAnswer>
Ctrl+Enter, and the primary button: the folder (choosing a folder), the selection, the field’s name (saving: a folder selected does not turn Save into Open), or what Enter would choose.
Sourcepub fn toggle(&mut self)
pub fn toggle(&mut self)
Selects or unselects the highlighted entry: a file choosing several (a
folder is refused, the reason in error), a folder
choosing one. Does nothing in the other kinds, which have no key for it.
Sourcepub fn select_all(&mut self) -> Result<(), String>
pub fn select_all(&mut self) -> Result<(), String>
Selects every file shown (choosing several). None to select is a refusal: the reason is the picker’s error, and the result.
Sourcepub fn primary(&mut self) -> Primary
pub fn primary(&mut self) -> Primary
What the primary button does now: its label, the readout of what it takes (announced when it changes), and why it is off, when it is.
Sourcepub fn empty_state(&self) -> EmptyState
pub fn empty_state(&self) -> EmptyState
What the list says when it shows nothing, and the way out it offers.
Sourcepub fn show(&mut self, ui: &mut Ui, places: &Places) -> Option<PickerAnswer>
pub fn show(&mut self, ui: &mut Ui, places: &Places) -> Option<PickerAnswer>
Draws the picker; its answer when given. Drawn to fill its room
(fill, a dialog), its footer keeps its whole height at the
bottom and what is above it scrolls when the room runs short
(overlay::DialogLayout).
Source§impl FilePicker
impl FilePicker
Sourcepub fn set_zoom(&mut self, zoom: ThumbZoom)
pub fn set_zoom(&mut self, zoom: ThumbZoom)
A new zoom for the grid; the highlighted cell stays in view.
Sourcepub fn views(&self) -> Vec<PickerView>
pub fn views(&self) -> Vec<PickerView>
The views it offers, in the switcher’s order: details; thumbnails with previews; columns when choosing a folder.
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, among Self::views), as Ctrl+n
does; false without such a mode, or with one view alone.
Trait Implementations§
Source§impl Clone for FilePicker
impl Clone for FilePicker
Source§fn clone(&self) -> FilePicker
fn clone(&self) -> FilePicker
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for FilePicker
impl !RefUnwindSafe for FilePicker
impl Send for FilePicker
impl Sync for FilePicker
impl Unpin for FilePicker
impl UnsafeUnpin for FilePicker
impl !UnwindSafe for FilePicker
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§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> DowncastSync for T
impl<T> DowncastSync for T
§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