27 inline constexpr uint32_t
Image = 0xFFFF0001u;
28 inline constexpr uint32_t
Files = 0xFFFF0002u;
38 std::span<const uint8_t>
rgba;
72 int2 m_dragStartScreenPos{ 0, 0 };
73 uint32_t m_dragPayloadType = 0;
74 uintptr_t m_dragPayloadValue = 0;
75 std::any m_dragPayload;
89 uint32_t m_dragEventPayloadType = 0;
90 uintptr_t m_dragEventPayloadValue = 0;
91 std::any m_dragEventPayload;
94 ID ResolveDropTarget(
ID hoveredID)
const;
96 void SetEventPayload(
ID sourceID, uint32_t payloadType, uintptr_t payloadValue);
124 const std::any&
GetEventPayload()
const {
return m_dragEventPayload.has_value() ? m_dragEventPayload : m_dragPayload; }
130 void Begin(
ID sourceID, uint32_t payloadType, uintptr_t payloadValue,
int2 startScreenPos,
Drag-and-drop state, owned by GUIStateManager.
Definition gui_drag_drop_state.h:68
void SetStartDistance(int32_t pixels)
Pointer travel in pixels before a pending drag starts.
Definition gui_drag_drop_state.h:135
ID GetDragOverID() const
Definition gui_drag_drop_state.h:102
void SetFrameVisualizerOverride(DragVisualizer visualizer)
Definition gui_drag_drop_state.h:143
const std::any & GetPayload() const
Definition gui_drag_drop_state.h:121
void UpdateFromInput(const InputState &in)
ID GetEnterTargetID() const
Definition gui_drag_drop_state.h:109
bool IsDragging() const
Definition gui_drag_drop_state.h:100
void Begin(ID sourceID, uint32_t payloadType, uintptr_t payloadValue, int2 startScreenPos, std::any payload={}, DragVisualizer sourceVisualizer={})
Arms a pending drag from sourceID; ignored for an Invalid source or payload type 0.
void EndFrameUpdate(ID hoveredForDrop, bool leftButtonDown)
bool IsDropTargetFor(ID id, uint32_t acceptedPayloadType=0) const
True when an active drag is over id and its payload type is acceptedPayloadType (0 accepts any type).
void SetValidatedTargetID(ID validated, ID taker)
The element under the pointer whose chain took the drag (validated), and the one in that chain that t...
Definition gui_drag_drop_state.h:140
ID GetOutTargetID() const
Definition gui_drag_drop_state.h:111
uintptr_t GetPayloadValue() const
Definition gui_drag_drop_state.h:103
void SetSourceVisualizer(DragVisualizer sourceVisualizer)
ID GetOverTargetID() const
Definition gui_drag_drop_state.h:110
ID GetDropTargetID() const
Definition gui_drag_drop_state.h:112
ID GetDraggedID() const
Definition gui_drag_drop_state.h:101
ID GetValidatedTargetID() const
Definition gui_drag_drop_state.h:113
bool InvokeActiveVisualizer(const DragVisualContext &context) const
ID GetTakerID() const
The element whose handler took the drag under the pointer: the validated target or one of its ancesto...
Definition gui_drag_drop_state.h:116
uint32_t GetEventPayloadType() const
Definition gui_drag_drop_state.h:119
const std::any & GetEventPayload() const
The payload the drag events of this frame carry: the drag's own, or the one just dropped (the drag it...
Definition gui_drag_drop_state.h:124
void ClearFrameVisualizerOverride()
uintptr_t GetEventPayloadValue() const
Definition gui_drag_drop_state.h:120
void SetValidatedTargetID(ID id)
Definition gui_drag_drop_state.h:141
ID GetEventSourceID() const
Definition gui_drag_drop_state.h:118
void ClearEvents()
Clears per-frame events. GUIStateManager::EndFrame calls it; the input manager may too.
std::function< void(const DragVisualContext &context)> DragVisualizer
Draws the dragged item while a drag is in progress.
Definition gui_drag_drop_state.h:62
ImageIndex
Index of an image in the graphics context's image set, as the shaders sample it.
Definition gui_image.h:99
Payload types the library defines, for payloads any control may take.
Definition gui_drag_drop_state.h:26
constexpr uint32_t Image
a DraggedImage
Definition gui_drag_drop_state.h:27
constexpr uint32_t Files
a DraggedFiles
Definition gui_drag_drop_state.h:28
Definition gui_logging.h:24
What a DragVisualizer draws from: the pointer, the source and target, and the payload.
Definition gui_drag_drop_state.h:49
uintptr_t payloadValue
Definition gui_drag_drop_state.h:57
ID targetID
Definition gui_drag_drop_state.h:52
uint32_t payloadType
Definition gui_drag_drop_state.h:56
const std::any * payload
Definition gui_drag_drop_state.h:58
tachyon::int2 screenPos
Definition gui_drag_drop_state.h:50
bool leftMouseDown
Definition gui_drag_drop_state.h:54
bool isDropValid
Definition gui_drag_drop_state.h:53
ID sourceID
Definition gui_drag_drop_state.h:51
Files being dragged inside the application (DragPayload::Files): paths, UTF-8.
Definition gui_drag_drop_state.h:43
std::vector< std::string > paths
Definition gui_drag_drop_state.h:44
A picture being dragged (DragPayload::Image).
Definition gui_drag_drop_state.h:35
std::span< const uint8_t > rgba
size.x * size.y * 4 bytes; empty when only drawn
Definition gui_drag_drop_state.h:38
uint2 size
in pixels
Definition gui_drag_drop_state.h:37
ImageIndex image
the registered image, for drawing it
Definition gui_drag_drop_state.h:36
A 64-bit element ID whose bit layout depends on its IDMode.
Definition gui_id.h:23
static constexpr ID Invalid()
The "no element" ID (all bits zero); also the default for optional ID parameters.
Definition gui_id.h:66
Integer 2D vector.
Definition gui_base_types.h:18
Definition gui_base_types.h:74