Module arcdps_imgui::drag_drop
source · Expand description
Structs to create a Drag and Drop sequence. Almost all structs are re-exported and can be accessed from the crate root; some additional utilities can be found in here.
A DragDrop is a UI mechanism where users can appear to “drag”
some data from one source to one target.
A source and a target must both have some name
identifier, which is declared when they
are created. If these names are equal, then a payload
of some kind
will be given to the target caller whne the user releases their mouse button over
the target (additionally, the UI will reflect that the payload can be deposited
in the target).
The complexity of this implementation is primarily in managing this payload. Users can provide three different kinds of payloads:
- Users can give an empty payload with begin. This payload type is essentially just a notification system, but using some shared state, this can be reasonably powerful, and is the safest way to transfer non-Copy data offered right now.
- Users can give a simple Copy payload with begin.
This allows users to copy data to Dear ImGui, which will take ownership over it, and then be given
it back to the Target. Please note: users are of course free to not drop any drag (cancel a drag),
so this data could easily be lost forever. Our
'static + Copy
bound is intended to keep users to simplistic types. - An unsafe implementation is provided which allows for any data to be unsafely copied. Note that once you use this method, the safe implementations in #1 and #2 can create memory unsafety problems; notably, they both assume that a payload has certain header information within it.
For examples of each payload type, see DragDropSource.
Structs§
- Flags for igBeginDragDropSource(), igAcceptDragDropPayload()
- An empty DragDropPayload. It has no data in it, and just includes two bools with status information.
- A DragDropPayload with status information and some POD, or plain old data, in it.
- Creates a source for drag drop data out of the last ID created.
- A helper struct for RAII drap-drop support.
- Creates a target for drag drop data out of the last ID created.
- Indicates that an incorrect payload type was received. It is opaque, but you can view useful information with Debug formatting when
debug_assertions
are enabled.