Skip to content

Commit

Permalink
Release v0.3.1 (#50)
Browse files Browse the repository at this point in the history
* Fix shortcut directories can not be selected (#43)

* Fix root directories not correctly displayed (#44)

* Update CI/CD (#46)

* Move FileDialog::update (#47)

* Fix display name of root directories on Windows (#48)

* Update planned features (#49)

* Add Pinnable folders to planned features

* Increase versions
  • Loading branch information
fluxxcode authored Feb 20, 2024
1 parent 5b5b1eb commit 50d2c95
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 49 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ on:
branches:
- master
- develop
- rel/*
pull_request:
branches:
- master
- develop
- rel/*

name: Rust

Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# egui-file-dialog changelog

## 2024-02-20 - v0.3.1 - Bug fixes
### 🐛 Bug Fixes
- Fixed not being able to select a shortcut directory like Home or Documents [#43](https://github.com/fluxxcode/egui-file-dialog/pull/43)
- Fixed issue where root directories were not displayed correctly [#44](https://github.com/fluxxcode/egui-file-dialog/pull/44) and [#48](https://github.com/fluxxcode/egui-file-dialog/pull/48)

### 🔧 Changes
- Updated CI to also run on release branches [#46](https://github.com/fluxxcode/egui-file-dialog/pull/46)

### 📚 Documentation
- `FileDialog::update` has been moved up in the documentation [#47](https://github.com/fluxxcode/egui-file-dialog/pull/47)
- Added "Pinnable folders" to planned features in `README.md` [#49](https://github.com/fluxxcode/egui-file-dialog/pull/49)

## 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)
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.3.0"
version = "0.3.1"
edition = "2021"
authors = ["fluxxcode"]
repository = "https://github.com/fluxxcode/egui-file-dialog"
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ The following lists some of the features that are currently missing but are plan
- Customize labels and enabled features
- Selection of multiple directory items at once
- Customizable file icons
- Pinnable folders for quick access: [#42](https://github.com/fluxxcode/egui-file-dialog/issues/42)
- 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.
Expand All @@ -44,7 +45,7 @@ Cargo.toml:
```toml
[dependencies]
eframe = "0.26.0"
egui-file-dialog = "0.3.0"
egui-file-dialog = "0.3.1"
```

main.rs:
Expand Down
29 changes: 28 additions & 1 deletion src/data/directory_content.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,34 @@ impl DirectoryEntry {
self.path
.file_name()
.and_then(|name| name.to_str())
.unwrap_or_default()
.unwrap_or_else(|| {
// Make sure the root directories like ["C:", "\"] and ["\\?\C:", "\"] are
// displayed correctly
#[cfg(windows)]
if self.path.components().count() == 2 {
let path = self
.path
.iter()
.nth(0)
.and_then(|seg| seg.to_str())
.unwrap_or_default();

// Skip path namespace prefix if present, for example: "\\?\C:"
if path.contains(r"\\?\") {
return path.get(4..).unwrap_or(path);
}

return path;
}

// Make sure the root directory "/" is displayed correctly
#[cfg(not(windows))]
if self.path.iter().count() == 1 {
return self.path.to_str().unwrap_or_default();
}

""
})
}
}

Expand Down
99 changes: 53 additions & 46 deletions src/file_dialog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ impl FileDialog {
}

// -------------------------------------------------
// Open:
// Open, Update:

/// Opens the file dialog in the given mode with the given options.
/// This function resets the file dialog and takes care for the variables that need to be
Expand Down Expand Up @@ -333,6 +333,50 @@ impl FileDialog {
let _ = self.open(DialogMode::SaveFile, true, None);
}

/// The main update method that should be called every frame if the dialog is to be visible.
///
/// This function has no effect if the dialog state is currently not `DialogState::Open`.
pub fn update(&mut self, ctx: &egui::Context) -> &Self {
if self.state != DialogState::Open {
return self;
}

let mut is_open = true;

self.create_window(&mut is_open).show(ctx, |ui| {
egui::TopBottomPanel::top("fe_top_panel")
.resizable(false)
.show_inside(ui, |ui| {
self.ui_update_top_panel(ctx, ui);
});

egui::SidePanel::left("fe_left_panel")
.resizable(true)
.default_width(150.0)
.width_range(90.0..=250.0)
.show_inside(ui, |ui| {
self.ui_update_left_panel(ctx, ui);
});

egui::TopBottomPanel::bottom("fe_bottom_panel")
.resizable(false)
.show_inside(ui, |ui| {
self.ui_update_bottom_panel(ctx, ui);
});

egui::CentralPanel::default().show_inside(ui, |ui| {
self.ui_update_central_panel(ui);
});
});

// User closed the window without finishing the dialog
if !is_open {
self.cancel();
}

self
}

// -------------------------------------------------
// Setter:

Expand Down Expand Up @@ -457,50 +501,6 @@ impl FileDialog {
pub fn operation_id(&self) -> Option<&str> {
self.operation_id.as_deref()
}

/// The main update method that should be called every frame if the dialog is to be visible.
///
/// This function has no effect if the dialog state is currently not `DialogState::Open`.
pub fn update(&mut self, ctx: &egui::Context) -> &Self {
if self.state != DialogState::Open {
return self;
}

let mut is_open = true;

self.create_window(&mut is_open).show(ctx, |ui| {
egui::TopBottomPanel::top("fe_top_panel")
.resizable(false)
.show_inside(ui, |ui| {
self.ui_update_top_panel(ctx, ui);
});

egui::SidePanel::left("fe_left_panel")
.resizable(true)
.default_width(150.0)
.width_range(90.0..=250.0)
.show_inside(ui, |ui| {
self.ui_update_left_panel(ctx, ui);
});

egui::TopBottomPanel::bottom("fe_bottom_panel")
.resizable(false)
.show_inside(ui, |ui| {
self.ui_update_bottom_panel(ctx, ui);
});

egui::CentralPanel::default().show_inside(ui, |ui| {
self.ui_update_central_panel(ui);
});
});

// User closed the window without finishing the dialog
if !is_open {
self.cancel();
}

self
}
}

/// UI methods
Expand Down Expand Up @@ -1195,6 +1195,8 @@ impl FileDialog {
/// Loads the given directory and updates the `directory_stack`.
/// The function deletes all directories from the `directory_stack` that are currently
/// stored in the vector before the `directory_offset`.
///
/// The function also sets the loaded directory as the selected item.
fn load_directory(&mut self, path: &Path) -> io::Result<()> {
let full_path = match fs::canonicalize(path) {
Ok(path) => path,
Expand All @@ -1220,7 +1222,12 @@ impl FileDialog {
self.directory_stack.push(full_path);
self.directory_offset = 0;

self.load_directory_content(path)
self.load_directory_content(path)?;

let dir_entry = DirectoryEntry::from_path(path);
self.select_item(&dir_entry);

Ok(())
}

/// Loads the directory content of the given path.
Expand Down

0 comments on commit 50d2c95

Please sign in to comment.