Struct egui_file_dialog::FileDialogConfig
source · pub struct FileDialogConfig {Show 48 fields
pub storage: FileDialogStorage,
pub labels: FileDialogLabels,
pub keybindings: FileDialogKeyBindings,
pub as_modal: bool,
pub modal_overlay_color: Color32,
pub initial_directory: PathBuf,
pub default_file_name: String,
pub allow_file_overwrite: bool,
pub directory_separator: String,
pub canonicalize_paths: bool,
pub err_icon: String,
pub warn_icon: String,
pub default_file_icon: String,
pub default_folder_icon: String,
pub pinned_icon: String,
pub device_icon: String,
pub removable_device_icon: String,
pub file_filters: Vec<FileFilter>,
pub default_file_filter: Option<String>,
pub file_icon_filters: Vec<IconFilter>,
pub quick_accesses: Vec<QuickAccess>,
pub title: Option<String>,
pub id: Option<Id>,
pub default_pos: Option<Pos2>,
pub fixed_pos: Option<Pos2>,
pub default_size: Vec2,
pub max_size: Option<Vec2>,
pub min_size: Vec2,
pub anchor: Option<(Align2, Vec2)>,
pub resizable: bool,
pub movable: bool,
pub title_bar: bool,
pub show_top_panel: bool,
pub show_parent_button: bool,
pub show_back_button: bool,
pub show_forward_button: bool,
pub show_new_folder_button: bool,
pub show_current_path: bool,
pub show_path_edit_button: bool,
pub show_menu_button: bool,
pub show_reload_button: bool,
pub show_hidden_option: bool,
pub show_search: bool,
pub show_left_panel: bool,
pub show_pinned_folders: bool,
pub show_places: bool,
pub show_devices: bool,
pub show_removable_devices: bool,
}
Expand description
Contains configuration values of a file dialog.
The configuration of a file dialog can be set using FileDialog::with_config
.
If you only need to configure a single file dialog, you don’t need to
manually use a FileDialogConfig
object. FileDialog
provides setter methods for
each of these configuration options, for example: FileDialog::initial_directory
or FileDialog::default_size
.
FileDialogConfig
is useful when you need to configure multiple FileDialog
objects with the
same or almost the same options.
§Example
use egui_file_dialog::{FileDialog, FileDialogConfig};
let config = FileDialogConfig {
initial_directory: std::path::PathBuf::from("/app/config"),
fixed_pos: Some(egui::Pos2::new(40.0, 40.0)),
show_left_panel: false,
..Default::default()
};
let file_dialog_a = FileDialog::with_config(config.clone())
.id("file-dialog-a");
let file_dialog_b = FileDialog::with_config(config.clone());
Fields§
§storage: FileDialogStorage
Persistent data of the file dialog.
labels: FileDialogLabels
The labels that the dialog uses.
keybindings: FileDialogKeyBindings
Keybindings used by the file dialog.
as_modal: bool
If the file dialog should be visible as a modal window. This means that the input outside the window is not registered.
modal_overlay_color: Color32
Color of the overlay that is displayed under the modal to prevent user interaction.
initial_directory: PathBuf
The first directory that will be opened when the dialog opens.
default_file_name: String
The default filename when opening the dialog in DialogMode::SaveFile
mode.
allow_file_overwrite: bool
If the user is allowed to select an already existing file when the dialog is
in DialogMode::SaveFile
mode.
directory_separator: String
Sets the separator of the directories when displaying a path. Currently only used when the current path is displayed in the top panel.
canonicalize_paths: bool
If the paths in the file dialog should be canonicalized before use.
err_icon: String
The icon that is used to display error messages.
warn_icon: String
The icon that is used to display warning messages.
default_file_icon: String
The default icon used to display files.
default_folder_icon: String
The default icon used to display folders.
pinned_icon: String
The icon used to display pinned paths in the left panel.
device_icon: String
The icon used to display devices in the left panel.
removable_device_icon: String
The icon used to display removable devices in the left panel.
file_filters: Vec<FileFilter>
File filters presented to the user in a dropdown.
default_file_filter: Option<String>
Name of the file filter to be selected by default.
file_icon_filters: Vec<IconFilter>
Sets custom icons for different files or folders.
Use FileDialogConfig::set_file_icon
to add a new icon to this list.
quick_accesses: Vec<QuickAccess>
Custom sections added to the left sidebar for quick access.
Use FileDialogConfig::add_quick_access
to add a new section to this list.
title: Option<String>
If set, the window title will be overwritten and set to the fixed value instead of being set dynamically.
id: Option<Id>
The ID of the window.
default_pos: Option<Pos2>
The default position of the window.
fixed_pos: Option<Pos2>
Sets the window position and prevents it from being dragged around.
default_size: Vec2
The default size of the window.
max_size: Option<Vec2>
The maximum size of the window.
min_size: Vec2
The minimum size of the window.
anchor: Option<(Align2, Vec2)>
The anchor of the window.
resizable: bool
If the window is resizable.
movable: bool
If the window is movable.
title_bar: bool
If the title bar of the window is shown.
show_top_panel: bool
If the top panel with the navigation buttons, current path display and search input should be visible.
Whether the parent folder button should be visible at the top.
Whether the back button should be visible at the top.
Whether the forward button should be visible at the top.
If the button to create a new folder should be visible at the top.
show_current_path: bool
If the current path display in the top panel should be visible.
If the button to text edit the current path should be visible.
If the menu button containing the reload button and other options should be visible.
If the reload button inside the top panel menu should be visible.
If the show hidden files and folders option inside the top panel menu should be visible.
show_search: bool
If the search input in the top panel should be visible.
show_left_panel: bool
If the sidebar with the shortcut directories such as “Home”, “Documents” etc. should be visible.
show_pinned_folders: bool
If pinned folders should be listed in the left sidebar. Disabling this will also disable the functionality to pin a folder.
show_places: bool
If the Places section in the left sidebar should be visible.
show_devices: bool
If the Devices section in the left sidebar should be visible.
show_removable_devices: bool
If the Removable Devices section in the left sidebar should be visible.
Implementations§
source§impl FileDialogConfig
impl FileDialogConfig
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 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::FileDialogConfig;
let config = FileDialogConfig::default()
.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 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::FileDialogConfig;
let config = FileDialogConfig::default()
// .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 of the file dialog.
§Examples
use egui_file_dialog::FileDialogConfig;
FileDialogConfig::default()
.add_quick_access("My App", |s| {
s.add_path("Config", "/app/config");
s.add_path("Themes", "/app/themes");
s.add_path("Languages", "/app/languages");
});
Trait Implementations§
source§impl Clone for FileDialogConfig
impl Clone for FileDialogConfig
source§fn clone(&self) -> FileDialogConfig
fn clone(&self) -> FileDialogConfig
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for FileDialogConfig
impl Debug for FileDialogConfig
Auto Trait Implementations§
impl Freeze for FileDialogConfig
impl !RefUnwindSafe for FileDialogConfig
impl Send for FileDialogConfig
impl Sync for FileDialogConfig
impl Unpin for FileDialogConfig
impl !UnwindSafe for FileDialogConfig
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,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)