Module imgui::drag_drop[][src]

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:

  1. 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.
  2. 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.
  3. 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

DragDropFlags

Flags for igBeginDragDropSource(), igAcceptDragDropPayload()

DragDropPayload
DragDropPayloadEmpty

An empty DragDropPayload. It has no data in it, and just includes two bools with status information.

DragDropPayloadPod

A DragDropPayload with status information and some POD, or plain old data, in it.

DragDropSource

Creates a source for drag drop data out of the last ID created.

DragDropSourceToolTip

A helper struct for RAII drap-drop support.

DragDropTarget

Creates a target for drag drop data out of the last ID created.

PayloadIsWrongType

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.