Skip to content

Commit

Permalink
Add pane_grid::DragEvent::Moved variant
Browse files Browse the repository at this point in the history
  • Loading branch information
jsatka committed Oct 31, 2024
1 parent d1e51fd commit 71fe9d8
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions widget/src/pane_grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,24 @@ where
}
}
}

if let Some(on_drag) = &self.on_drag {
if let Some((pane, origin)) = action.picked_pane() {
if let Some(cursor_position) = cursor.position() {
let offset = if cursor_position.distance(origin)
> DRAG_DEADBAND_DISTANCE
{
cursor_position - origin
} else {
Vector::new(0.0, 0.0)
};
shell.publish(on_drag(DragEvent::Moved {
pane,
offset,
}))
}
}
}
}
_ => {}
}
Expand Down Expand Up @@ -1123,6 +1141,16 @@ pub enum DragEvent {
pane: Pane,
},

/// A [`Pane`] was moved while being dragged.
Moved {
/// The picked [`Pane`].
pane: Pane,

/// The offset [`Vector`] how much the picked [`Pane`] was moved
/// from its origin.
offset: Vector,
},

/// A [`Pane`] was dropped on top of another [`Pane`].
Dropped {
/// The picked [`Pane`].
Expand Down

0 comments on commit 71fe9d8

Please sign in to comment.