pub struct FileDialog {Show 26 fields
config: FileDialogConfig,
modals: Vec<Box<dyn FileDialogModal + Send + Sync>>,
mode: DialogMode,
state: DialogState,
show_files: bool,
operation_id: Option<String>,
window_id: Id,
user_directories: Option<UserDirectories>,
system_disks: Disks,
directory_stack: Vec<PathBuf>,
directory_offset: usize,
directory_content: DirectoryContent,
create_directory_dialog: CreateDirectoryDialog,
path_edit_visible: bool,
path_edit_value: String,
path_edit_activate: bool,
path_edit_request_focus: bool,
selected_item: Option<DirectoryEntry>,
file_name_input: String,
file_name_input_error: Option<String>,
file_name_input_request_focus: bool,
selected_file_filter: Option<Id>,
scroll_to_selection: bool,
search_value: String,
init_search: bool,
any_focused_last_frame: bool,
}
Expand description
Represents a file dialog instance.
The FileDialog
instance can be used multiple times and for different actions.
§Examples
use egui_file_dialog::FileDialog;
struct MyApp {
file_dialog: FileDialog,
}
impl MyApp {
fn update(&mut self, ctx: &egui::Context, ui: &mut egui::Ui) {
if ui.button("Pick a file").clicked() {
self.file_dialog.pick_file();
}
if let Some(path) = self.file_dialog.update(ctx).picked() {
println!("Picked file: {:?}", path);
}
}
}
Fields§
§config: FileDialogConfig
The configuration of the file dialog
modals: Vec<Box<dyn FileDialogModal + Send + Sync>>
Stack of modal windows to be displayed. The top element is what is currently being rendered.
mode: DialogMode
The mode the dialog is currently in
state: DialogState
The state the dialog is currently in
show_files: bool
If files are displayed in addition to directories.
This option will be ignored when mode == DialogMode::SelectFile
.
operation_id: Option<String>
This is an optional ID that can be set when opening the dialog to determine which operation the dialog is used for. This is useful if the dialog is used multiple times for different actions in the same view. The ID then makes it possible to distinguish for which action the user has selected an item. This ID is not used internally.
window_id: Id
The currently used window ID.
user_directories: Option<UserDirectories>
The user directories like Home or Documents.
These are loaded once when the dialog is created or when the refresh()
method is called.
system_disks: Disks
The currently mounted system disks.
These are loaded once when the dialog is created or when the refresh()
method is called.
directory_stack: Vec<PathBuf>
Contains the directories that the user opened. Every newly opened directory is pushed to the vector. Used for the navigation buttons to load the previous or next directory.
directory_offset: usize
An offset from the back of directory_stack
telling which directory is currently open.
If 0, the user is currently in the latest open directory.
If not 0, the user has used the “Previous directory” button and has
opened previously opened directories.
directory_content: DirectoryContent
The content of the currently open directory
create_directory_dialog: CreateDirectoryDialog
The dialog that is shown when the user wants to create a new directory.
path_edit_visible: bool
Whether the text edit is open for editing the current path.
path_edit_value: String
Buffer holding the text when the user edits the current path.
path_edit_activate: bool
If the path edit should be initialized. Unlike path_edit_request_focus
,
this also sets the cursor to the end of the text input field.
path_edit_request_focus: bool
If the text edit of the path should request focus in the next frame.
selected_item: Option<DirectoryEntry>
The item that the user currently selected. Can be a directory or a folder.
file_name_input: String
Buffer for the input of the file name when the dialog is in SaveFile
mode.
file_name_input_error: Option<String>
This variables contains the error message if the file_name_input
is invalid.
This can be the case, for example, if a file or folder with the name already exists.
file_name_input_request_focus: bool
If the file name input text field should request focus in the next frame.
selected_file_filter: Option<Id>
The file filter the user selected
scroll_to_selection: bool
If we should scroll to the item selected by the user in the next frame.
search_value: String
Buffer containing the value of the search input.
init_search: bool
If the search should be initialized in the next frame.
any_focused_last_frame: bool
If any widget was focused in the last frame. This is used to prevent the dialog from closing when pressing the escape key inside a text input.
Implementations§
Source§impl FileDialog
impl FileDialog
Sourcepub fn with_config(config: FileDialogConfig) -> Self
pub fn with_config(config: FileDialogConfig) -> Self
Creates a new file dialog object and initializes it with the specified configuration.
Sourcepub fn with_file_system(file_system: Arc<dyn FileSystem + Send + Sync>) -> Self
pub fn with_file_system(file_system: Arc<dyn FileSystem + Send + Sync>) -> Self
Uses the given file system instead of the native file system.
Sourcepub fn open(
&mut self,
mode: DialogMode,
show_files: bool,
operation_id: Option<&str>,
)
pub fn open( &mut self, mode: DialogMode, show_files: bool, operation_id: Option<&str>, )
Opens the file dialog in the given mode with the given options. This function resets the file dialog and takes care for the variables that need to be set when opening the file dialog.
Returns the result of the operation to load the initial directory.
If you don’t need to set the individual parameters, you can also use the shortcut
methods select_directory
, select_file
and save_file
.
§Arguments
mode
- The mode in which the dialog should be openedshow_files
- If files should also be displayed to the user in addition to directories. This is ignored if the mode isDialogMode::SelectFile
.operation_id
- Sets an ID for which operation the dialog was opened. This is useful when the dialog can be used for various operations in a single view. The ID can then be used to check which action the user selected an item for.
§Examples
The following example shows how the dialog can be used for multiple
actions using the operation_id
.
use std::path::PathBuf;
use egui_file_dialog::{DialogMode, FileDialog};
struct MyApp {
file_dialog: FileDialog,
picked_file_a: Option<PathBuf>,
picked_file_b: Option<PathBuf>,
}
impl MyApp {
fn update(&mut self, ctx: &egui::Context, ui: &mut egui::Ui) {
if ui.button("Pick file a").clicked() {
let _ = self.file_dialog.open(DialogMode::PickFile, true, Some("pick_a"));
}
if ui.button("Pick file b").clicked() {
let _ = self.file_dialog.open(DialogMode::PickFile, true, Some("pick_b"));
}
self.file_dialog.update(ctx);
if let Some(path) = self.file_dialog.picked() {
if self.file_dialog.operation_id() == Some("pick_a") {
self.picked_file_a = Some(path.to_path_buf());
}
if self.file_dialog.operation_id() == Some("pick_b") {
self.picked_file_b = Some(path.to_path_buf());
}
}
}
}
Sourcepub fn pick_directory(&mut self)
pub fn pick_directory(&mut self)
Shortcut function to open the file dialog to prompt the user to pick a directory.
If used, no files in the directories will be shown to the user.
Use the open()
method instead, if you still want to display files to the user.
This function resets the file dialog. Configuration variables such as
initial_directory
are retained.
The function ignores the result of the initial directory loading operation.
Sourcepub fn pick_file(&mut self)
pub fn pick_file(&mut self)
Shortcut function to open the file dialog to prompt the user to pick a file.
This function resets the file dialog. Configuration variables such as
initial_directory
are retained.
The function ignores the result of the initial directory loading operation.
Sourcepub fn pick_multiple(&mut self)
pub fn pick_multiple(&mut self)
Shortcut function to open the file dialog to prompt the user to pick multiple
files and folders.
This function resets the file dialog. Configuration variables such as initial_directory
are retained.
The function ignores the result of the initial directory loading operation.
Sourcepub fn save_file(&mut self)
pub fn save_file(&mut self)
Shortcut function to open the file dialog to prompt the user to save a file.
This function resets the file dialog. Configuration variables such as
initial_directory
are retained.
The function ignores the result of the initial directory loading operation.
Sourcepub fn update(&mut self, ctx: &Context) -> &Self
pub fn update(&mut self, ctx: &Context) -> &Self
The main update method that should be called every frame if the dialog is to be visible.
This function has no effect if the dialog state is currently not DialogState::Open
.
Sourcepub fn set_right_panel_width(&mut self, width: f32)
pub fn set_right_panel_width(&mut self, width: f32)
Sets the width of the right panel.
Sourcepub fn clear_right_panel_width(&mut self)
pub fn clear_right_panel_width(&mut self)
Clears the width of the right panel by setting it to None.
Sourcepub fn update_with_right_panel_ui(
&mut self,
ctx: &Context,
f: &mut (dyn FnMut(&mut Ui, &mut FileDialog) + '_),
) -> &Self
pub fn update_with_right_panel_ui( &mut self, ctx: &Context, f: &mut (dyn FnMut(&mut Ui, &mut FileDialog) + '_), ) -> &Self
Do an update with a custom right panel ui.
Example use cases:
- Show custom information for a file (size, MIME type, etc.)
- Embed a preview, like a thumbnail for an image
- Add controls for custom open options, like open as read-only, etc.
See active_entry
to get the active directory entry
to show the information for.
This function has no effect if the dialog state is currently not DialogState::Open
.
Sourcepub fn config_mut(&mut self) -> &mut FileDialogConfig
pub fn config_mut(&mut self) -> &mut FileDialogConfig
Mutably borrow internal config
.
Sourcepub fn storage(self, storage: FileDialogStorage) -> Self
pub fn storage(self, storage: FileDialogStorage) -> Self
Sets the storage used by the file dialog. Storage includes all data that is persistently stored between multiple file dialog instances.
Sourcepub fn storage_mut(&mut self) -> &mut FileDialogStorage
pub fn storage_mut(&mut self) -> &mut FileDialogStorage
Mutably borrow internal storage.
Sourcepub fn keybindings(self, keybindings: FileDialogKeyBindings) -> Self
pub fn keybindings(self, keybindings: FileDialogKeyBindings) -> Self
Sets the keybindings used by the file dialog.
Sourcepub fn labels(self, labels: FileDialogLabels) -> Self
pub fn labels(self, labels: FileDialogLabels) -> Self
Sets the labels the file dialog uses.
Used to enable multiple language support.
See FileDialogLabels
for more information.
Sourcepub fn labels_mut(&mut self) -> &mut FileDialogLabels
pub fn labels_mut(&mut self) -> &mut FileDialogLabels
Mutably borrow internal config.labels
.
Sourcepub const fn opening_mode(self, opening_mode: OpeningMode) -> Self
pub const fn opening_mode(self, opening_mode: OpeningMode) -> Self
Sets which directory is loaded when opening the file dialog.
Sourcepub const fn as_modal(self, as_modal: bool) -> Self
pub const fn as_modal(self, as_modal: bool) -> Self
If the file dialog window should be displayed as a modal.
If the window is displayed as modal, the area outside the dialog can no longer be interacted with and an overlay is displayed.
Sourcepub const fn modal_overlay_color(self, modal_overlay_color: Color32) -> Self
pub const fn modal_overlay_color(self, modal_overlay_color: Color32) -> Self
Sets the color of the overlay when the dialog is displayed as a modal window.
Sourcepub fn initial_directory(self, directory: PathBuf) -> Self
pub fn initial_directory(self, directory: PathBuf) -> Self
Sets the first loaded directory when the dialog opens. If the path is a file, the file’s parent directory is used. If the path then has no parent directory or cannot be loaded, the user will receive an error. However, the user directories and system disk allow the user to still select a file in the event of an error.
Since fs::canonicalize
is used, both absolute paths and relative paths are allowed.
See FileDialog::canonicalize_paths
for more information.
Sourcepub fn default_file_name(self, name: &str) -> Self
pub fn default_file_name(self, name: &str) -> Self
Sets the default file name when opening the dialog in DialogMode::SaveFile
mode.
Sourcepub const fn allow_file_overwrite(self, allow_file_overwrite: bool) -> Self
pub const fn allow_file_overwrite(self, allow_file_overwrite: bool) -> Self
Sets if the user is allowed to select an already existing file when the dialog is in
DialogMode::SaveFile
mode.
If this is enabled, the user will receive a modal asking whether the user really wants to overwrite an existing file.
Sourcepub const fn allow_path_edit_to_save_file_without_extension(
self,
allow: bool,
) -> Self
pub const fn allow_path_edit_to_save_file_without_extension( self, allow: bool, ) -> Self
Sets if the path edit is allowed to select the path as the file to save if it does not have an extension.
This can lead to confusion if the user wants to open a directory with the path edit, types it incorrectly and the dialog tries to select the incorrectly typed folder as the file to be saved.
This only affects the DialogMode::SaveFile
mode.
Sourcepub fn directory_separator(self, separator: &str) -> Self
pub fn directory_separator(self, separator: &str) -> Self
Sets the separator of the directories when displaying a path. Currently only used when the current path is displayed in the top panel.
Sourcepub const fn canonicalize_paths(self, canonicalize: bool) -> Self
pub const fn canonicalize_paths(self, canonicalize: bool) -> Self
Sets if the paths in the file dialog should be canonicalized before use.
By default, all paths are canonicalized. This has the advantage that the paths are all brought to a standard and are therefore compatible with each other.
On Windows, however, this results in the namespace prefix \\?\
being set in
front of the path, which may not be compatible with other applications.
In addition, canonicalizing converts all relative paths to absolute ones.
See: Rust docs for more information.
In general, it is only recommended to disable canonicalization if you know what you are doing and have a reason for it. Disabling canonicalization can lead to unexpected behavior, for example if an already canonicalized path is then set as the initial directory.
Sourcepub const fn load_via_thread(self, load_via_thread: bool) -> Self
pub const fn load_via_thread(self, load_via_thread: bool) -> Self
If the directory content should be loaded via a separate thread. This prevents the application from blocking when loading large directories or from slow hard drives.
Sourcepub const fn truncate_filenames(self, truncate_filenames: bool) -> Self
pub const fn truncate_filenames(self, truncate_filenames: bool) -> Self
Sets if long filenames should be truncated in the middle. The extension, if available, will be preserved.
Warning! If this is disabled, the scroll-to-selection might not work correctly and have an offset for large directories.
Sourcepub fn default_file_icon(self, icon: &str) -> Self
pub fn default_file_icon(self, icon: &str) -> Self
Sets the default icon that is used to display files.
Sourcepub fn default_folder_icon(self, icon: &str) -> Self
pub fn default_folder_icon(self, icon: &str) -> Self
Sets the default icon that is used to display folders.
Sourcepub fn device_icon(self, icon: &str) -> Self
pub fn device_icon(self, icon: &str) -> Self
Sets the icon that is used to display devices in the left panel.
Sourcepub fn removable_device_icon(self, icon: &str) -> Self
pub fn removable_device_icon(self, icon: &str) -> Self
Sets the icon that is used to display removable devices in the left panel.
Sourcepub fn add_file_filter(
self,
name: &str,
filter: Arc<dyn Fn(&Path) -> bool + Send + Sync>,
) -> Self
pub fn add_file_filter( self, name: &str, filter: Arc<dyn Fn(&Path) -> bool + Send + Sync>, ) -> Self
Adds a new file filter the user can select from a dropdown widget.
NOTE: The name must be unique. If a filter with the same name already exists, it will be overwritten.
§Arguments
name
- Display name of the filterfilter
- Sets a filter function that checks whether a given Path matches the criteria for this filter.
§Examples
use std::sync::Arc;
use egui_file_dialog::FileDialog;
FileDialog::new()
.add_file_filter(
"PNG files",
Arc::new(|path| path.extension().unwrap_or_default() == "png"))
.add_file_filter(
"JPG files",
Arc::new(|path| path.extension().unwrap_or_default() == "jpg"));
Sourcepub fn default_file_filter(self, name: &str) -> Self
pub fn default_file_filter(self, name: &str) -> Self
Name of the file filter to be selected by default.
No file filter is selected if there is no file filter with that name.
Sourcepub fn set_file_icon(
self,
icon: &str,
filter: Arc<dyn Fn(&Path) -> bool + Send + Sync>,
) -> Self
pub fn set_file_icon( self, icon: &str, filter: Arc<dyn Fn(&Path) -> bool + Send + Sync>, ) -> Self
Sets a new icon for specific files or folders.
§Arguments
icon
- The icon that should be used.filter
- Sets a filter function that checks whether a given Path matches the criteria for this icon.
§Examples
use std::sync::Arc;
use egui_file_dialog::FileDialog;
FileDialog::new()
// .png files should use the "document with picture (U+1F5BB)" icon.
.set_file_icon("🖻", Arc::new(|path| path.extension().unwrap_or_default() == "png"))
// .git directories should use the "web-github (U+E624)" icon.
.set_file_icon("", Arc::new(|path| path.file_name().unwrap_or_default() == ".git"));
Sourcepub fn add_quick_access(
self,
heading: &str,
builder: impl FnOnce(&mut QuickAccess),
) -> Self
pub fn add_quick_access( self, heading: &str, builder: impl FnOnce(&mut QuickAccess), ) -> Self
Adds a new custom quick access section to the left panel.
§Examples
use egui_file_dialog::FileDialog;
FileDialog::new()
.add_quick_access("My App", |s| {
s.add_path("Config", "/app/config");
s.add_path("Themes", "/app/themes");
s.add_path("Languages", "/app/languages");
});
Sourcepub fn title(self, title: &str) -> Self
pub fn title(self, title: &str) -> Self
Overwrites the window title.
By default, the title is set dynamically, based on the DialogMode
the dialog is currently in.
Sourcepub fn default_pos(self, default_pos: impl Into<Pos2>) -> Self
pub fn default_pos(self, default_pos: impl Into<Pos2>) -> Self
Sets the default position of the window.
Sourcepub fn fixed_pos(self, pos: impl Into<Pos2>) -> Self
pub fn fixed_pos(self, pos: impl Into<Pos2>) -> Self
Sets the window position and prevents it from being dragged around.
Sourcepub fn default_size(self, size: impl Into<Vec2>) -> Self
pub fn default_size(self, size: impl Into<Vec2>) -> Self
Sets the default size of the window.
Sourcepub fn min_size(self, min_size: impl Into<Vec2>) -> Self
pub fn min_size(self, min_size: impl Into<Vec2>) -> Self
Sets the minimum size of the window.
Specifying a smaller minimum size than the default can lead to unexpected behavior.
Sourcepub fn anchor(self, align: Align2, offset: impl Into<Vec2>) -> Self
pub fn anchor(self, align: Align2, offset: impl Into<Vec2>) -> Self
Sets the anchor of the window.
Sourcepub const fn movable(self, movable: bool) -> Self
pub const fn movable(self, movable: bool) -> Self
Sets if the window is movable.
Has no effect if an anchor is set.
Sourcepub const fn title_bar(self, title_bar: bool) -> Self
pub const fn title_bar(self, title_bar: bool) -> Self
Sets if the title bar of the window is shown.
Sourcepub const fn show_top_panel(self, show_top_panel: bool) -> Self
pub const fn show_top_panel(self, show_top_panel: bool) -> Self
Sets if the top panel with the navigation buttons, current path display and search input should be visible.
Sets whether the parent folder button should be visible in the top panel.
Has no effect when FileDialog::show_top_panel
is disabled.
Sets whether the back button should be visible in the top panel.
Has no effect when FileDialog::show_top_panel
is disabled.
Sets whether the forward button should be visible in the top panel.
Has no effect when FileDialog::show_top_panel
is disabled.
Sets whether the button to create a new folder should be visible in the top panel.
Has no effect when FileDialog::show_top_panel
is disabled.
Sourcepub const fn show_current_path(self, show_current_path: bool) -> Self
pub const fn show_current_path(self, show_current_path: bool) -> Self
Sets whether the current path should be visible in the top panel.
Has no effect when FileDialog::show_top_panel
is disabled.
Sets whether the button to text edit the current path should be visible in the top panel.
has no effect when FileDialog::show_top_panel
is disabled.
Sets whether the menu with the reload button and other options should be visible inside the top panel.
Has no effect when FileDialog::show_top_panel
is disabled.
Sets whether the reload button inside the top panel menu should be visible.
Has no effect when FileDialog::show_top_panel
or
FileDialog::show_menu_button
is disabled.
Sets whether the show hidden files and folders option inside the top panel menu should be visible.
Has no effect when FileDialog::show_top_panel
or
FileDialog::show_menu_button
is disabled.
Sourcepub const fn show_system_files_option(
self,
show_system_files_option: bool,
) -> Self
pub const fn show_system_files_option( self, show_system_files_option: bool, ) -> Self
Sets whether the show system files option inside the top panel menu should be visible.
Has no effect when FileDialog::show_top_panel
or
FileDialog::show_menu_button
is disabled.
Sourcepub const fn show_search(self, show_search: bool) -> Self
pub const fn show_search(self, show_search: bool) -> Self
Sets whether the search input should be visible in the top panel.
Has no effect when FileDialog::show_top_panel
is disabled.
Sourcepub const fn show_left_panel(self, show_left_panel: bool) -> Self
pub const fn show_left_panel(self, show_left_panel: bool) -> Self
Sets if the sidebar with the shortcut directories such as “Home”, “Documents” etc. should be visible.
Sourcepub const fn show_pinned_folders(self, show_pinned_folders: bool) -> Self
pub const fn show_pinned_folders(self, show_pinned_folders: bool) -> Self
Sets if pinned folders should be listed in the left sidebar. Disabling this will also disable the functionality to pin a folder.
Sourcepub const fn show_places(self, show_places: bool) -> Self
pub const fn show_places(self, show_places: bool) -> Self
Sets if the “Places” section should be visible in the left sidebar. The Places section contains the user directories such as Home or Documents.
Has no effect when FileDialog::show_left_panel
is disabled.
Sourcepub const fn show_devices(self, show_devices: bool) -> Self
pub const fn show_devices(self, show_devices: bool) -> Self
Sets if the “Devices” section should be visible in the left sidebar. The Devices section contains the non removable system disks.
Has no effect when FileDialog::show_left_panel
is disabled.
Sourcepub const fn show_removable_devices(self, show_removable_devices: bool) -> Self
pub const fn show_removable_devices(self, show_removable_devices: bool) -> Self
Sets if the “Removable Devices” section should be visible in the left sidebar. The Removable Devices section contains the removable disks like USB disks.
Has no effect when FileDialog::show_left_panel
is disabled.
Sourcepub fn picked(&self) -> Option<&Path>
pub fn picked(&self) -> Option<&Path>
Returns the directory or file that the user picked, or the target file
if the dialog is in DialogMode::SaveFile
mode.
None is returned when the user has not yet selected an item.
Sourcepub fn take_picked(&mut self) -> Option<PathBuf>
pub fn take_picked(&mut self) -> Option<PathBuf>
Returns the directory or file that the user picked, or the target file
if the dialog is in DialogMode::SaveFile
mode.
Unlike FileDialog::picked
, this method returns the picked path only once and
sets the dialog’s state to DialogState::Closed
.
None is returned when the user has not yet picked an item.
Sourcepub fn picked_multiple(&self) -> Option<Vec<&Path>>
pub fn picked_multiple(&self) -> Option<Vec<&Path>>
Returns a list of the files and folders the user picked, when the dialog is in
DialogMode::PickMultiple
mode.
None is returned when the user has not yet picked an item.
Sourcepub fn take_picked_multiple(&mut self) -> Option<Vec<PathBuf>>
pub fn take_picked_multiple(&mut self) -> Option<Vec<PathBuf>>
Returns a list of the files and folders the user picked, when the dialog is in
DialogMode::PickMultiple
mode.
Unlike FileDialog::picked_multiple
, this method returns the picked paths only once
and sets the dialog’s state to DialogState::Closed
.
None is returned when the user has not yet picked an item.
Sourcepub const fn selected_entry(&self) -> Option<&DirectoryEntry>
pub const fn selected_entry(&self) -> Option<&DirectoryEntry>
Returns the currently active directory entry.
This is either the currently highlighted entry, or the currently active directory if nothing is being highlighted.
For the [DialogMode::SelectMultiple
] counterpart,
see [FileDialog::active_selected_entries
].
Sourcepub fn selected_entries(&self) -> impl Iterator<Item = &DirectoryEntry>
pub fn selected_entries(&self) -> impl Iterator<Item = &DirectoryEntry>
Returns an iterator over the currently selected entries in SelectMultiple
mode.
For the counterpart in single selection modes, see [FileDialog::active_entry
].
Sourcepub fn operation_id(&self) -> Option<&str>
pub fn operation_id(&self) -> Option<&str>
Returns the ID of the operation for which the dialog is currently being used.
See FileDialog::open
for more information.
Sourcepub const fn mode(&self) -> DialogMode
pub const fn mode(&self) -> DialogMode
Returns the mode the dialog is currently in.
Sourcepub fn state(&self) -> DialogState
pub fn state(&self) -> DialogState
Returns the state the dialog is currently in.
Sourcepub const fn get_window_id(&self) -> Id
pub const fn get_window_id(&self) -> Id
Get the window Id
Source§impl FileDialog
UI methods
impl FileDialog
UI methods
Sourcefn update_ui(
&mut self,
ctx: &Context,
right_panel_fn: Option<&mut (dyn FnMut(&mut Ui, &mut FileDialog) + '_)>,
)
fn update_ui( &mut self, ctx: &Context, right_panel_fn: Option<&mut (dyn FnMut(&mut Ui, &mut FileDialog) + '_)>, )
Main update method of the UI
Takes an optional callback to show a custom right panel.
Sourcefn ui_update_modal_background(&self, ctx: &Context) -> InnerResponse<()>
fn ui_update_modal_background(&self, ctx: &Context) -> InnerResponse<()>
Updates the main modal background of the file dialog window.
fn ui_update_modals(&mut self, ui: &mut Ui)
Sourcefn create_window<'a>(&self, is_open: &'a mut bool) -> Window<'a>
fn create_window<'a>(&self, is_open: &'a mut bool) -> Window<'a>
Creates a new egui window with the configured options.
Sourceconst fn get_window_title(&self) -> &String
const fn get_window_title(&self) -> &String
Gets the window title to use. This is either one of the default window titles or the configured window title.
Sourcefn ui_update_top_panel(&mut self, ui: &mut Ui)
fn ui_update_top_panel(&mut self, ui: &mut Ui)
Updates the top panel of the dialog. Including the navigation buttons, the current path display, the reload button and the search field.
Updates the navigation buttons like parent or previous directory
Sourcefn ui_update_current_path(&mut self, ui: &mut Ui, width: f32)
fn ui_update_current_path(&mut self, ui: &mut Ui, width: f32)
Updates the view to display the current path. This could be the view for displaying the current path and the individual sections, as well as the view for text editing of the current path.
Sourcefn ui_update_path_display(
&mut self,
ui: &mut Ui,
width: f32,
edit_button_size: Vec2,
)
fn ui_update_path_display( &mut self, ui: &mut Ui, width: f32, edit_button_size: Vec2, )
Updates the view when the currently open path with the individual sections is displayed.
Sourcefn ui_update_path_edit(
&mut self,
ui: &mut Ui,
width: f32,
edit_button_size: Vec2,
)
fn ui_update_path_edit( &mut self, ui: &mut Ui, width: f32, edit_button_size: Vec2, )
Updates the view when the user currently wants to text edit the current path.
Sourcefn ui_update_search(&mut self, ui: &mut Ui)
fn ui_update_search(&mut self, ui: &mut Ui)
Updates the search input
Sourcefn edit_search_on_text_input(&mut self, ui: &Ui)
fn edit_search_on_text_input(&mut self, ui: &Ui)
Focuses and types into the search input, if text input without shortcut modifiers is detected, and no other inputs are focused.
§Arguments
re
: Theegui::Response
returned by the filter text edit widget
Sourcefn ui_update_left_panel(&mut self, ui: &mut Ui)
fn ui_update_left_panel(&mut self, ui: &mut Ui)
Updates the left panel of the dialog. Including the list of the user directories (Places) and system disks (Devices, Removable Devices).
Sourcefn ui_update_left_panel_entry(
&mut self,
ui: &mut Ui,
display_name: &str,
path: &Path,
) -> Response
fn ui_update_left_panel_entry( &mut self, ui: &mut Ui, display_name: &str, path: &Path, ) -> Response
Updates a path entry in the left panel.
Returns the response of the selectable label.
Sourcefn ui_update_quick_access(&mut self, ui: &mut Ui, quick_access: &QuickAccess)
fn ui_update_quick_access(&mut self, ui: &mut Ui, quick_access: &QuickAccess)
Updates a custom quick access section added to the left panel.
Sourcefn ui_update_pinned_paths(&mut self, ui: &mut Ui, spacing: f32) -> bool
fn ui_update_pinned_paths(&mut self, ui: &mut Ui, spacing: f32) -> bool
Updates the list of pinned folders.
Returns true if at least one directory item was included in the list and the heading is visible. If no item was listed, false is returned.
Sourcefn ui_update_user_directories(&mut self, ui: &mut Ui, spacing: f32) -> bool
fn ui_update_user_directories(&mut self, ui: &mut Ui, spacing: f32) -> bool
Updates the list of user directories (Places).
Returns true if at least one directory was included in the list and the heading is visible. If no directory was listed, false is returned.
Sourcefn ui_update_devices(
&mut self,
ui: &mut Ui,
spacing: f32,
disks: &Disks,
) -> bool
fn ui_update_devices( &mut self, ui: &mut Ui, spacing: f32, disks: &Disks, ) -> bool
Updates the list of devices like system disks.
Returns true if at least one device was included in the list and the heading is visible. If no device was listed, false is returned.
Sourcefn ui_update_removable_devices(
&mut self,
ui: &mut Ui,
spacing: f32,
disks: &Disks,
) -> bool
fn ui_update_removable_devices( &mut self, ui: &mut Ui, spacing: f32, disks: &Disks, ) -> bool
Updates the list of removable devices like USB drives.
Returns true if at least one device was included in the list and the heading is visible. If no device was listed, false is returned.
Sourcefn ui_update_device_entry(&mut self, ui: &mut Ui, device: &Disk)
fn ui_update_device_entry(&mut self, ui: &mut Ui, device: &Disk)
Updates a device entry of a device list like “Devices” or “Removable Devices”.
Sourcefn ui_update_bottom_panel(&mut self, ui: &mut Ui)
fn ui_update_bottom_panel(&mut self, ui: &mut Ui)
Updates the bottom panel showing the selected item and main action buttons.
Sourcefn ui_update_selection_preview(&mut self, ui: &mut Ui, button_size: Vec2)
fn ui_update_selection_preview(&mut self, ui: &mut Ui, button_size: Vec2)
Updates the selection preview like “Selected directory: X”
fn get_selection_preview_text(&self) -> String
fn ui_update_file_filter_selection(&mut self, ui: &mut Ui, width: f32)
Updates the action buttons like save, open and cancel
Sourcefn ui_update_central_panel(&mut self, ui: &mut Ui)
fn ui_update_central_panel(&mut self, ui: &mut Ui)
Updates the central panel. This is either the contents of the directory or the error message when there was an error loading the current directory.
Sourcefn update_directory_content(&mut self, ui: &mut Ui) -> bool
fn update_directory_content(&mut self, ui: &mut Ui) -> bool
Updates the directory content (Not the UI!). This is required because the contents of the directory might be loaded on a separate thread. This function checks the status of the directory content and updates the UI accordingly.
Sourcefn ui_update_central_panel_content(&mut self, ui: &mut Ui)
fn ui_update_central_panel_content(&mut self, ui: &mut Ui)
Updates the contents of the currently open directory. TODO: Refactor
Sourcefn ui_update_central_panel_entry(
&mut self,
ui: &mut Ui,
item: &mut DirectoryEntry,
reset_multi_selection: &mut bool,
batch_select_item_b: &mut Option<DirectoryEntry>,
) -> bool
fn ui_update_central_panel_entry( &mut self, ui: &mut Ui, item: &mut DirectoryEntry, reset_multi_selection: &mut bool, batch_select_item_b: &mut Option<DirectoryEntry>, ) -> bool
Updates a single directory content entry. TODO: Refactor
fn ui_update_create_directory_dialog( &mut self, ui: &mut Ui, ) -> Option<DirectoryEntry>
Sourcefn batch_select_between(
&self,
directory_content: &mut DirectoryContent,
item_a: &DirectoryEntry,
item_b: &DirectoryEntry,
)
fn batch_select_between( &self, directory_content: &mut DirectoryContent, item_a: &DirectoryEntry, item_b: &DirectoryEntry, )
Selects every item inside the directory_content
between item_a
and item_b
,
excluding both given items.
Helper function to add a sized button that can be enabled or disabled
Updates the context menu of a path.
§Arguments
item_response
- The response of the egui item for which the context menu should be opened.path
- The path for which the context menu should be opened.
Sourcefn set_cursor_to_end(re: &Response, data: &str)
fn set_cursor_to_end(re: &Response, data: &str)
Sets the cursor position to the end of a text input field.
§Arguments
re
- response of the text input widgetdata
- buffer holding the text of the input widget
Sourcefn calc_char_width(ui: &Ui, char: char) -> f32
fn calc_char_width(ui: &Ui, char: char) -> f32
Calculates the width of a single char.
Sourcefn calc_text_width(ui: &Ui, text: &str) -> f32
fn calc_text_width(ui: &Ui, text: &str) -> f32
Calculates the width of the specified text using the current font configuration. Does not take new lines or text breaks into account!
fn truncate_filename(ui: &Ui, item: &DirectoryEntry, max_length: f32) -> String
Source§impl FileDialog
Keybindings
impl FileDialog
Keybindings
Sourcefn update_keybindings(&mut self, ctx: &Context)
fn update_keybindings(&mut self, ctx: &Context)
Checks whether certain keybindings have been pressed and executes the corresponding actions.
Sourcefn exec_keybinding_submit(&mut self)
fn exec_keybinding_submit(&mut self)
Executes the action when the keybinding submit
is pressed.
Sourcefn exec_keybinding_cancel(&mut self)
fn exec_keybinding_cancel(&mut self)
Executes the action when the keybinding cancel
is pressed.
Sourcefn exec_keybinding_selection_up(&mut self)
fn exec_keybinding_selection_up(&mut self)
Executes the action when the keybinding selection_up
is pressed.
Sourcefn exec_keybinding_selection_down(&mut self)
fn exec_keybinding_selection_down(&mut self)
Executes the action when the keybinding selection_down
is pressed.
Source§impl FileDialog
Implementation
impl FileDialog
Implementation
Sourcefn get_selected_file_filter(&self) -> Option<&FileFilter>
fn get_selected_file_filter(&self) -> Option<&FileFilter>
Get the file filter the user currently selected.
Sourcefn get_dir_content_filtered_iter(&self) -> impl Iterator<Item = &DirectoryEntry>
fn get_dir_content_filtered_iter(&self) -> impl Iterator<Item = &DirectoryEntry>
Gets a filtered iterator of the directory content of this object.
Sourcefn open_new_folder_dialog(&mut self)
fn open_new_folder_dialog(&mut self)
Opens the dialog to create a new folder.
Sourcefn process_new_folder(&mut self, created_dir: &Path) -> DirectoryEntry
fn process_new_folder(&mut self, created_dir: &Path) -> DirectoryEntry
Function that processes a newly created folder.
Sourcefn open_modal(&mut self, modal: Box<dyn FileDialogModal + Send + Sync>)
fn open_modal(&mut self, modal: Box<dyn FileDialogModal + Send + Sync>)
Opens a new modal window.
Sourcefn exec_modal_action(&mut self, action: ModalAction)
fn exec_modal_action(&mut self, action: ModalAction)
Executes the given modal action.
Sourcefn canonicalize_path(&self, path: &Path) -> PathBuf
fn canonicalize_path(&self, path: &Path) -> PathBuf
Canonicalizes the specified path if canonicalization is enabled. Returns the input path if an error occurs or canonicalization is disabled.
Sourcefn pin_path(&mut self, path: DirectoryEntry)
fn pin_path(&mut self, path: DirectoryEntry)
Pins a path to the left sidebar.
Sourcefn unpin_path(&mut self, path: &DirectoryEntry)
fn unpin_path(&mut self, path: &DirectoryEntry)
Unpins a path from the left sidebar.
Sourcefn is_pinned(&self, path: &DirectoryEntry) -> bool
fn is_pinned(&self, path: &DirectoryEntry) -> bool
Checks if the path is pinned to the left sidebar.
fn is_primary_selected(&self, item: &DirectoryEntry) -> bool
Sourcefn reset(&mut self)
fn reset(&mut self)
Resets the dialog to use default values. Configuration variables are retained.
Sourcefn refresh(&mut self)
fn refresh(&mut self)
Refreshes the dialog. Including the user directories, system disks and currently open directory.
Sourcefn submit(&mut self)
fn submit(&mut self)
Submits the current selection and tries to finish the dialog, if the selection is valid.
Sourcefn submit_save_file(&mut self, path: PathBuf)
fn submit_save_file(&mut self, path: PathBuf)
Submits the file dialog with the specified path and opens the OverwriteFileModal
if the path already exists.
Sourcefn get_initial_directory(&self) -> PathBuf
fn get_initial_directory(&self) -> PathBuf
This function generates the initial directory based on the configuration. The function does the following things:
- Get the path to open based on the opening mode
- Canonicalize the path if enabled
- Attempts to use the parent directory if the path is a file
Sourcefn current_directory(&self) -> Option<&Path>
fn current_directory(&self) -> Option<&Path>
Gets the currently open directory.
Sourcefn is_selection_valid(&self) -> bool
fn is_selection_valid(&self) -> bool
Checks whether the selection or the file name entered is valid. What is checked depends on the mode the dialog is currently in.
Sourcefn validate_file_name_input(&self) -> Option<String>
fn validate_file_name_input(&self) -> Option<String>
Validates the file name entered by the user.
Returns None if the file name is valid. Otherwise returns an error message.
Sourcefn select_item(&mut self, item: &mut DirectoryEntry)
fn select_item(&mut self, item: &mut DirectoryEntry)
Marks the given item as the selected directory item.
Also updates the file_name_input
to the name of the selected item.
Sourcefn select_next_visible_item_before(&mut self, item: &DirectoryEntry) -> bool
fn select_next_visible_item_before(&mut self, item: &DirectoryEntry) -> bool
Attempts to select the last visible item in directory_content
before the specified item.
Returns true if an item is found and selected. Returns false if no visible item is found before the specified item.
Sourcefn select_next_visible_item_after(&mut self, item: &DirectoryEntry) -> bool
fn select_next_visible_item_after(&mut self, item: &DirectoryEntry) -> bool
Attempts to select the last visible item in directory_content
after the specified item.
Returns true if an item is found and selected. Returns false if no visible item is found after the specified item.
Sourcefn select_first_visible_item(&mut self)
fn select_first_visible_item(&mut self)
Tries to select the first visible item inside directory_content
.
Sourcefn select_last_visible_item(&mut self)
fn select_last_visible_item(&mut self)
Tries to select the last visible item inside directory_content
.
Sourcefn open_path_edit(&mut self)
fn open_path_edit(&mut self)
Opens the text field in the top panel to text edit the current path.
Sourcefn submit_path_edit(&mut self)
fn submit_path_edit(&mut self)
Loads the directory from the path text edit.
Sourcefn close_path_edit(&mut self)
fn close_path_edit(&mut self)
Closes the text field at the top to edit the current path without loading the entered directory.
Sourcefn load_next_directory(&mut self)
fn load_next_directory(&mut self)
Loads the next directory in the directory_stack
.
If directory_offset
is 0 and there is no other directory to load, Ok()
is returned and
nothing changes.
Otherwise, the result of the directory loading operation is returned.
Sourcefn load_previous_directory(&mut self)
fn load_previous_directory(&mut self)
Loads the previous directory the user opened.
If there is no previous directory left, Ok()
is returned and nothing changes.
Otherwise, the result of the directory loading operation is returned.
Sourcefn load_parent_directory(&mut self)
fn load_parent_directory(&mut self)
Loads the parent directory of the currently open directory.
If the directory doesn’t have a parent, Ok()
is returned and nothing changes.
Otherwise, the result of the directory loading operation is returned.
Sourcefn reload_directory(&mut self)
fn reload_directory(&mut self)
Reloads the currently open directory.
If no directory is currently open, Ok()
will be returned.
Otherwise, the result of the directory loading operation is returned.
In most cases, this function should not be called directly.
Instead, refresh
should be used to reload all other data like system disks too.
Sourcefn load_directory(&mut self, path: &Path)
fn load_directory(&mut self, path: &Path)
Loads the given directory and updates the directory_stack
.
The function deletes all directories from the directory_stack
that are currently
stored in the vector before the directory_offset
.
The function also sets the loaded directory as the selected item.
Sourcefn load_directory_content(&mut self, path: &Path)
fn load_directory_content(&mut self, path: &Path)
Loads the directory content of the given path.