egui_file_dialog

Struct FileDialog

Source
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

Source

pub fn new() -> Self

Creates a new file dialog instance with default values.

Source

pub fn with_config(config: FileDialogConfig) -> Self

Creates a new file dialog object and initializes it with the specified configuration.

Source

pub fn with_file_system(file_system: Arc<dyn FileSystem + Send + Sync>) -> Self

Uses the given file system instead of the native file system.

Source

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 opened
  • show_files - If files should also be displayed to the user in addition to directories. This is ignored if the mode is DialogMode::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());
            }
        }
    }
}
Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn set_right_panel_width(&mut self, width: f32)

Sets the width of the right panel.

Source

pub fn clear_right_panel_width(&mut self)

Clears the width of the right panel by setting it to None.

Source

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.

Source

pub fn config_mut(&mut self) -> &mut FileDialogConfig

Mutably borrow internal config.

Source

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.

Source

pub fn storage_mut(&mut self) -> &mut FileDialogStorage

Mutably borrow internal storage.

Source

pub fn keybindings(self, keybindings: FileDialogKeyBindings) -> Self

Sets the keybindings used by the file dialog.

Source

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.

Source

pub fn labels_mut(&mut self) -> &mut FileDialogLabels

Mutably borrow internal config.labels.

Source

pub const fn opening_mode(self, opening_mode: OpeningMode) -> Self

Sets which directory is loaded when opening the file dialog.

Source

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.

Source

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.

Source

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.

Source

pub fn default_file_name(self, name: &str) -> Self

Sets the default file name when opening the dialog in DialogMode::SaveFile mode.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn err_icon(self, icon: &str) -> Self

Sets the icon that is used to display errors.

Source

pub fn default_file_icon(self, icon: &str) -> Self

Sets the default icon that is used to display files.

Source

pub fn default_folder_icon(self, icon: &str) -> Self

Sets the default icon that is used to display folders.

Source

pub fn device_icon(self, icon: &str) -> Self

Sets the icon that is used to display devices in the left panel.

Source

pub fn removable_device_icon(self, icon: &str) -> Self

Sets the icon that is used to display removable devices in the left panel.

Source

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 filter
  • filter - 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"));
Source

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.

Source

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"));
Source

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");
    });
Source

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.

Source

pub fn id(self, id: impl Into<Id>) -> Self

Sets the ID of the window.

Source

pub fn default_pos(self, default_pos: impl Into<Pos2>) -> Self

Sets the default position of the window.

Source

pub fn fixed_pos(self, pos: impl Into<Pos2>) -> Self

Sets the window position and prevents it from being dragged around.

Source

pub fn default_size(self, size: impl Into<Vec2>) -> Self

Sets the default size of the window.

Source

pub fn max_size(self, max_size: impl Into<Vec2>) -> Self

Sets the maximum size of the window.

Source

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.

Source

pub fn anchor(self, align: Align2, offset: impl Into<Vec2>) -> Self

Sets the anchor of the window.

Source

pub const fn resizable(self, resizable: bool) -> Self

Sets if the window is resizable.

Source

pub const fn movable(self, movable: bool) -> Self

Sets if the window is movable.

Has no effect if an anchor is set.

Source

pub const fn title_bar(self, title_bar: bool) -> Self

Sets if the title bar of the window is shown.

Source

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.

Source

pub const fn show_parent_button(self, show_parent_button: bool) -> Self

Sets whether the parent folder button should be visible in the top panel.

Has no effect when FileDialog::show_top_panel is disabled.

Source

pub const fn show_back_button(self, show_back_button: bool) -> Self

Sets whether the back button should be visible in the top panel.

Has no effect when FileDialog::show_top_panel is disabled.

Source

pub const fn show_forward_button(self, show_forward_button: bool) -> Self

Sets whether the forward button should be visible in the top panel.

Has no effect when FileDialog::show_top_panel is disabled.

Source

pub const fn show_new_folder_button(self, show_new_folder_button: bool) -> Self

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.

Source

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.

Source

pub const fn show_path_edit_button(self, show_path_edit_button: bool) -> Self

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.

Source

pub const fn show_menu_button(self, show_menu_button: bool) -> Self

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.

Source

pub const fn show_reload_button(self, show_reload_button: bool) -> Self

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.

Source

pub const fn show_hidden_option(self, show_hidden_option: bool) -> Self

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.

Source

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.

Sets whether the search input should be visible in the top panel.

Has no effect when FileDialog::show_top_panel is disabled.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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

Source

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

Source

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.

Source

pub const fn mode(&self) -> DialogMode

Returns the mode the dialog is currently in.

Source

pub fn state(&self) -> DialogState

Returns the state the dialog is currently in.

Source

pub const fn get_window_id(&self) -> Id

Get the window Id

Source§

impl FileDialog

UI methods

Source

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.

Source

fn ui_update_modal_background(&self, ctx: &Context) -> InnerResponse<()>

Updates the main modal background of the file dialog window.

Source

fn ui_update_modals(&mut self, ui: &mut Ui)

Source

fn create_window<'a>(&self, is_open: &'a mut bool) -> Window<'a>

