aseprite / laf

A C++ library to create desktop applications
https://aseprite.github.io/laf/
MIT License
274 stars 58 forks source link

Add mouse coordinates to os::Event::DropFiles event indicating the point where the drop of files took place on the target window #82

Closed martincapello closed 5 months ago

martincapello commented 5 months ago

Implements pending work needed for https://github.com/aseprite/aseprite/issues/131

aseprite-bot commented 5 months ago

clang-tidy review says "All clean, LGTM! :+1:"

aseprite-bot commented 5 months ago

clang-tidy review says "All clean, LGTM! :+1:"

dacap commented 5 months ago

I've pushed other commit in the branch for the allevents example. I think we'll need a new kind of event, because DropFiles occurs when we release the mouse button, but for this we'll need some kind of feedback in the whole drag operation.

martincapello commented 5 months ago

Great. Yeah, we will need a new event for that. DragFiles?

dacap commented 5 months ago

It can be "DragFiles", although we'll need to detect the "DragFilesEnter" and "DragFilesLeave" events too (to remove the feedback if the user does't drop or press Esc key).

Not sure if we should create more generic DnD (drag-and-drop) events at this moment (e.g. DragEnter / DragLeave / Drag / Drop) probably just leave this as specific (for files only now) as possible and leave more generic events for a future refactor.

martincapello commented 5 months ago

I've been investigating a bit, and it actually makes sense to go generic right now....because the DnD protocols used in each OS are generic as well. Because if I understood well, the drop files event is a sort of simplified DnD case on windows that we emulated in linux and macos using just some parts of their generic protocols, right? Then, to get feedback about the dragging we will need to implement the IDropTarget interface on Windows. In macOs we will have to add support for draggingUpdated:, draggingExited: and draggingEnded:. And in linux, we will have to take a closer look to XDnD protocol to support the dragging feedback.

dacap commented 5 months ago

That seems the best decision. I can merge this right now (as this PR adds the position of the DropFiles event correctly), and do the whole DnD work in a specific dnd branch for that. I could take some part of the implementation if you wish.

martincapello commented 5 months ago

Makes sense. Merge this as is and I will continue working in a different branch. First I would like to start drafting some implementation for macOS to agree with you about the api that should be exposed to laf clients and some implementation details.