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: boolWhether to draw the browser (show/hide)
mode: DialogModeMode
cwd: PathBufCurrent working directory
selected: Vec<String>Selected entry names (relative to cwd)
save_name: StringOptional filename input for SaveFile
filters: Vec<FileFilter>Filters (lower-case extensions)
active_filter: Option<usize>Active filter index (None = All)
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)
layout: LayoutStyleLayout style for the browser UI
allow_multi: boolAllow selecting multiple files
Show dotfiles (simple heuristic)
double_click: boolDouble-click navigates/confirm (directories/files)
path_edit: boolPath edit mode (Ctrl+L)
path_edit_buffer: StringPath edit buffer
focus_path_edit_next: boolFocus path edit on next frame
focus_search_next: boolFocus 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)
Max breadcrumb segments to display (compress with ellipsis when exceeded)
dirs_first: boolPut directories before files when sorting
empty_hint_enabled: boolShow 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
impl FileBrowserState
Sourcepub fn new(mode: DialogMode) -> Self
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}"),
}
}
});Sourcepub fn set_filters<I, F>(&mut self, filters: I)
pub fn set_filters<I, F>(&mut self, filters: I)
Configure filters
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FileBrowserState
impl !RefUnwindSafe for FileBrowserState
impl Send for FileBrowserState
impl Sync for FileBrowserState
impl Unpin for FileBrowserState
impl !UnwindSafe for FileBrowserState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.