Skip to content

Commit

Permalink
refactor: DragDrop -> DragDropped
Browse files Browse the repository at this point in the history
Keep everything in past-tense
  • Loading branch information
valadaptive committed Jan 10, 2025
1 parent 3025f4f commit d714b1c
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion examples/dnd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl ApplicationHandler for Application {
WindowEvent::DragLeft { .. }
| WindowEvent::DragEntered { .. }
| WindowEvent::DragMoved { .. }
| WindowEvent::DragDrop { .. } => {
| WindowEvent::DragDropped { .. } => {
println!("{:?}", event);
},
WindowEvent::CloseRequested => {
Expand Down
2 changes: 1 addition & 1 deletion examples/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ impl ApplicationHandler for Application {
| WindowEvent::PointerEntered { .. }
| WindowEvent::DragEntered { .. }
| WindowEvent::DragMoved { .. }
| WindowEvent::DragDrop { .. }
| WindowEvent::DragDropped { .. }
| WindowEvent::Destroyed
| WindowEvent::Moved(_) => (),
}
Expand Down
4 changes: 2 additions & 2 deletions src/changelog/unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ changelog entry.

The `WindowEvent::DroppedFile`, `WindowEvent::HoveredFile` and `WindowEvent::HoveredFileCancelled`
events have been removed, and replaced with `WindowEvent::DragEntered`, `WindowEvent::DragMoved`,
`WindowEvent::DragDrop` and `WindowEvent::DragLeft`.
`WindowEvent::DragDropped` and `WindowEvent::DragLeft`.

The old drag-and-drop events were emitted once per file. This occurred when files were *first*
hovered over the window, dropped, or left the window. The new drag-and-drop events are emitted
Expand All @@ -177,7 +177,7 @@ changelog entry.

The rough correspondence is:
- `WindowEvent::HoveredFile` -> `WindowEvent::DragEntered`
- `WindowEvent::DroppedFile` -> `WindowEvent::DragDrop`
- `WindowEvent::DroppedFile` -> `WindowEvent::DragDropped`
- `WindowEvent::HoveredFileCancelled` -> `WindowEvent::DragLeft`

The `WindowEvent::DragMoved` event is entirely new, and is emitted whenever the pointer moves
Expand Down
4 changes: 2 additions & 2 deletions src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ pub enum WindowEvent {
position: PhysicalPosition<f64>,
},
/// The drag operation has dropped file(s) on the window.
DragDrop {
DragDropped {
/// List of paths that are being dragged onto the window.
paths: Vec<PathBuf>,
/// (x,y) coordinates in pixels relative to the top-left corner of the window. May be
Expand Down Expand Up @@ -1241,7 +1241,7 @@ mod tests {
position: (0, 0).into(),
});
with_window_event(DragMoved { position: (0, 0).into() });
with_window_event(DragDrop {
with_window_event(DragDropped {
paths: vec!["x.txt".into()],
position: (0, 0).into(),
});
Expand Down
2 changes: 1 addition & 1 deletion src/platform_impl/apple/appkit/window_delegate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ declare_class!(
let dl = self.view().convertPoint_fromView(dl, None);
let position = LogicalPosition::<f64>::from((dl.x, dl.y)).to_physical(self.scale_factor());

self.queue_event(WindowEvent::DragDrop { paths, position });
self.queue_event(WindowEvent::DragDropped { paths, position });

true
}
Expand Down
2 changes: 1 addition & 1 deletion src/platform_impl/linux/x11/event_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ impl EventProcessor {
if let Some(Ok(ref path_list)) = self.dnd.result {
callback(&self.target, Event::WindowEvent {
window_id,
event: WindowEvent::DragDrop {
event: WindowEvent::DragDropped {
paths: path_list.iter().map(Into::into).collect(),
position: self.dnd.position,
},
Expand Down
4 changes: 2 additions & 2 deletions src/platform_impl/windows/drop_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ impl FileDropHandler {
pt: POINTL,
_pdwEffect: *mut u32,
) -> HRESULT {
use crate::event::WindowEvent::DragDrop;
use crate::event::WindowEvent::DragDropped;
let drop_handler = unsafe { Self::from_interface(this) };
if drop_handler.enter_is_valid {
let mut pt = POINT { x: pt.x, y: pt.y };
Expand All @@ -164,7 +164,7 @@ impl FileDropHandler {
let hdrop = unsafe { Self::iterate_filenames(pDataObj, |path| paths.push(path)) };
drop_handler.send_event(Event::WindowEvent {
window_id: WindowId::from_raw(drop_handler.window as usize),
event: DragDrop { paths, position },
event: DragDropped { paths, position },
});
if let Some(hdrop) = hdrop {
unsafe {
Expand Down

0 comments on commit d714b1c

Please sign in to comment.