Struct egui_file_dialog::FileDialogConfig
source · pub struct FileDialogConfig {Show 36 fields
pub labels: FileDialogLabels,
pub initial_directory: PathBuf,
pub default_file_name: String,
pub directory_separator: String,
pub canonicalize_paths: bool,
pub err_icon: String,
pub default_file_icon: String,
pub default_folder_icon: String,
pub device_icon: String,
pub removable_device_icon: 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_reload_button: bool,
pub show_search: bool,
pub show_left_panel: 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
or FileDialog::overwrite_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§
§labels: FileDialogLabels
The labels that the dialog uses.
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.
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.
default_file_icon: String
The default icon used to display files.
default_folder_icon: String
The default icon used to display folders.
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_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 reload button in the top panel 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_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 set_file_icon(
self,
icon: &str,
filter: Arc<dyn Fn(&Path) -> bool>
) -> Self
pub fn set_file_icon( self, icon: &str, filter: Arc<dyn Fn(&Path) -> bool> ) -> 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 more