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