summaryrefslogtreecommitdiff
path: root/iced_drop/src
diff options
context:
space:
mode:
Diffstat (limited to 'iced_drop/src')
-rw-r--r--iced_drop/src/lib.rs24
-rw-r--r--iced_drop/src/widget/droppable.rs8
-rw-r--r--iced_drop/src/widget/operation/drop.rs5
3 files changed, 21 insertions, 16 deletions
diff --git a/iced_drop/src/lib.rs b/iced_drop/src/lib.rs
index fc559dc..9906cbe 100644
--- a/iced_drop/src/lib.rs
+++ b/iced_drop/src/lib.rs
@@ -1,8 +1,10 @@
pub mod widget;
use iced::{
- advanced::{graphics::futures::MaybeSend, renderer, widget::Id},
- Command, Element, Point, Rectangle,
+ advanced::widget::{operate, Id},
+ advanced::{graphics::futures::MaybeSend, renderer},
+ task::Task,
+ Element, Point, Rectangle,
};
use widget::droppable::*;
@@ -18,17 +20,17 @@ where
Droppable::new(content)
}
-pub fn zones_on_point<Message, MF>(
+pub fn zones_on_point<T, MF>(
msg: MF,
point: Point,
options: Option<Vec<Id>>,
depth: Option<usize>,
-) -> Command<Message>
+) -> Task<T>
where
- Message: 'static,
- MF: Fn(Vec<(Id, Rectangle)>) -> Message + MaybeSend + Sync + Clone + 'static,
+ T: Send + 'static,
+ MF: Fn(Vec<(Id, Rectangle)>) -> T + MaybeSend + Sync + Clone + 'static,
{
- Command::widget(drop::find_zones(
+ operate(drop::find_zones(
move |bounds| bounds.contains(point),
options,
depth,
@@ -41,11 +43,11 @@ pub fn find_zones<Message, MF, F>(
filter: F,
options: Option<Vec<Id>>,
depth: Option<usize>,
-) -> Command<Message>
+) -> Task<Message>
where
- Message: 'static,
+ Message: Send + 'static,
MF: Fn(Vec<(Id, Rectangle)>) -> Message + MaybeSend + Sync + Clone + 'static,
- F: Fn(&Rectangle) -> bool + 'static,
+ F: Fn(&Rectangle) -> bool + Send + 'static,
{
- Command::widget(drop::find_zones(filter, options, depth)).map(move |id| msg(id))
+ operate(drop::find_zones(filter, options, depth)).map(move |id| msg(id))
}
diff --git a/iced_drop/src/widget/droppable.rs b/iced_drop/src/widget/droppable.rs
index ed7dcbd..80d8600 100644
--- a/iced_drop/src/widget/droppable.rs
+++ b/iced_drop/src/widget/droppable.rs
@@ -228,8 +228,10 @@ where
state.action = Action::Drag(start, position);
// update the position of the overlay since the cursor was moved
if self.drag_center {
- state.overlay_bounds.x = position.x - state.overlay_bounds.width / 2.0;
- state.overlay_bounds.y = position.y - state.overlay_bounds.height / 2.0;
+ state.overlay_bounds.x =
+ position.x - state.overlay_bounds.width / 2.0;
+ state.overlay_bounds.y =
+ position.y - state.overlay_bounds.height / 2.0;
} else {
state.overlay_bounds.x = state.widget_pos.x + position.x - start.x;
state.overlay_bounds.y = state.widget_pos.y + position.y - start.y;
@@ -315,7 +317,7 @@ where
tree: &mut Tree,
layout: Layout<'_>,
renderer: &Renderer,
- operation: &mut dyn Operation<Message>,
+ operation: &mut dyn Operation,
) {
let state = tree.state.downcast_mut::<State>();
operation.custom(state, self.id.as_ref());
diff --git a/iced_drop/src/widget/operation/drop.rs b/iced_drop/src/widget/operation/drop.rs
index 12a2e30..a76181c 100644
--- a/iced_drop/src/widget/operation/drop.rs
+++ b/iced_drop/src/widget/operation/drop.rs
@@ -17,7 +17,7 @@ pub fn find_zones<F>(
depth: Option<usize>,
) -> impl Operation<Vec<(Id, Rectangle)>>
where
- F: Fn(&Rectangle) -> bool + 'static,
+ F: Fn(&Rectangle) -> bool + Send + 'static,
{
struct FindDropZone<F> {
filter: F,
@@ -30,7 +30,7 @@ where
impl<F> Operation<Vec<(Id, Rectangle)>> for FindDropZone<F>
where
- F: Fn(&Rectangle) -> bool + 'static,
+ F: Fn(&Rectangle) -> bool + Send + 'static,
{
fn container(
&mut self,
@@ -70,6 +70,7 @@ where
_state: &mut dyn Scrollable,
_id: Option<&Id>,
bounds: Rectangle,
+ _content_bounds: Rectangle,
translation: Vector,
) {
if (self.filter)(&bounds) {