FileBrowserState

Struct FileBrowserState 

Source
pub struct FileBrowserState {
Show 26 fields pub visible: bool, pub mode: DialogMode, pub cwd: PathBuf, pub selected: Vec<String>, pub save_name: String, pub filters: Vec<FileFilter>, pub active_filter: Option<usize>, pub click_action: ClickAction, pub search: String, pub sort_by: SortBy, pub sort_ascending: bool, pub layout: LayoutStyle, pub allow_multi: bool, pub show_hidden: bool, pub double_click: bool, pub path_edit: bool, pub path_edit_buffer: String, pub focus_path_edit_next: bool, pub focus_search_next: bool, pub result: Option<Result<Selection, FileDialogError>>, pub ui_error: Option<String>, pub breadcrumbs_max_segments: usize, pub dirs_first: bool, pub empty_hint_enabled: bool, pub empty_hint_color: [f32; 4], pub empty_hint_static_message: Option<String>,
}
Expand description

State for in-UI file browser

Fields§

§visible: bool

Whether to draw the browser (show/hide)

§mode: DialogMode

Mode

§cwd: PathBuf

Current working directory

§selected: Vec<String>

Selected entry names (relative to cwd)

§save_name: String

Optional filename input for SaveFile

§filters: Vec<FileFilter>

Filters (lower-case extensions)

§active_filter: Option<usize>

Active filter index (None = All)

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

§layout: LayoutStyle

Layout style for the browser UI

§allow_multi: bool

Allow selecting multiple files

§show_hidden: bool

Show dotfiles (simple heuristic)

§double_click: bool

Double-click navigates/confirm (directories/files)

§path_edit: bool

Path edit mode (Ctrl+L)

§path_edit_buffer: String

Path edit buffer

§focus_path_edit_next: bool

Focus path edit on next frame

§focus_search_next: bool

Focus search on next frame (Ctrl+F)

§result: Option<Result<Selection, FileDialogError>>

Result emitted when the user confirms or cancels

§ui_error: Option<String>

Error string to display in UI (non-fatal)

§breadcrumbs_max_segments: usize

Max breadcrumb segments to display (compress with ellipsis when exceeded)

§dirs_first: bool

Put directories before files when sorting

§empty_hint_enabled: bool

Show a hint row when no entries match filters/search

§empty_hint_color: [f32; 4]

RGBA color of the empty hint text

§empty_hint_static_message: Option<String>

Custom static hint message when entries list is empty; if None, a default message is built

Implementations§

Source§

impl FileBrowserState

Source

pub fn new(mode: DialogMode) -> Self

Create a new state for a mode.

Examples

use dear_file_browser::{DialogMode, FileBrowserState, FileDialogExt, FileFilter};
let mut state = FileBrowserState::new(DialogMode::OpenFiles);
// Optional configuration
state.dirs_first = true;
state.double_click = true;            // dbl-click file = confirm; dbl-click dir = enter
state.click_action = dear_file_browser::ClickAction::Select; // or Navigate
state.breadcrumbs_max_segments = 6;   // compress deep paths
// Filters are case-insensitive and extension names shouldn't include dots
state.set_filters(vec![FileFilter::from(("Images", &["png", "jpg", "jpeg"]))]);

ui.window("File Browser").build(|| {
    if let Some(res) = ui.file_browser().show(&mut state) {
        match res {
            Ok(sel) => {
                for p in sel.paths { eprintln!("{:?}", p); }
            }
            Err(e) => eprintln!("dialog cancelled or error: {e}"),
        }
    }
});
Source

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

Configure filters

Trait Implementations§

Source§

impl Debug for FileBrowserState

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