pub struct FileDialogCore {Show 15 fields
pub mode: DialogMode,
pub cwd: PathBuf,
pub save_name: String,
pub click_action: ClickAction,
pub search: String,
pub sort_by: SortBy,
pub sort_ascending: bool,
pub sort_mode: SortMode,
pub dirs_first: bool,
pub allow_multi: bool,
pub max_selection: Option<usize>,
pub show_hidden: bool,
pub double_click: bool,
pub places: Places,
pub save_policy: SavePolicy,
/* private fields */
}Expand description
Core state machine for the ImGui-embedded file dialog.
This type contains only domain state and logic (selection, navigation, filtering, sorting). It does not depend on Dear ImGui types and can be unit tested by driving its methods.
Fields§
§mode: DialogModeMode.
cwd: PathBufCurrent working directory.
save_name: StringOptional filename input for SaveFile.
click_action: ClickActionClick behavior for directories: select or navigate.
search: StringSearch query to filter entries by substring (case-insensitive).
sort_by: SortByCurrent sort column.
sort_ascending: boolSort order flag (true = ascending).
sort_mode: SortModeString comparison mode used for sorting.
dirs_first: boolPut directories before files when sorting.
allow_multi: boolAllow selecting multiple files.
max_selection: Option<usize>Optional cap for maximum number of selected files (OpenFiles mode).
None=> no limitSome(1)=> single selection
Show dotfiles (simple heuristic).
double_click: boolDouble-click navigates/confirm (directories/files).
places: PlacesPlaces shown in the left pane (System + Bookmarks + custom groups).
save_policy: SavePolicySave behavior knobs (SaveFile mode only).
Implementations§
Source§impl FileDialogCore
impl FileDialogCore
Sourcepub fn new(mode: DialogMode) -> Self
pub fn new(mode: DialogMode) -> Self
Creates a new dialog core for a mode.
Returns whether a “back” navigation is currently possible.
Returns whether a “forward” navigation is currently possible.
Sourcepub fn recent_paths(&self) -> impl Iterator<Item = &PathBuf>
pub fn recent_paths(&self) -> impl Iterator<Item = &PathBuf>
Returns recently visited directories (most recent first).
Sourcepub fn filters(&self) -> &[FileFilter]
pub fn filters(&self) -> &[FileFilter]
Returns all configured filters.
Sourcepub fn set_filters(&mut self, filters: Vec<FileFilter>)
pub fn set_filters(&mut self, filters: Vec<FileFilter>)
Replaces the current filter list and resets selection to “auto first filter”.
Use Self::set_active_filter_all to explicitly select “All files” afterwards.
Sourcepub fn add_filter(&mut self, filter: impl Into<FileFilter>)
pub fn add_filter(&mut self, filter: impl Into<FileFilter>)
Adds a filter to the end of the filter list.
Sourcepub fn extend_filters<I, F>(&mut self, filters: I)
pub fn extend_filters<I, F>(&mut self, filters: I)
Adds multiple filters to the end of the filter list.
Sourcepub fn clear_filters(&mut self)
pub fn clear_filters(&mut self)
Clears all filters and selects “All files”.
Sourcepub fn active_filter_index(&self) -> Option<usize>
pub fn active_filter_index(&self) -> Option<usize>
Returns the active filter index (into Self::filters) if any.
Sourcepub fn active_filter(&self) -> Option<&FileFilter>
pub fn active_filter(&self) -> Option<&FileFilter>
Returns the active filter (if any).
Sourcepub fn set_active_filter_all(&mut self)
pub fn set_active_filter_all(&mut self)
Explicitly select “All files” as the active filter.
Sourcepub fn set_active_filter_index(&mut self, index: usize) -> bool
pub fn set_active_filter_index(&mut self, index: usize) -> bool
Explicitly select a filter by index.
Returns false if the index is out of bounds.
Sourcepub fn handle_event(&mut self, event: CoreEvent) -> CoreEventOutcome
pub fn handle_event(&mut self, event: CoreEvent) -> CoreEventOutcome
Apply one core event and return host-facing outcome.
Sourcepub fn invalidate_dir_cache(&mut self)
pub fn invalidate_dir_cache(&mut self)
Mark the current directory snapshot as dirty so it will be refreshed on next draw.
Sourcepub fn scan_policy(&self) -> ScanPolicy
pub fn scan_policy(&self) -> ScanPolicy
Returns the currently configured scan policy.
Sourcepub fn set_scan_policy(&mut self, policy: ScanPolicy)
pub fn set_scan_policy(&mut self, policy: ScanPolicy)
Sets scan policy for future directory refreshes.
Values are normalized to avoid invalid batch sizes. Calling this invalidates the directory cache when policy changes.
Sourcepub fn scan_generation(&self) -> u64
pub fn scan_generation(&self) -> u64
Returns the latest issued scan generation.
Sourcepub fn scan_status(&self) -> &ScanStatus
pub fn scan_status(&self) -> &ScanStatus
Returns the current scan status.
Sourcepub fn request_rescan(&mut self)
pub fn request_rescan(&mut self)
Requests a rescan on the next refresh tick.
Sourcepub fn set_scan_hook<F>(&mut self, hook: F)
pub fn set_scan_hook<F>(&mut self, hook: F)
Installs a scan hook that can mutate or drop filesystem entries.
The hook runs before filtering/sorting and before snapshot ids are built. Calling this invalidates the directory cache.
Sourcepub fn clear_scan_hook(&mut self)
pub fn clear_scan_hook(&mut self)
Clears the scan hook and reverts to raw filesystem entries.
Calling this invalidates the directory cache.
Sourcepub fn focus_and_select_by_id(&mut self, id: EntryId)
pub fn focus_and_select_by_id(&mut self, id: EntryId)
Selects and focuses a single entry by id.
Sourcepub fn replace_selection_by_ids<I>(&mut self, ids: I)where
I: IntoIterator<Item = EntryId>,
pub fn replace_selection_by_ids<I>(&mut self, ids: I)where
I: IntoIterator<Item = EntryId>,
Replace selection by entry ids.
Sourcepub fn clear_selection(&mut self)
pub fn clear_selection(&mut self)
Clear current selection, focus and anchor.
Sourcepub fn selected_len(&self) -> usize
pub fn selected_len(&self) -> usize
Returns the number of currently selected entries.
Sourcepub fn has_selection(&self) -> bool
pub fn has_selection(&self) -> bool
Returns whether there is at least one selected entry.
Sourcepub fn selected_entry_ids(&self) -> Vec<EntryId>
pub fn selected_entry_ids(&self) -> Vec<EntryId>
Returns selected entry ids in deterministic selection order.
Sourcepub fn selected_entry_paths(&self) -> Vec<PathBuf>
pub fn selected_entry_paths(&self) -> Vec<PathBuf>
Resolves selected entry paths from ids in the current snapshot.
Any ids that are not currently resolvable are skipped.
Sourcepub fn selected_entry_counts(&self) -> (usize, usize)
pub fn selected_entry_counts(&self) -> (usize, usize)
Counts selected files and directories in the current snapshot.
Returns (files, dirs). Any ids that are not currently resolvable are skipped.
Sourcepub fn entry_path_by_id(&self, id: EntryId) -> Option<&Path>
pub fn entry_path_by_id(&self, id: EntryId) -> Option<&Path>
Resolves an entry path from an entry id in the current snapshot.
Returns None when the id is not currently resolvable (for example,
before the next rescan after create/rename/paste).
Sourcepub fn focused_entry_id(&self) -> Option<EntryId>
pub fn focused_entry_id(&self) -> Option<EntryId>
Returns the currently focused entry id, if any.