Skip to content

Commit

Permalink
Aggregate multiple dragged files while user is selecting a target pane
Browse files Browse the repository at this point in the history
  • Loading branch information
mtkennerly committed Dec 16, 2024
1 parent 6910d6a commit 41afb95
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
* Fixed:
* The `crop` content fit now works correctly for videos.
Previously, it acted the same as `stretch`.
* If you drag-and-dropped multiple files into the window
while there was more than one grid open,
only one of the files would be inserted into the grid that you selected.

## v0.1.0 (2024-12-12)

Expand Down
18 changes: 8 additions & 10 deletions src/gui/app.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::{
collections::HashMap,
collections::{HashMap, HashSet},
num::NonZeroUsize,
time::{Duration, Instant},
};
Expand Down Expand Up @@ -48,7 +48,7 @@ pub struct App {
last_tick: Instant,
#[allow(unused)] // TODO: https://github.com/iced-rs/iced/pull/2691
dragging_pane: bool,
dragged_file: Option<StrictPath>,
dragged_files: HashSet<StrictPath>,
viewing_pane_controls: Option<grid::Id>,
playlist_path: Option<StrictPath>,
playlist_dirty: bool,
Expand Down Expand Up @@ -207,7 +207,7 @@ impl App {
media: Default::default(),
last_tick: Instant::now(),
dragging_pane: false,
dragged_file: None,
dragged_files: Default::default(),
viewing_pane_controls: None,
playlist_path,
playlist_dirty,
Expand Down Expand Up @@ -842,7 +842,7 @@ impl App {
modal::scroll_down(),
])
} else {
self.dragged_file = Some(path);
self.dragged_files.insert(path);
iced::window::get_oldest().and_then(iced::window::gain_focus)
}
}
Expand All @@ -854,11 +854,9 @@ impl App {
return Task::none();
};

let Some(path) = self.dragged_file.take() else {
return Task::none();
};

let settings = grid.settings().with_source(media::Source::new_path(path));
let settings = grid
.settings()
.with_sources(self.dragged_files.drain().map(media::Source::new_path).collect());

self.show_modal(Modal::new_grid_settings(grid_id, settings));
modal::scroll_down()
Expand Down Expand Up @@ -1120,7 +1118,7 @@ impl App {
}

pub fn view(&self) -> Element {
let dragging_file = self.dragged_file.is_some();
let dragging_file = !self.dragged_files.is_empty();
let obscured = !self.modals.is_empty();

Responsive::new(move |viewport| {
Expand Down

0 comments on commit 41afb95

Please sign in to comment.