Skip to content

Commit

Permalink
Implement show_top_panel (#60)
Browse files Browse the repository at this point in the history
* Implement show_top_panel

* Update CHANGELOG.md
  • Loading branch information
fluxxcode authored Feb 22, 2024
1 parent 97512bf commit 99276ea
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
### ✨ Features
- Added `FileDialog::take_selected` as an alternative to `FileDialog::selected` [#52](https://github.com/fluxxcode/egui-file-dialog/pull/52)
- Added `FileDialogConfig` and `FileDialog::overwrite_config` to override the configuration of a file dialog. This is useful if you want to configure multiple `FileDialog` objects with the same options. [#58](https://github.com/fluxxcode/egui-file-dialog/pull/58)
- Added `FileDialog::show_top_panel` to show or hide the top panel with the navigation buttons, current path, etc. [#60](https://github.com/fluxxcode/egui-file-dialog/pull/60)
- Added `FileDialog::show_left_panel` to show or hide the left panel with the shortcut directories such as “Home”, “Documents”, etc. [#54](https://github.com/fluxxcode/egui-file-dialog/pull/54)
- Added `FileDialog::show_places`, `FileDialog::show_devices` and `FileDialog::show_removable_devices` to show or hide individual section of the left panel [#57](https://github.com/fluxxcode/egui-file-dialog/pull/57)

Expand Down
25 changes: 20 additions & 5 deletions src/file_dialog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ pub struct FileDialogConfig {

// ------------------------------------------------------------------------
// Feature options:
/// If the top panel with the navigation buttons, current path display and search input
/// should be visible.
pub show_top_panel: bool,

/// If the sidebar with the shortcut directories such as
/// “Home”, “Documents” etc. should be visible.
pub show_left_panel: bool,
Expand Down Expand Up @@ -111,6 +115,8 @@ impl Default for FileDialogConfig {
movable: true,
title_bar: true,

show_top_panel: true,

show_left_panel: true,
show_places: true,
show_devices: true,
Expand Down Expand Up @@ -548,6 +554,13 @@ impl FileDialog {
self
}

/// Sets if the top panel with the navigation buttons, current path display
/// and search input should be visible.
pub fn show_top_panel(mut self, show_top_panel: bool) -> Self {
self.config.show_top_panel = show_top_panel;
self
}

/// Sets if the sidebar with the shortcut directories such as
/// “Home”, “Documents” etc. should be visible.
pub fn show_left_panel(mut self, show_left_panel: bool) -> Self {
Expand Down Expand Up @@ -638,11 +651,13 @@ impl FileDialog {
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(ui);
});
if self.config.show_top_panel {
egui::TopBottomPanel::top("fe_top_panel")
.resizable(false)
.show_inside(ui, |ui| {
self.ui_update_top_panel(ui);
});
}

if self.config.show_left_panel {
egui::SidePanel::left("fe_left_panel")
Expand Down

0 comments on commit 99276ea

Please sign in to comment.