-
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
Improvements to make drag-and-drop easier #3882
Comments
We should take a look at the Dear ImGui API for drag-and-drop |
I want to mention egui_dnd just as a baseline to compare an egui-builtin solution against. It only seems to support fairly simple layouts. I would like something that supports drag and drop between different uis for maximum flexibility. An example use case of mine would be to drag tree nodes in a tree. For example move |
@crumblingstatue I think a proper high-level drag-and-drop API in egui is still a little far off due to the difficulty to properly address the general case(s). This issue is more about the little things that would make lower-level implementation easier. As for the tree drag-and-drop, I just built a demo of that in the rerun repository: rerun-io/rerun#4879. I plan on making a proper egui example out of it. |
* Closes #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>
* 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>
Response
andMemory
#3876 addedmen.dragged_id()
, but there is no way to get the value of to anegui::Id
(which could then be converted to an internal Id).ctx().anything_being_decidedly_dragged()
(equivalent toui.memory(|mem| mem.is_anything_being_dragged()) && ui.input(|i| i.pointer.is_decidedly_dragging())
ctx().drag_stopped()
The text was updated successfully, but these errors were encountered: