Skip to main content

iced_drop/
lib.rs

1pub mod widget;
2
3use iced_core::{renderer, Element};
4use widget::droppable::*;
5
6#[cfg(feature = "helpers")]
7use iced_core::Point;
8#[cfg(feature = "helpers")]
9use iced_core::widget::Id;
10#[cfg(feature = "helpers")]
11use iced_widget::graphics::futures::MaybeSend;
12#[cfg(feature = "helpers")]
13use crate::widget::operation::drop;
14#[cfg(feature = "helpers")]
15use iced_core::Rectangle;
16#[cfg(feature = "helpers")]
17use iced_runtime::task::widget as operate;
18#[cfg(feature = "helpers")]
19use iced_runtime::Task;
20
21#[cfg(not(feature = "helpers"))]
22use widget::operation::drop;
23#[cfg(not(feature = "helpers"))]
24pub use drop::find_zones;
25
26pub fn droppable<'a, Message, Theme, Renderer>(
27    content: impl Into<Element<'a, Message, Theme, Renderer>>,
28) -> Droppable<'a, Message, Theme, Renderer>
29where
30    Message: Clone,
31    Renderer: renderer::Renderer,
32{
33    Droppable::new(content)
34}
35
36#[cfg(feature = "helpers")]
37pub fn zones_on_point<T, MF>(
38    msg: MF,
39    point: Point,
40    options: Option<Vec<Id>>,
41    depth: Option<usize>,
42) -> Task<T>
43where
44    T: Send + 'static,
45    MF: Fn(Vec<(Id, Rectangle)>) -> T + MaybeSend + Sync + Clone + 'static,
46{
47    operate(drop::find_zones(
48        move |bounds| bounds.contains(point),
49        options,
50        depth,
51    ))
52        .map(msg)
53}
54
55#[cfg(feature = "helpers")]
56pub fn find_zones<Message, MF, F>(
57    msg: MF,
58    filter: F,
59    options: Option<Vec<Id>>,
60    depth: Option<usize>,
61) -> Task<Message>
62where
63    Message: Send + 'static,
64    MF: Fn(Vec<(Id, Rectangle)>) -> Message
65    + MaybeSend
66    + Sync
67    + Clone
68    + 'static,
69    F: Fn(&Rectangle) -> bool + Send + 'static,
70{
71    operate(drop::find_zones(filter, options, depth)).map(msg)
72}