iced_drop/
lib.rs

1pub mod widget;
2
3use iced::{
4	Element, Point, Rectangle,
5	advanced::widget::{Id, operate},
6	advanced::{graphics::futures::MaybeSend, renderer},
7	task::Task,
8};
9
10use widget::droppable::*;
11use widget::operation::drop;
12
13pub fn droppable<'a, Message, Theme, Renderer>(content: impl Into<Element<'a, Message, Theme, Renderer>>) -> Droppable<'a, Message, Theme, Renderer>
14where
15	Message: Clone,
16	Renderer: renderer::Renderer,
17{
18	Droppable::new(content)
19}
20
21pub fn zones_on_point<T, MF>(msg: MF, point: Point, options: Option<Vec<Id>>, depth: Option<usize>) -> Task<T>
22where
23	T: Send + 'static,
24	MF: Fn(Vec<(Id, Rectangle)>) -> T + MaybeSend + Sync + Clone + 'static,
25{
26	operate(drop::find_zones(move |bounds| bounds.contains(point), options, depth)).map(msg)
27}
28
29pub fn find_zones<Message, MF, F>(msg: MF, filter: F, options: Option<Vec<Id>>, depth: Option<usize>) -> Task<Message>
30where
31	Message: Send + 'static,
32	MF: Fn(Vec<(Id, Rectangle)>) -> Message + MaybeSend + Sync + Clone + 'static,
33	F: Fn(&Rectangle) -> bool + Send + 'static,
34{
35	operate(drop::find_zones(filter, options, depth)).map(msg)
36}