Skip to main content

FileDialogCore

Struct FileDialogCore 

Source
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: DialogMode

Mode.

§cwd: PathBuf

Current working directory.

§save_name: String

Optional filename input for SaveFile.

§click_action: ClickAction

Click behavior for directories: select or navigate.

§search: String

Search query to filter entries by substring (case-insensitive).

§sort_by: SortBy

Current sort column.

§sort_ascending: bool

Sort order flag (true = ascending).

§sort_mode: SortMode

String comparison mode used for sorting.

§dirs_first: bool

Put directories before files when sorting.

§allow_multi: bool

Allow selecting multiple files.

§max_selection: Option<usize>

Optional cap for maximum number of selected files (OpenFiles mode).

  • None => no limit
  • Some(1) => single selection
§show_hidden: bool

Show dotfiles (simple heuristic).

§double_click: bool

Double-click navigates/confirm (directories/files).

§places: Places

Places shown in the left pane (System + Bookmarks + custom groups).

§save_policy: SavePolicy

Save behavior knobs (SaveFile mode only).

Implementations§

Source§

impl FileDialogCore

Source

pub fn new(mode: DialogMode) -> Self

Creates a new dialog core for a mode.

Source

pub fn can_navigate_back(&self) -> bool

Returns whether a “back” navigation is currently possible.

Source

pub fn can_navigate_forward(&self) -> bool

Returns whether a “forward” navigation is currently possible.

Source

pub fn recent_paths(&self) -> impl Iterator<Item = &PathBuf>

Returns recently visited directories (most recent first).

Source

pub fn filters(&self) -> &[FileFilter]

Returns all configured filters.

Source

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.

Source

pub fn add_filter(&mut self, filter: impl Into<FileFilter>)

Adds a filter to the end of the filter list.

Source

pub fn extend_filters<I, F>(&mut self, filters: I)
where I: IntoIterator<Item = F>, F: Into<FileFilter>,

Adds multiple filters to the end of the filter list.

Source

pub fn clear_filters(&mut self)

Clears all filters and selects “All files”.

Source

pub fn active_filter_index(&self) -> Option<usize>

Returns the active filter index (into Self::filters) if any.

Source

pub fn active_filter(&self) -> Option<&FileFilter>

Returns the active filter (if any).

Source

pub fn set_active_filter_all(&mut self)

Explicitly select “All files” as the active filter.

Source

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.

Source

pub fn handle_event(&mut self, event: CoreEvent) -> CoreEventOutcome

Apply one core event and return host-facing outcome.

Source

pub fn invalidate_dir_cache(&mut self)

Mark the current directory snapshot as dirty so it will be refreshed on next draw.

Source

pub fn scan_policy(&self) -> ScanPolicy

Returns the currently configured scan policy.

Source

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.

Source

pub fn scan_generation(&self) -> u64

Returns the latest issued scan generation.

Source

pub fn scan_status(&self) -> &ScanStatus

Returns the current scan status.

Source

pub fn request_rescan(&mut self)

Requests a rescan on the next refresh tick.

Source

pub fn set_scan_hook<F>(&mut self, hook: F)
where F: FnMut(&mut FsEntry) -> ScanHookAction + 'static,

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.

Source

pub fn clear_scan_hook(&mut self)

Clears the scan hook and reverts to raw filesystem entries.

Calling this invalidates the directory cache.

Source

pub fn set_cwd(&mut self, cwd: PathBuf)

Sets the current directory and clears selection/focus.

Source

pub fn focus_and_select_by_id(&mut self, id: EntryId)

Selects and focuses a single entry by id.

Source

pub fn replace_selection_by_ids<I>(&mut self, ids: I)
where I: IntoIterator<Item = EntryId>,

Replace selection by entry ids.

Source

pub fn clear_selection(&mut self)

Clear current selection, focus and anchor.

Source

pub fn selected_len(&self) -> usize

Returns the number of currently selected entries.

Source

pub fn has_selection(&self) -> bool

Returns whether there is at least one selected entry.

Source

pub fn selected_entry_ids(&self) -> Vec<EntryId>

Returns selected entry ids in deterministic selection order.

Source

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.

Source

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.

Source

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

Source

pub fn focused_entry_id(&self) -> Option<EntryId>

Returns the currently focused entry id, if any.

Trait Implementations§

Source§

impl Debug for FileDialogCore

Source§

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

Formats the value using the given formatter. Read more

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more