Creates a new egui window with the configured options.

Source

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.

Source

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.

Source

fn ui_update_nav_buttons(&mut self, ui: &mut Ui, button_size: Vec2)

Updates the navigation buttons like parent or previous directory

Source

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.

Source

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.

Source

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.

Updates the search input

Source

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
Source

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

Source

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.

Source

fn ui_update_quick_access(&mut self, ui: &mut Ui, quick_access: &QuickAccess)

Updates a custom quick access section added to the left panel.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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

Source

fn ui_update_bottom_panel(&mut self, ui: &mut Ui)

Updates the bottom panel showing the selected item and main action buttons.

Source

fn ui_update_selection_preview(&mut self, ui: &mut Ui, button_size: Vec2)

Updates the selection preview like “Selected directory: X”

Source

fn get_selection_preview_text(&self) -> String

Source

fn ui_update_file_filter_selection(&mut self, ui: &mut Ui, width: f32)

Source

fn ui_update_action_buttons(&mut self, ui: &mut Ui, button_size: Vec2)

Updates the action buttons like save, open and cancel

Source

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.

Source

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.

Source

fn ui_update_central_panel_content(&mut self, ui: &mut Ui)

Updates the contents of the currently open directory. TODO: Refactor

Source

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

Source

fn ui_update_create_directory_dialog( &mut self, ui: &mut Ui, ) -> Option<DirectoryEntry>

Source

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.

Source

fn ui_button_sized( &self, ui: &mut Ui, enabled: bool, size: Vec2, label: &str, err_tooltip: Option<&str>, ) -> bool

Helper function to add a sized button that can be enabled or disabled

Source

fn ui_update_path_context_menu( &mut self, item_response: &Response, path: &DirectoryEntry, )

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

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 widget
  • data - buffer holding the text of the input widget
Source

fn calc_char_width(ui: &Ui, char: char) -> f32

Calculates the width of a single char.

Source

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!

Source

fn truncate_filename(ui: &Ui, item: &DirectoryEntry, max_length: f32) -> String

Source§

impl FileDialog

Keybindings

Source

fn update_keybindings(&mut self, ctx: &Context)

Checks whether certain keybindings have been pressed and executes the corresponding actions.

Source

fn exec_keybinding_submit(&mut self)

Executes the action when the keybinding submit is pressed.

Source

fn exec_keybinding_cancel(&mut self)

Executes the action when the keybinding cancel is pressed.

Source

fn exec_keybinding_selection_up(&mut self)

Executes the action when the keybinding selection_up is pressed.

Source

fn exec_keybinding_selection_down(&mut self)

Executes the action when the keybinding selection_down is pressed.

Source§

impl FileDialog

Implementation

Source

fn get_selected_file_filter(&self) -> Option<&FileFilter>

Get the file filter the user currently selected.

Source

fn get_dir_content_filtered_iter(&self) -> impl Iterator<Item = &DirectoryEntry>

Gets a filtered iterator of the directory content of this object.

Source

fn open_new_folder_dialog(&mut self)

Opens the dialog to create a new folder.

Source

fn process_new_folder(&mut self, created_dir: &Path) -> DirectoryEntry

Function that processes a newly created folder.

Source

fn open_modal(&mut self, modal: Box<dyn FileDialogModal + Send + Sync>)

Opens a new modal window.

Source

fn exec_modal_action(&mut self, action: ModalAction)

Executes the given modal action.

Source

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.

Source

fn pin_path(&mut self, path: DirectoryEntry)

Pins a path to the left sidebar.

Source

fn unpin_path(&mut self, path: &DirectoryEntry)

Unpins a path from the left sidebar.

Source

fn is_pinned(&self, path: &DirectoryEntry) -> bool

Checks if the path is pinned to the left sidebar.

Source

fn is_primary_selected(&self, item: &DirectoryEntry) -> bool

Source

fn reset(&mut self)

Resets the dialog to use default values. Configuration variables are retained.

Source

fn refresh(&mut self)

Refreshes the dialog. Including the user directories, system disks and currently open directory.

Source

fn submit(&mut self)

Submits the current selection and tries to finish the dialog, if the selection is valid.

Source

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.

Source

fn cancel(&mut self)

Cancels the dialog.

Source

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
Source

fn current_directory(&self) -> Option<&Path>

Gets the currently open directory.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

fn select_first_visible_item(&mut self)

Tries to select the first visible item inside directory_content.

Source

fn select_last_visible_item(&mut self)

Tries to select the last visible item inside directory_content.

Source

fn open_path_edit(&mut self)

Opens the text field in the top panel to text edit the current path.

Source

fn submit_path_edit(&mut self)

Loads the directory from the path text edit.

Source

fn close_path_edit(&mut self)

Closes the text field at the top to edit the current path without loading the entered directory.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

fn load_directory_content(&mut self, path: &Path)

Loads the directory content of the given path.

Trait Implementations§

Source§

impl Debug for FileDialog

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for FileDialog

Source§

fn default() -> Self

Creates a new file dialog instance with default values.

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

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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