dear_file_browser/custom_pane.rs
1use std::path::{Path, PathBuf};
2
3use dear_imgui_rs::Ui;
4
5use crate::core::{DialogMode, FileFilter};
6use crate::dialog_core::{ConfirmGate, EntryId};
7
8/// Context passed to a [`CustomPane`] while rendering.
9///
10/// This is a read-only view of the dialog state relevant for building
11/// IGFD-style extra widgets (per-filter options, validation, etc).
12#[derive(Clone, Copy, Debug)]
13pub struct CustomPaneCtx<'a> {
14 /// Dialog mode.
15 pub mode: DialogMode,
16 /// Current working directory.
17 pub cwd: &'a Path,
18 /// Selected entry IDs in deterministic selection order.
19 pub selected_entry_ids: &'a [EntryId],
20 /// Selected entry paths in deterministic selection order.
21 pub selected_paths: &'a [PathBuf],
22 /// Number of selected files in the current snapshot.
23 pub selected_files_count: usize,
24 /// Number of selected directories in the current snapshot.
25 pub selected_dirs_count: usize,
26 /// Current save filename buffer (SaveFile mode).
27 pub save_name: &'a str,
28 /// Active filter (None = "All files").
29 pub active_filter: Option<&'a FileFilter>,
30}
31
32/// IGFD-style custom pane that can draw extra UI and optionally block confirmation.
33///
34/// The pane is rendered inside the file dialog (typically below the file list).
35/// It returns a [`ConfirmGate`] each frame which is used to enable/disable the
36/// confirm action (button, Enter key, double-click confirm, etc).
37pub trait CustomPane {
38 /// Draw the pane contents and return the current confirm gate.
39 fn draw(&mut self, ui: &Ui, ctx: CustomPaneCtx<'_>) -> ConfirmGate;
40}