diff --git a/Cargo.toml b/Cargo.toml
index ab568fb5..67e4fea6 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,13 +1,3 @@
-[workspace]
-members = ["examples/*"]
-
-[workspace.dependencies]
-eframe = { version = "0.29.1", default-features = false, features = [
- "glow",
- "persistence",
-] }
-egui-file-dialog = { path = "." }
-
[package]
name = "egui-file-dialog"
description = "An easy-to-use file dialog for egui"
@@ -23,18 +13,21 @@ license = "MIT"
[dependencies]
egui = { version = "0.29.1", default-features = false }
-
-# Used to fetch user folders
+# fetch user folders
directories = "5.0"
-
-# Used to fetch disks
+# canonicalize paths
+dunce = "1.0.5"
+# fetch disks
sysinfo = { version = "0.32", default-features = false, features = ["disk"] }
-
-# Used for persistent storage
+# persistent storage
serde = { version = "1", features = ["derive"], optional = true }
-# Used to canonicalize paths
-dunce = "1.0.5"
+[dev-dependencies]
+eframe = { version = "0.29.1", default-features = false, features = [
+ "glow",
+ "persistence",
+] }
+egui-file-dialog = { path = "." }
[features]
default = ["serde", "default_fonts"]
diff --git a/README.md b/README.md
index 98d11cb1..73716623 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,5 @@
# egui-file-dialog
+
[![Latest version](https://img.shields.io/crates/v/egui-file-dialog.svg)](https://crates.io/crates/egui-file-dialog)
[![Documentation](https://img.shields.io/docsrs/egui-file-dialog)](https://docs.rs/egui-file-dialog)
[![Dependency status](https://deps.rs/repo/github/fluxxcode/egui-file-dialog/status.svg)](https://deps.rs/repo/github/fluxxcode/egui-file-dialog)
@@ -27,6 +28,7 @@ The file dialog is intended for use by desktop applications, allowing the use of
The latest changes included in the next release can be found in the [CHANGELOG.md](https://github.com/fluxxcode/egui-file-dialog/blob/develop/CHANGELOG.md) file on the develop branch.
## Features
+
- Select a file or a directory
- Save a file (Prompt user for a destination path)
- Dialog to ask the user if the existing file should be overwritten
@@ -51,11 +53,13 @@ The latest changes included in the next release can be found in the [CHANGELOG.m
- Add a right panel with custom UI using
## Example
+
Detailed examples that can be run can be found in the [examples](https://github.com/fluxxcode/egui-file-dialog/tree/develop/examples) folder.
The following example shows the basic use of the file dialog with [eframe](https://github.com/emilk/egui/tree/master/crates/eframe) to select a file.
Cargo.toml:
+
```toml
[dependencies]
eframe = "0.29.1"
@@ -63,6 +67,7 @@ egui-file-dialog = "0.7.0"
```
main.rs:
+
```rust
use std::path::PathBuf;
@@ -114,25 +119,33 @@ fn main() -> eframe::Result<()> {
}
```
+## Examples
+
+The examples can be found in the [examples](examples) folder.
+Further descriptions can be found in the [EXAMPLES.](examples/README.md) file.
+
## Keybindings
+
Keybindings can be used in the file dialog for easier navigation. All keybindings can be configured from the backend with `FileDialogKeyBindings` and `FileDialog::keybindings`. \
The following table lists all available keybindings and their default values.
-| Name | Description | Default |
-| --- | --- | --- |
-| submit | Submit the current action or open the currently selected folder | `Enter` |
-| cancel | Cancel the current action | `Escape` |
-| parent | Open the parent directory | `ALT` + `↑` |
-| back | Go back | `Mouse button 1`
`ALT` + `←`
`Backspace` |
-| forward | Go forward | `Mouse button 2`
`ALT` + `→` |
-| reload | Reload the file dialog data and the currently open directory | `F5` |
-| new_folder | Open the dialog to create a new folder | `CTRL` + `N` on linux/windows or `CMD` + `N` on macOS |
-| edit_path | Text edit the current path | `/` |
-| home_edit_path | Open the home directory and start text editing the path | `~` |
-| selection_up | Move the selection one item up | `↑` |
-| selection_down | Move the selection one item down | `↓` |
-| select_all | Select every item in the directory when using the file dialog to select multiple files and folders | `CTRL` + `A` on linux/windows or `CMD` + `A` on macOS |
+
+| Name | Description | Default |
+| -------------- | -------------------------------------------------------------------------------------------------- | ----------------------------------------------------- |
+| submit | Submit the current action or open the currently selected folder | `Enter` |
+| cancel | Cancel the current action | `Escape` |
+| parent | Open the parent directory | `ALT` + `↑` |
+| back | Go back | `Mouse button 1`
`ALT` + `←`
`Backspace` |
+| forward | Go forward | `Mouse button 2`
`ALT` + `→` |
+| reload | Reload the file dialog data and the currently open directory | `F5` |
+| new_folder | Open the dialog to create a new folder | `CTRL` + `N` on linux/windows or `CMD` + `N` on macOS |
+| edit_path | Text edit the current path | `/` |
+| home_edit_path | Open the home directory and start text editing the path | `~` |
+| selection_up | Move the selection one item up | `↑` |
+| selection_down | Move the selection one item down | `↓` |
+| select_all | Select every item in the directory when using the file dialog to select multiple files and folders | `CTRL` + `A` on linux/windows or `CMD` + `A` on macOS |
## Customization
+
Many things can be customized so that the dialog can be used in different situations. \
A few highlights of the customization are listed below. For all possible customization options, see the documentation on [docs.rs](https://docs.rs/egui-file-dialog/latest/egui_file_dialog/struct.FileDialog.html).
@@ -146,6 +159,7 @@ Since the dialog uses the egui style to look like the rest of the application, t
The following example shows how a single file dialog can be customized. \
If you need to configure multiple file dialog objects with the same or almost the same options, it is a good idea to use `FileDialogConfig` and `FileDialog::with_config` (See `FileDialogConfig` on [docs.rs](https://docs.rs/egui-file-dialog/latest/egui_file_dialog/struct.FileDialogConfig.html)).
+
```rust
use std::path::PathBuf;
use std::sync::Arc;
@@ -186,12 +200,14 @@ FileDialog::new()
Arc::new(|p| p.extension().unwrap_or_default() == "rs"),
);
```
+
With the options the dialog then looks like this:
If you want to display your own information in the file dialog, you can update the file dialog with
`update_with_right_panel_ui` instead of `update`. This allows e.g. to display custom image previews or further
information about the selected item. See [custom-right-panel](https://github.com/fluxxcode/egui-file-dialog/tree/develop/examples/custom-right-panel) for the full example.
+
```rust
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
// Update the dialog with a custom right panel
@@ -202,9 +218,11 @@ fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
});
}
```
+
## Multilingual support
+
For desktop applications it is often necessary to offer different languages. While the dialog currently only offers English labels by default, the labels are fully customizable. This makes it possible to adapt the labels to different languages.
The following example shows how the labels can be changed to display the file dialog in English or German. \
@@ -243,6 +261,7 @@ fn update_labels(language: &Language, file_dialog: &mut FileDialog) {
```
## Persistent data
+
The file dialog currently requires the following persistent data to be stored across multiple file dialog objects:
- Folders the user pinned to the left sidebar (`FileDialog::show_pinned_folders`)
@@ -292,3 +311,7 @@ impl eframe::App for MyApp {
}
}
```
+
+## Development
+
+Feel free to contribute to the project. If you have any questions or need help, please open an issue.
diff --git a/examples/README.md b/examples/README.md
new file mode 100644
index 00000000..f6ae54d1
--- /dev/null
+++ b/examples/README.md
@@ -0,0 +1,78 @@
+# Examples
+
+## Multi Selection
+
+Example showing how to select multiple files and folders at once.
+
+```shell
+cargo run --example multi_selection
+```
+
+![Screenshot](../media/examples/multi-selection.png)
+
+## Multilingual
+
+Example that shows how the dialog can be displayed and used in different languages.
+
+```shell
+cargo run --example multilingual
+```
+
+![Screenshot](../media/examples/multilingual.png)
+
+## Multiple Actions
+
+This example shows how you can query multiple files from the user in one view.
+
+```shell
+cargo run --example multiple_actions
+```
+
+![Screenshot](../media/examples/multiple_actions.png)
+
+## Persistence
+
+This example uses eframe to show how the persistent data of the file dialog can be saved. \
+The example uses the `serde` feature to serialize the required data.
+
+```shell
+cargo run --example persistence
+```
+
+## Pick Directory
+
+Example showing how to select a directory using the file dialog.
+
+```shell
+cargo run --example pick_directory
+```
+
+![Screenshot](../media/examples/pick_directory.png)
+
+## Pick File
+
+Example showing how to select a file using the file dialog.
+
+```shell
+cargo run --example pick_file
+```
+
+![Screenshot](../media/examples/pick_file.png)
+
+## Sandbox
+
+Sandbox app used during development of the file dialog.
+
+```shell
+cargo run --example sandbox
+```
+
+## Save File
+
+Example showing how to save a file using the file dialog.
+
+```shell
+cargo run --example save_file
+```
+
+![Screenshot](../media/examples/save_file.png)
diff --git a/examples/custom-right-panel/src/main.rs b/examples/custom-right-panel.rs
similarity index 93%
rename from examples/custom-right-panel/src/main.rs
rename to examples/custom-right-panel.rs
index b041b801..8eddd57e 100644
--- a/examples/custom-right-panel/src/main.rs
+++ b/examples/custom-right-panel.rs
@@ -31,15 +31,15 @@ impl eframe::App for MyApp {
if let Some(items) = &self.picked_items {
for item in items {
- ui.label(format!("{:?}", item));
+ ui.label(format!("{item:?}"));
}
} else {
ui.label("None");
}
self.file_dialog
- .update_with_right_panel_ui(ctx, &mut |ui, dia| match dia.mode() {
- DialogMode::SelectMultiple => {
+ .update_with_right_panel_ui(ctx, &mut |ui, dia| {
+ if dia.mode() == DialogMode::SelectMultiple {
ui.heading("Selected items");
ui.separator();
egui::ScrollArea::vertical()
@@ -50,8 +50,7 @@ impl eframe::App for MyApp {
ui.separator();
}
});
- }
- _ => {
+ } else {
ui.heading("Active item");
ui.small(format!("{:#?}", dia.active_entry()));
}
diff --git a/examples/custom-right-panel/Cargo.toml b/examples/custom-right-panel/Cargo.toml
deleted file mode 100644
index e518d1e8..00000000
--- a/examples/custom-right-panel/Cargo.toml
+++ /dev/null
@@ -1,10 +0,0 @@
-[package]
-name = "custom-right-panel"
-version = "0.1.0"
-edition = "2021"
-
-# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
-
-[dependencies]
-eframe.workspace = true
-egui-file-dialog.workspace = true
diff --git a/examples/multi_selection/src/main.rs b/examples/multi-selection.rs
similarity index 95%
rename from examples/multi_selection/src/main.rs
rename to examples/multi-selection.rs
index ba13be33..f5f5144c 100644
--- a/examples/multi_selection/src/main.rs
+++ b/examples/multi-selection.rs
@@ -28,7 +28,7 @@ impl eframe::App for MyApp {
if let Some(items) = &self.picked_items {
for item in items {
- ui.label(format!("{:?}", item));
+ ui.label(format!("{item:?}"));
}
} else {
ui.label("None");
diff --git a/examples/multi_selection/Cargo.toml b/examples/multi_selection/Cargo.toml
deleted file mode 100644
index 1e721add..00000000
--- a/examples/multi_selection/Cargo.toml
+++ /dev/null
@@ -1,10 +0,0 @@
-[package]
-name = "multi_selection"
-version = "0.1.0"
-edition = "2021"
-
-# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
-
-[dependencies]
-eframe.workspace = true
-egui-file-dialog.workspace = true
diff --git a/examples/multi_selection/README.md b/examples/multi_selection/README.md
deleted file mode 100644
index acec7f0f..00000000
--- a/examples/multi_selection/README.md
+++ /dev/null
@@ -1,7 +0,0 @@
-Example showing how to select multiple files and folders at once.
-
-```
-cargo run -p multi_selection
-```
-
-![](screenshot.png)
diff --git a/examples/multilingual/src/main.rs b/examples/multilingual.rs
similarity index 100%
rename from examples/multilingual/src/main.rs
rename to examples/multilingual.rs
diff --git a/examples/multilingual/Cargo.toml b/examples/multilingual/Cargo.toml
deleted file mode 100644
index 7e494fc9..00000000
--- a/examples/multilingual/Cargo.toml
+++ /dev/null
@@ -1,10 +0,0 @@
-[package]
-name = "multilingual"
-version = "0.1.0"
-edition = "2021"
-
-# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
-
-[dependencies]
-eframe.workspace = true
-egui-file-dialog.workspace = true
diff --git a/examples/multilingual/README.md b/examples/multilingual/README.md
deleted file mode 100644
index 492aedd3..00000000
--- a/examples/multilingual/README.md
+++ /dev/null
@@ -1,7 +0,0 @@
-Example that shows how the dialog can be displayed and used in different languages.
-
-```
-cargo run -p multilingual
-```
-
-![](screenshot.png)
diff --git a/examples/multiple_actions/src/main.rs b/examples/multiple-actions.rs
similarity index 100%
rename from examples/multiple_actions/src/main.rs
rename to examples/multiple-actions.rs
diff --git a/examples/multiple_actions/Cargo.toml b/examples/multiple_actions/Cargo.toml
deleted file mode 100644
index 29f6f5ad..00000000
--- a/examples/multiple_actions/Cargo.toml
+++ /dev/null
@@ -1,10 +0,0 @@
-[package]
-name = "multiple_actions"
-version = "0.1.0"
-edition = "2021"
-
-# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
-
-[dependencies]
-eframe.workspace = true
-egui-file-dialog.workspace = true
diff --git a/examples/multiple_actions/README.md b/examples/multiple_actions/README.md
deleted file mode 100644
index fd4e2ed2..00000000
--- a/examples/multiple_actions/README.md
+++ /dev/null
@@ -1,7 +0,0 @@
-This example shows how you can query multiple files from the user in one view.
-
-```
-cargo run -p multiple_actions
-```
-
-![](screenshot.png)
diff --git a/examples/persistence/src/main.rs b/examples/persistence.rs
similarity index 98%
rename from examples/persistence/src/main.rs
rename to examples/persistence.rs
index 92fedbd8..0bbef787 100644
--- a/examples/persistence/src/main.rs
+++ b/examples/persistence.rs
@@ -16,7 +16,7 @@ impl MyApp {
// Alternatively, you can also use the `FileDialog::storage` builder method.
if let Some(storage) = cc.storage {
*file_dialog.storage_mut() =
- eframe::get_value(storage, "file_dialog_storage").unwrap_or_default()
+ eframe::get_value(storage, "file_dialog_storage").unwrap_or_default();
}
Self {
diff --git a/examples/persistence/Cargo.toml b/examples/persistence/Cargo.toml
deleted file mode 100644
index a1b0766f..00000000
--- a/examples/persistence/Cargo.toml
+++ /dev/null
@@ -1,10 +0,0 @@
-[package]
-name = "persistence"
-version = "0.1.0"
-edition = "2021"
-
-# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
-
-[dependencies]
-eframe.workspace = true
-egui-file-dialog.workspace = true
diff --git a/examples/persistence/README.md b/examples/persistence/README.md
deleted file mode 100644
index 5bfdc199..00000000
--- a/examples/persistence/README.md
+++ /dev/null
@@ -1,6 +0,0 @@
-This example uses eframe to show how the persistent data of the file dialog can be saved. \
-The example uses the `serde` feature to serialize the required data.
-
-```
-cargo run -p persistence
-```
diff --git a/examples/pick_directory/src/main.rs b/examples/pick_directory.rs
similarity index 100%
rename from examples/pick_directory/src/main.rs
rename to examples/pick_directory.rs
diff --git a/examples/pick_directory/Cargo.toml b/examples/pick_directory/Cargo.toml
deleted file mode 100644
index 8f241224..00000000
--- a/examples/pick_directory/Cargo.toml
+++ /dev/null
@@ -1,10 +0,0 @@
-[package]
-name = "pick_directory"
-version = "0.1.0"
-edition = "2021"
-
-# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
-
-[dependencies]
-eframe.workspace = true
-egui-file-dialog.workspace = true
diff --git a/examples/pick_directory/README.md b/examples/pick_directory/README.md
deleted file mode 100644
index a53d2051..00000000
--- a/examples/pick_directory/README.md
+++ /dev/null
@@ -1,7 +0,0 @@
-Example showing how to select a directory using the file dialog.
-
-```
-cargo run -p select_directory
-```
-
-![](screenshot.png)
diff --git a/examples/pick_file/src/main.rs b/examples/pick_file.rs
similarity index 100%
rename from examples/pick_file/src/main.rs
rename to examples/pick_file.rs
diff --git a/examples/pick_file/Cargo.toml b/examples/pick_file/Cargo.toml
deleted file mode 100644
index 75fc9cd5..00000000
--- a/examples/pick_file/Cargo.toml
+++ /dev/null
@@ -1,10 +0,0 @@
-[package]
-name = "pick_file"
-version = "0.1.0"
-edition = "2021"
-
-# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
-
-[dependencies]
-eframe.workspace = true
-egui-file-dialog.workspace = true
diff --git a/examples/pick_file/README.md b/examples/pick_file/README.md
deleted file mode 100644
index 9b56fc1d..00000000
--- a/examples/pick_file/README.md
+++ /dev/null
@@ -1,7 +0,0 @@
-Example showing how to select a file using the file dialog.
-
-```
-cargo run -p select_file
-```
-
-![](screenshot.png)
diff --git a/examples/sandbox/src/main.rs b/examples/sandbox.rs
similarity index 96%
rename from examples/sandbox/src/main.rs
rename to examples/sandbox.rs
index ac18e77e..ac29bfdf 100644
--- a/examples/sandbox/src/main.rs
+++ b/examples/sandbox.rs
@@ -36,7 +36,7 @@ impl MyApp {
if let Some(storage) = cc.storage {
*file_dialog.storage_mut() =
- eframe::get_value(storage, "file_dialog_storage").unwrap_or_default()
+ eframe::get_value(storage, "file_dialog_storage").unwrap_or_default();
}
Self {
@@ -85,7 +85,7 @@ impl eframe::App for MyApp {
if let Some(items) = &self.picked_multiple {
for item in items {
- ui.label(format!("{:?}", item));
+ ui.label(format!("{item:?}"));
}
} else {
ui.label("None");
@@ -105,7 +105,7 @@ impl eframe::App for MyApp {
DialogMode::SelectDirectory => self.picked_directory = Some(path),
DialogMode::SelectFile => self.picked_file = Some(path),
DialogMode::SaveFile => self.saved_file = Some(path),
- _ => {}
+ DialogMode::SelectMultiple => {}
}
}
diff --git a/examples/sandbox/Cargo.toml b/examples/sandbox/Cargo.toml
deleted file mode 100644
index b3a3d498..00000000
--- a/examples/sandbox/Cargo.toml
+++ /dev/null
@@ -1,10 +0,0 @@
-[package]
-name = "sandbox"
-version = "0.1.0"
-edition = "2021"
-
-# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
-
-[dependencies]
-eframe = { workspace = true, features = ["serde", "ron"] }
-egui-file-dialog.workspace = true
diff --git a/examples/sandbox/README.md b/examples/sandbox/README.md
deleted file mode 100644
index 0a76cb61..00000000
--- a/examples/sandbox/README.md
+++ /dev/null
@@ -1,5 +0,0 @@
-Sandbox app used during development of the file exporter.
-
-```
-cargo run -p sandbox
-```
diff --git a/examples/save_file/src/main.rs b/examples/save_file.rs
similarity index 100%
rename from examples/save_file/src/main.rs
rename to examples/save_file.rs
diff --git a/examples/save_file/Cargo.toml b/examples/save_file/Cargo.toml
deleted file mode 100644
index f3277f79..00000000
--- a/examples/save_file/Cargo.toml
+++ /dev/null
@@ -1,10 +0,0 @@
-[package]
-name = "save_file"
-version = "0.1.0"
-edition = "2021"
-
-# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
-
-[dependencies]
-eframe.workspace = true
-egui-file-dialog.workspace = true
diff --git a/examples/save_file/README.md b/examples/save_file/README.md
deleted file mode 100644
index 266c5fa9..00000000
--- a/examples/save_file/README.md
+++ /dev/null
@@ -1,7 +0,0 @@
-Example showing how to save a file using the file dialog.
-
-```
-cargo run -p save_file
-```
-
-![](screenshot.png)
diff --git a/examples/multi_selection/screenshot.png b/media/examples/multi-selection.png
similarity index 100%
rename from examples/multi_selection/screenshot.png
rename to media/examples/multi-selection.png
diff --git a/examples/multilingual/screenshot.png b/media/examples/multilingual.png
similarity index 100%
rename from examples/multilingual/screenshot.png
rename to media/examples/multilingual.png
diff --git a/examples/multiple_actions/screenshot.png b/media/examples/multiple_actions.png
similarity index 100%
rename from examples/multiple_actions/screenshot.png
rename to media/examples/multiple_actions.png
diff --git a/examples/pick_directory/screenshot.png b/media/examples/pick_directory.png
similarity index 100%
rename from examples/pick_directory/screenshot.png
rename to media/examples/pick_directory.png
diff --git a/examples/pick_file/screenshot.png b/media/examples/pick_file.png
similarity index 100%
rename from examples/pick_file/screenshot.png
rename to media/examples/pick_file.png
diff --git a/examples/save_file/screenshot.png b/media/examples/save_file.png
similarity index 100%
rename from examples/save_file/screenshot.png
rename to media/examples/save_file.png