Skip to content

Commit

Permalink
Merge branch develop into docs/update_readme
Browse files Browse the repository at this point in the history
  • Loading branch information
fluxxcode committed Dec 17, 2024
2 parents d23c312 + 51be318 commit a7a2c8c
Show file tree
Hide file tree
Showing 44 changed files with 771 additions and 198 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

- Added `FileDialog::update_with_right_panel_ui` to add a custom right panel to the file dialog [#170](https://github.com/fluxxcode/egui-file-dialog/pull/170) (thanks [@crumblingstatue](https://github.com/crumblingstatue)!)
- Added `FileDialog::active_selected_entries` and `FileDialog::active_entry` to get information about the current active item/s [#170](https://github.com/fluxxcode/egui-file-dialog/pull/170) (thanks [@crumblingstatue](https://github.com/crumblingstatue)!)
- Added new `InformationPanel` to optionally display file information and image previews in the right panel (thanks [@hacknus](https://github.com/hacknus) and [@bircni](https://github.com/bircni)!)
- Added option to show system files in the hamburger menu [#173](https://github.com/fluxxcode/egui-file-dialog/pull/173) (thanks [@crumblingstatue](https://github.com/crumblingstatue)!)
- Support mapped network devices on Windows [#189](https://github.com/fluxxcode/egui-file-dialog/pull/189)
- Added the ability to drag and drop files and folders to open their respective path [#192](https://github.com/fluxxcode/egui-file-dialog/pull/192) (thanks [@hacknus](https://github.com/hacknus)!)
Expand All @@ -24,13 +25,14 @@
### 🔧 Changes

- Use path edit as file to save [#160](https://github.com/fluxxcode/egui-file-dialog/pull/160)
- Updated sysinfo to version `0.32` [#161](https://github.com/fluxxcode/egui-file-dialog/pull/161)
- Updated sysinfo to version `0.33` [#220](https://github.com/fluxxcode/egui-file-dialog/pull/220)
- Made default egui fonts an optional feature `default_fonts` [#163](https://github.com/fluxxcode/egui-file-dialog/pull/163) (thanks [@StarStarJ](https://github.com/StarStarJ)!)
- Filter directory when loading to improve performance [#169](https://github.com/fluxxcode/egui-file-dialog/pull/169)
- Implement non blocking directory loading [#177](https://github.com/fluxxcode/egui-file-dialog/pull/177)
- Only update visible items in the central panel if the search value is empty and the create directory dialog is currently closed [#181](https://github.com/fluxxcode/egui-file-dialog/pull/181)
- Improve CI [#186](https://github.com/fluxxcode/egui-file-dialog/pull/186) (thanks [@bircni](https://github.com/bircni)!)
- Use `cmd` for keybindings on MacOS [#205](https://github.com/fluxxcode/egui-file-dialog/pull/205) (thanks [@hacknus](https://github.com/hacknus)!)
- Cleanup examples [#213](https://github.com/fluxxcode/egui-file-dialog/pull/213) (thanks [@bircni](https://github.com/bircni)!)

### 📚 Documentation

Expand Down
46 changes: 26 additions & 20 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -22,24 +12,39 @@ license = "MIT"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
egui = { version = "0.29.1", default-features = false }

# Used to fetch user folders
egui = { version = "0.30.0", default-features = false }
# fetch user folders
directories = "5.0"

# Used to fetch disks
sysinfo = { version = "0.32", default-features = false, features = ["disk"] }

# Used for persistent storage
# canonicalize paths
dunce = "1.0.5"
# fetch disks
sysinfo = { version = "0.33", default-features = false, features = ["disk"] }
# persistent storage
serde = { version = "1", features = ["derive"], optional = true }
# meta-data storage
indexmap = { version = "2.7.0", features = ["serde"], optional = true }

# Used to canonicalize paths
dunce = "1.0.5"
# info panel meta-data display
image-meta = { version = "0.1.2", optional = true }
chrono = { version = "0.4.39", optional = true }

[dev-dependencies]
eframe = { version = "0.30.0", default-features = false, features = [
"glow",
"persistence",
"wayland",
"x11",
] }
egui-file-dialog = { path = "." , features = ["information_view"] }
egui_extras = { version = "0.30", features = ["all_loaders"] }
# required by the egui loaders
image = { version = "0.25.5", features = ["bmp", "jpeg", "gif", "png", "tiff", "rayon"] }

[features]
default = ["serde", "default_fonts"]
serde = ["dep:serde"]
default_fonts = ["egui/default_fonts"]
information_view = ["dep:chrono", "image-meta", "indexmap"]

[lints.rust]
unsafe_code = "warn"
Expand All @@ -61,3 +66,4 @@ struct_field_names = { level = "allow", priority = 13 }
missing_fields_in_debug = { level = "allow", priority = 14 }
missing_errors_doc = { level = "allow", priority = 15 }
module_name_repetitions = { level = "allow", priority = 16 }
cast_precision_loss = { level = "allow", priority = 17 }
51 changes: 37 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -28,6 +29,7 @@ The latest changes included in the next release can be found in the [CHANGELOG.m

## Features
- Pick a file or a directory
- 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
- Pick multiple files and folders at once (ctrl/shift + click on linux/windows and cmd/shift + click on macOS)
Expand All @@ -51,18 +53,21 @@ 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"
egui-file-dialog = "0.7.0"
```

main.rs:

```rust
use std::path::PathBuf;

Expand Down Expand Up @@ -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` <br/> `ALT` + `` <br/> `Backspace` |
| forward | Go forward | `Mouse button 2` <br/> `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` <br/> `ALT` + `` <br/> `Backspace` |
| forward | Go forward | `Mouse button 2` <br/> `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).

Expand All @@ -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;
Expand Down Expand Up @@ -186,12 +200,14 @@ FileDialog::new()
Arc::new(|p| p.extension().unwrap_or_default() == "rs"),
);
```

With the options the dialog then looks like this:
<img src="media/customization_demo.png">

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
Expand All @@ -202,9 +218,11 @@ fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
});
}
```

<img src="media/right_panel_demo.png">

## 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. \
Expand Down Expand Up @@ -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`)
Expand Down Expand Up @@ -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.
100 changes: 100 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# 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)


## Pick File with Information View

Example showing how to pick a file and display file information using the `InformationView`.

Requires the feature `information_view` as well as these dependencies:

```toml
[dependencies]
egui-file-dialog = { version = "*", features = ["information_view"] }
egui_extras = { version = "0.29", features = ["all_loaders"] }
# required by the egui loaders
image = { version = "0.25.5", features = ["bmp", "jpeg", "gif", "png", "tiff", "rayon"] }
```

```shell
cargo run --example pick_file_with_information_view
```

![Screenshot](../media/examples/information_view.png)

10 changes: 0 additions & 10 deletions examples/custom-right-panel/Cargo.toml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -50,8 +50,7 @@ impl eframe::App for MyApp {
ui.separator();
}
});
}
_ => {
} else {
ui.heading("Active item");
ui.small(format!("{:#?}", dia.active_entry()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
10 changes: 0 additions & 10 deletions examples/multi_selection/Cargo.toml

This file was deleted.

7 changes: 0 additions & 7 deletions examples/multi_selection/README.md

This file was deleted.

File renamed without changes.
Loading

0 comments on commit a7a2c8c

Please sign in to comment.