Skip to content

Commit

Permalink
Resizable and movable option (#15)
Browse files Browse the repository at this point in the history
* Add FileDialog::resizable

* Add FileDialog::movable

* Update CHANGELOG.md
  • Loading branch information
fluxxcode authored Feb 4, 2024
1 parent 2c82729 commit f8548cb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
### ✨ Features
- Added `FileDialog::anchor` to overwrite the window anchor [#11](https://github.com/fluxxcode/egui-file-dialog/pull/11)
- Added `FileDialog::title` to overwrite the window title [#12](https://github.com/fluxxcode/egui-file-dialog/pull/12)
- Added `FileDialog::resizable` to set if the window is resizable [#15](https://github.com/fluxxcode/egui-file-dialog/pull/15)
- Added `FileDialog::movable` to set if the window is movable [#15](https://github.com/fluxxcode/egui-file-dialog/pull/15)

### 🔧 Changes
- Removed the version of `egui-file-dialog` in the examples [#8](https://github.com/fluxxcode/egui-file-dialog/pull/8)
Expand Down
22 changes: 22 additions & 0 deletions src/file_dialog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ pub struct FileDialog {
window_default_size: egui::Vec2,
/// The anchor of the window.
window_anchor: Option<(egui::Align2, egui::Vec2)>,
/// If the window is resizable
window_resizable: bool,
/// If the window is movable
window_movable: bool,

/// The dialog that is shown when the user wants to create a new directory.
create_directory_dialog: CreateDirectoryDialog,
Expand Down Expand Up @@ -153,6 +157,8 @@ impl FileDialog {
window_overwrite_title: None,
window_default_size: egui::Vec2::new(650.0, 370.0),
window_anchor: None,
window_resizable: true,
window_movable: true,

create_directory_dialog: CreateDirectoryDialog::new(),

Expand Down Expand Up @@ -199,6 +205,20 @@ impl FileDialog {
self
}

/// Sets if the window is resizable.
pub fn resizable(mut self, resizable: bool) -> Self {
self.window_resizable = resizable;
self
}

/// Sets if the window is movable.
///
/// Has no effect if an anchor is set.
pub fn movable(mut self, movable: bool) -> Self {
self.window_movable = movable;
self
}

/// Sets the default file name when opening the dialog in `DialogMode::SaveFile` mode.
pub fn default_file_name(mut self, name: &str) -> Self {
self.default_file_name = name.to_string();
Expand Down Expand Up @@ -351,6 +371,8 @@ impl FileDialog {
.default_size(self.window_default_size)
.min_width(355.0)
.min_height(200.0)
.resizable(self.window_resizable)
.movable(self.window_movable)
.collapsible(false);

if let Some((anchor, offset)) = self.window_anchor {
Expand Down

0 comments on commit f8548cb

Please sign in to comment.