-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add drag-and-drop APIs with payloads storage #3887
Conversation
264ec2d
to
ca0dc07
Compare
7ffd062
to
4d164ce
Compare
5123501
to
e1a7b32
Compare
d9b91a3
to
f2eeacf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm only able to use the low-level API in rerun, because of all the geometry testing I must run on my side, but the ability to store and retrieve the dnd payload (along with using its existence as a marker of on on-going drag) makes the code much cleaner and easy to reason with.
@abey79 Oh, you can't even use the |
@emilk The response API works well when moving boxes inside boxes, but not so well when moving boxes in-between boxes :) |
* Closes emilk#3882 This adds several methods to make drag-and-drop more ergonomic in egui. In particular, egui can now keep track of _what_ is being dragged for you (the _payload_). Low-level: * `egui::DragAndDrop` hold the payload during a drag Mid-level: * `Response::dnd_set_drag_payload` sets it for drag-sources * `Response::dnd_hover_payload` and `Response::dnd_release_payload` reads it for drop-targets High-level: * `ui.dnd_drag_source`: make a widget draggable * `ui.dnd_drop_zone`: a container where things can be dropped The drag-and-drop demo is now a lot simpler: https://github.com/emilk/egui/blob/emilk/drag-and-drop/crates/egui_demo_lib/src/demo/drag_and_drop.rs --------- Co-authored-by: Antoine Beyeler <abeyeler@ab-ware.com>
This adds several methods to make drag-and-drop more ergonomic in egui.
In particular, egui can now keep track of what is being dragged for you (the payload).
Low-level:
egui::DragAndDrop
hold the payload during a dragMid-level:
Response::dnd_set_drag_payload
sets it for drag-sourcesResponse::dnd_hover_payload
andResponse::dnd_release_payload
reads it for drop-targetsHigh-level:
ui.dnd_drag_source
: make a widget draggableui.dnd_drop_zone
: a container where things can be droppedThe drag-and-drop demo is now a lot simpler:
https://github.com/emilk/egui/blob/emilk/drag-and-drop/crates/egui_demo_lib/src/demo/drag_and_drop.rs