Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drag and drop support in druid-shell #1742

Open
futurepaul opened this issue Apr 27, 2021 · 7 comments
Open

Drag and drop support in druid-shell #1742

futurepaul opened this issue Apr 27, 2021 · 7 comments
Labels
enhancement adds or requests a new feature shell concerns the shell abstraction

Comments

@futurepaul
Copy link
Collaborator

This is mentioned in the "longer term future" section of the druid-shell roadmap. Perhaps we're getting close?

My personal use case is to drag files from the filesystem onto the window, ideally with a sub-window drop location.

For implementation reference, Winit has DroppedFile / HoveredFile / HoveredFileCancelled events for mac, windows, and x11. I wasn't able to find the precise way this is done in GTK... drag and drop are a little bit overloaded terms.

@futurepaul futurepaul added enhancement adds or requests a new feature shell concerns the shell abstraction labels Apr 27, 2021
@Pancir
Copy link

Pancir commented May 13, 2021

In addition to the previous use case I have another.

I'm creating an application for images management.
My use case is to drag an image from one view to another using drop coordinates to place the image in the certain location.

@SecondFlight
Copy link
Collaborator

SecondFlight commented May 13, 2021

from one view to another

@Pancir Are you talking about dragging an image from the filesystem or from another app, or are you talking about dragging an image from one place in your app to another? If it's the second then I think this may be a different concern. It could make sense to write a drag-and-drop utility widget that facilitates some of this.

@Pancir
Copy link

Pancir commented May 14, 2021

@SecondFlight

  1. dragging an image from one place in your app to another

  2. from file system as well (as previous author wrote)

Perhaps, I am not sure yet, dragging a label on image too, this will just add a text tag to the image.

@SecondFlight
Copy link
Collaborator

Okay, thanks for clarifying!

@cmyr
Copy link
Member

cmyr commented May 16, 2021

Dragging within your app is definitely something you could build now, although it would require some hacking. Full system-wide drag & drop support will be a fairly large project, and would need research and some sort of RFC/design proposal.

@Boscop
Copy link

Boscop commented May 23, 2021

Note that winit's drag & drop support is not really useable if you have multiple drop areas in your app and want to know which drop area received the file. winit doesn't give you the mouse pos at the time when the DroppedFile event happens:
rust-windowing/winit#1550 (comment)

I also have a use case where my GUI needs drag & drop between ui elements and drag & drop from windows explorer onto different drop areas in the UI. winit doesn't give me the mouse pos while the file-dragging cursor is hovering over the window, so I can't highlight the hovered drop target.

I have a partial workaround for winit, described here: tauri-apps/tao#62
but that's only for getting the mouse pos in the same frame where DroppedFile happens.
It doesn't help with getting mouse pos while the file-dragging cursor is hovering/moving before dropping (for highlighting the hovered drop target).

Druid has a chance to get this right from the start :)

The fix is simple:
winit (or druid-shell in this case) should send CursorEntered event as soon as the file-dragging cursor moves over the window, and continuously send CursorMoved events as the cursor moves.

@cmyr
Copy link
Member

cmyr commented Jun 28, 2021

another piece of potentially useful prior-art for this feature:

https://matejknopp.com/post/introducing-nativeshell/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement adds or requests a new feature shell concerns the shell abstraction
Projects
None yet
Development

No branches or pull requests

5 participants