diff options
| author | Polesznyák Márk László <116908301+pml68@users.noreply.github.com> | 2025-04-29 23:35:39 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-29 23:35:39 +0200 |
| commit | ca50c308f0058af80e9125ba00a1349877169968 (patch) | |
| tree | 38fbd5c78c90487e5b641f635d01c4a614ddfd44 /crates/iced_drop/src/lib.rs | |
| parent | Merge pull request #14 from pml68/dependabot/cargo/windows_exe_info-0.5.1 (diff) | |
| parent | style: `theme` -> `appearance` (diff) | |
| download | iced-builder-ca50c308f0058af80e9125ba00a1349877169968.tar.gz | |
Merge pull request #20 from pml68/feat/custom-theme
Diffstat (limited to 'crates/iced_drop/src/lib.rs')
| -rw-r--r-- | crates/iced_drop/src/lib.rs | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/crates/iced_drop/src/lib.rs b/crates/iced_drop/src/lib.rs new file mode 100644 index 0000000..c1e1b03 --- /dev/null +++ b/crates/iced_drop/src/lib.rs @@ -0,0 +1,55 @@ +pub mod widget; + +use iced::advanced::graphics::futures::MaybeSend; +use iced::advanced::renderer; +use iced::advanced::widget::{operate, Id}; +use iced::task::Task; +use iced::{Element, Point, Rectangle}; +use widget::droppable::*; +use widget::operation::drop; + +pub fn droppable<'a, Message, Theme, Renderer>( + content: impl Into<Element<'a, Message, Theme, Renderer>>, +) -> Droppable<'a, Message, Theme, Renderer> +where + Message: Clone, + Renderer: renderer::Renderer, +{ + Droppable::new(content) +} + +pub fn zones_on_point<T, MF>( + msg: MF, + point: Point, + options: Option<Vec<Id>>, + depth: Option<usize>, +) -> Task<T> +where + T: Send + 'static, + MF: Fn(Vec<(Id, Rectangle)>) -> T + MaybeSend + Sync + Clone + 'static, +{ + operate(drop::find_zones( + move |bounds| bounds.contains(point), + options, + depth, + )) + .map(move |id| msg(id)) +} + +pub fn find_zones<Message, MF, F>( + msg: MF, + filter: F, + options: Option<Vec<Id>>, + depth: Option<usize>, +) -> Task<Message> +where + Message: Send + 'static, + MF: Fn(Vec<(Id, Rectangle)>) -> Message + + MaybeSend + + Sync + + Clone + + 'static, + F: Fn(&Rectangle) -> bool + Send + 'static, +{ + operate(drop::find_zones(filter, options, depth)).map(move |id| msg(id)) +} |
