Skip to content

Commit

Permalink
Merge pull request #41 from fluxxcode/develop
Browse files Browse the repository at this point in the history
Release v0.3.0
  • Loading branch information
fluxxcode authored Feb 18, 2024
2 parents a6c32fe + 57ba7cf commit 5b5b1eb
Show file tree
Hide file tree
Showing 11 changed files with 281 additions and 139 deletions.
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
# egui-file-dialog changelog

## 2024-02-18 - v0.3.0 - UI improvements
### 🖥 UI
- Updated bottom panel so that the dialog can also be resized in `DialogMode::SaveFile` or when selecting a file or directory with a long name [#32](https://github.com/fluxxcode/egui-file-dialog/pull/32)
- The error when saving a file is now displayed as a tooltip when hovering over the grayed out save button \
![preview](media/changelog/v0.3.0/error_tooltip.png)
- Updated file name input to use all available space
- Added scroll area around the selected item, so that long file names can be displayed without making the dialog larger
- The default minimum window size has been further reduced to `(340.0, 170.0)` [#32](https://github.com/fluxxcode/egui-file-dialog/pull/32)
- Added an error icon to the error message when creating a new folder [#32](https://github.com/fluxxcode/egui-file-dialog/pull/32) \
![preview](media/changelog/v0.3.0/error_icon.png)
- Removable devices are now listed in a separate devices section [#34](https://github.com/fluxxcode/egui-file-dialog/pull/34)
- Added mount point to the disk names on Windows [#38](https://github.com/fluxxcode/egui-file-dialog/pull/38)

### 🔧 Changes
- Restructure `file_dialog.rs` [#36](https://github.com/fluxxcode/egui-file-dialog/pull/36)

### 📚 Documentation
- Fix typos in the documentation [#29](https://github.com/fluxxcode/egui-file-dialog/pull/29)
- Fix eframe version in the example in `README.md` [#30](https://github.com/fluxxcode/egui-file-dialog/pull/30)
- Added "Planned features” section to `README.md` and minor improvements [#31](https://github.com/fluxxcode/egui-file-dialog/pull/31) (Renamed with [#35](https://github.com/fluxxcode/egui-file-dialog/pull/35))
- Updated example screenshot in `README.md` to include new "Removable Devices" section [#34](https://github.com/fluxxcode/egui-file-dialog/pull/34)
- Moved media files from `doc/img/` to `media/` [#37](https://github.com/fluxxcode/egui-file-dialog/pull/37)

## 2024-02-07 - v0.2.0 - API improvements
### 🚨 Breaking Changes
- Rename `FileDialog::default_window_size` to `FileDialog::default_size` [#14](https://github.com/fluxxcode/egui-file-dialog/pull/14)
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ members = [
[package]
name = "egui-file-dialog"
description = "An easy-to-use file dialog for egui"
version = "0.2.0"
version = "0.3.0"
edition = "2021"
authors = ["fluxxcode"]
repository = "https://github.com/fluxxcode/egui-file-dialog"
Expand Down
20 changes: 16 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@

This repository provides an easy-to-use file dialog (a.k.a. file explorer, file picker) for [egui](https://github.com/emilk/egui). This makes it possible to use a file dialog directly in the egui application without having to rely on the file explorer of the operating system.

<img src="doc/img/demo.png">
<img src="media/demo.png">

The goal for the future is that parts of the dialog can be dynamically adapted so that it can be used in different situations. One goal, for example, is that the labels can be dynamically adjusted to support different languages.

The project is currently in a very early version. Some planned features are still missing and some improvements still need to be made.

**NOTE**: As long as version 1.0.0 has not yet been reached, even minor version increases may contain breaking changes.
Check out [CHANGELOG.md](https://github.com/fluxxcode/egui-file-dialog/blob/develop/CHANGELOG.md) in the develop branch to find the latest features included in the next release.

**Currently only tested on Linux and Windows!**

Expand All @@ -25,14 +25,26 @@ The project is currently in a very early version. Some planned features are stil
- Shortcut for user directories (Home, Documents, ...) and system disks
- Resizable window

## Planned features
The following lists some of the features that are currently missing but are planned for the future!
- Customize labels and enabled features
- Selection of multiple directory items at once
- Customizable file icons
- Only show files with a specific file extension (The user can already filter files by file extension using the search, but there is currently no backend method for this or a dropdown to be able to select from predefined file extensions.)
- Keyboard input
- Context menus, for example for renaming, deleting or copying files or directories.
- Option to show or hide hidden files and folders

## Example
Detailed examples that can be run can be found in the [examples](https://github.com/fluxxcode/egui-file-dialog/tree/master/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.25.0"
egui-file-dialog = "0.2.0"
eframe = "0.26.0"
egui-file-dialog = "0.3.0"
```

main.rs:
Expand Down
Binary file removed doc/img/demo.png
Binary file not shown.
Binary file added media/changelog/v0.3.0/error_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/changelog/v0.3.0/error_tooltip.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/demo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 9 additions & 1 deletion src/create_directory_dialog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,15 @@ impl CreateDirectoryDialog {

if let Some(err) = &self.error {
ui.add_space(5.0);
let response = ui.label(err);

let response = ui
.horizontal_wrapped(|ui| {
ui.spacing_mut().item_spacing.x = 0.0;

ui.colored_label(ui.style().visuals.error_fg_color, "⚠ ");
ui.label(err);
})
.response;

if self.scroll_to_error {
response.scroll_to_me(Some(egui::Align::Center));
Expand Down
56 changes: 42 additions & 14 deletions src/data/disks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ use std::path::{Path, PathBuf};
pub struct Disk {
mount_point: PathBuf,
display_name: String,
is_removable: bool,
}

impl Disk {
/// Create a new Disk object based on the data of a sysinfo::Disk.
pub fn from_sysinfo_disk(disk: &sysinfo::Disk) -> Self {
Self {
mount_point: disk.mount_point().to_path_buf(),
display_name: Self::gen_display_name(disk),
display_name: gen_display_name(disk),
is_removable: disk.is_removable(),
}
}

Expand All @@ -28,19 +30,8 @@ impl Disk {
&self.display_name
}

fn gen_display_name(disk: &sysinfo::Disk) -> String {
// TODO: Get display name of the devices.
// Currently on Linux it returns "/dev/sda1" and on Windows it returns an
// empty string for the C:\\ drive.
let name = disk.name().to_str().unwrap_or_default().to_string();

// Try using the mount point as the display name if the specified name
// from sysinfo::Disk is empty or contains invalid characters
if name.is_empty() {
return disk.mount_point().to_str().unwrap_or_default().to_string();
}

name
pub fn is_removable(&self) -> bool {
self.is_removable
}
}

Expand Down Expand Up @@ -69,3 +60,40 @@ impl Disks {
self.disks.iter()
}
}

#[cfg(windows)]
fn gen_display_name(disk: &sysinfo::Disk) -> String {
// TODO: Get display name of the devices.
// Currently on Windows it returns an empty string for the C:\\ drive.

let mut name = disk.name().to_str().unwrap_or_default().to_string();
let mount_point = disk
.mount_point()
.to_str()
.unwrap_or_default()
.to_string()
.replace("\\", "");

// Try using the mount point as the display name if the specified name
// from sysinfo::Disk is empty or contains invalid characters
if name.is_empty() {
return mount_point;
}

name.push_str(format!(" ({})", mount_point).as_str());

name
}

#[cfg(not(windows))]
fn gen_display_name(disk: &sysinfo::Disk) -> String {
let name = disk.name().to_str().unwrap_or_default().to_string();

// Try using the mount point as the display name if the specified name
// from sysinfo::Disk is empty or contains invalid characters
if name.is_empty() {
return disk.mount_point().to_str().unwrap_or_default().to_string();
}

name
}
2 changes: 1 addition & 1 deletion src/data/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ mod directory_content;
pub use directory_content::{DirectoryContent, DirectoryEntry};

mod disks;
pub use disks::Disks;
pub use disks::{Disk, Disks};

mod user_directories;
pub use user_directories::UserDirectories;
Loading

0 comments on commit 5b5b1eb

Please sign in to comment.