egui_file_dialog/modals/mod.rs
1use std::path::PathBuf;
2
3use crate::FileDialogConfig;
4
5mod overwrite_file_modal;
6pub use overwrite_file_modal::OverwriteFileModal;
7
8/// Contains actions that are executed by the file dialog when closing a modal.
9#[derive(Clone)]
10pub enum ModalAction {
11 /// If no action should be executed.
12 None,
13 /// If the file dialog should save the specified path.
14 /// Should only be used if the `FileDialog` is in `FileDialogMode::SaveFile` mode.
15 SaveFile(PathBuf),
16}
17
18#[derive(Clone)]
19pub enum ModalState {
20 /// If the modal is currently open and still waiting for user input
21 Pending,
22 /// If the modal should be closed in the next frame
23 Close(ModalAction),
24}
25
26pub trait FileDialogModal {
27 /// Main update method of the modal.
28 /// Should be called every time the modal should be visible.
29 fn update(&mut self, config: &FileDialogConfig, ui: &mut egui::Ui) -> ModalState;
30
31 /// Updates the configured keybindings for the modal window.
32 fn update_keybindings(&mut self, _config: &FileDialogConfig, _ctx: &egui::Context) {}
33}