#pragma once #include #include namespace XCEngine::UI::Editor::Collections::GridDragDrop { using ::XCEngine::UI::UIPoint; using DragDropInteraction::kDefaultDragThreshold; using DragDropInteraction::ProcessResult; using DragDropInteraction::State; inline void ResetTransientRequests(State& state) { DragDropInteraction::ResetTransientRequests(state); } inline bool HasActivePointerCapture(const State& state) { return DragDropInteraction::HasActivePointerCapture(state); } template ProcessResult ProcessInputEvents( State& state, const std::vector& inputEvents, Callbacks& callbacks, float dragThreshold = kDefaultDragThreshold) { struct AdaptedCallbacks { Callbacks& callbacks; std::string ResolveDraggableItem(const UIPoint& point) const { return callbacks.ResolveDraggableItem(point); } void ResetDropTarget(State& state) const { state.dropTargetItemId.clear(); state.validDropTarget = false; } void UpdateDropTarget( State& state, std::string_view draggedItemId, const UIPoint& point) const { state.dropTargetItemId = callbacks.ResolveDropTargetItem(draggedItemId, point); state.validDropTarget = !state.dropTargetItemId.empty() && callbacks.CanDropOnItem(draggedItemId, state.dropTargetItemId); } bool IsItemSelected(std::string_view itemId) const { return callbacks.IsItemSelected(itemId); } bool SelectDraggedItem(std::string_view itemId) const { return callbacks.SelectDraggedItem(itemId); } bool CommitDrop(State& state, ProcessResult&) const { return callbacks.CommitDropOnItem( state.draggedItemId, state.dropTargetItemId); } } adaptedCallbacks{ callbacks }; return DragDropInteraction::ProcessInputEvents( state, inputEvents, adaptedCallbacks, dragThreshold); } } // namespace XCEngine::UI::Editor::Collections::GridDragDrop