Add drag-and-drop APIs with payloads storage#3887
Merged
Conversation
264ec2d to
ca0dc07
Compare
7ffd062 to
4d164ce
Compare
5123501 to
e1a7b32
Compare
d9b91a3 to
f2eeacf
Compare
abey79
approved these changes
Jan 26, 2024
Collaborator
abey79
left a comment
There was a problem hiding this comment.
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.
Owner
Author
|
@abey79 Oh, you can't even use the |
Collaborator
|
@emilk The response API works well when moving boxes inside boxes, but not so well when moving boxes in-between boxes :) |
hacknus
pushed a commit
to hacknus/egui
that referenced
this pull request
Oct 30, 2024
* 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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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::DragAndDrophold the payload during a dragMid-level:
Response::dnd_set_drag_payloadsets it for drag-sourcesResponse::dnd_hover_payloadandResponse::dnd_release_payloadreads 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