Skip to content

Commit

Permalink
Always publish either Dropped or Canceled event when picked `Pane…
Browse files Browse the repository at this point in the history
…` is dropped
  • Loading branch information
jsatka committed Oct 31, 2024
1 parent 50340b4 commit d1e51fd
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions widget/src/pane_grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -510,17 +510,19 @@ where
| Event::Touch(touch::Event::FingerLost { .. }) => {
if let Some((pane, origin)) = action.picked_pane() {
if let Some(on_drag) = on_drag {
let mut drag_event = DragEvent::Canceled { pane };

if let Some(cursor_position) = cursor.position() {
if cursor_position.distance(origin)
> DRAG_DEADBAND_DISTANCE
{
let event = if let Some(edge) =
if let Some(edge) =
in_edge(layout, cursor_position)
{
DragEvent::Dropped {
drag_event = DragEvent::Dropped {
pane,
target: Target::Edge(edge),
}
};
} else {
let dropped_region = self
.panes
Expand All @@ -536,24 +538,23 @@ where
.map(|region| (target, region))
});

match dropped_region {
Some(((target, _), region))
if pane != target =>
{
DragEvent::Dropped {
if let Some(((target, _), region)) =
dropped_region
{
if pane != target {
drag_event = DragEvent::Dropped {
pane,
target: Target::Pane(
target, region,
),
}
};
}
_ => DragEvent::Canceled { pane },
}
};

shell.publish(on_drag(event));
}
}
}
};

shell.publish(on_drag(drag_event));
}

event_status = event::Status::Captured;
Expand Down Expand Up @@ -1131,8 +1132,7 @@ pub enum DragEvent {
target: Target,
},

/// A [`Pane`] was picked and then dropped outside of other [`Pane`]
/// boundaries.
/// A [`Pane`] was dropped outside of valid [`Target`] areas.
Canceled {
/// The picked [`Pane`].
pane: Pane,
Expand Down

0 comments on commit d1e51fd

Please sign in to comment.