| 217 | |
| 218 | |
| 219 | void StyledRenderable::HandleDragDrop(DrawingContext& context) |
| 220 | { |
| 221 | if (CanDrag && DragDropType) { |
| 222 | if (ImGui::BeginDragDropSource((ImGuiDragDropFlags)DragFlags)) { |
| 223 | if (!IsDragging) { |
| 224 | if (OnDragStart) { |
| 225 | DragPreview = Manager->CreateRenderable<Group>()->Handle; |
| 226 | Manager->GetEventQueue().Call(OnDragStart, lua::ImguiHandle(Handle), lua::ImguiHandle(DragPreview)); |
| 227 | } |
| 228 | IsDragging = true; |
| 229 | } |
| 230 | |
| 231 | ImGui::SetDragDropPayload(DragDropType.GetString(), &Handle, sizeof(Handle)); |
| 232 | if (DragPreview) { |
| 233 | auto preview = Manager->GetRenderable(DragPreview); |
| 234 | if (preview) { |
| 235 | preview->Render(context); |
| 236 | } |
| 237 | } |
| 238 | ImGui::EndDragDropSource(); |
| 239 | } else if (IsDragging) { |
| 240 | Manager->GetEventQueue().Call(OnDragEnd, lua::ImguiHandle(Handle)); |
| 241 | if (DragPreview) { |
| 242 | Manager->DestroyRenderable(DragPreview); |
| 243 | DragPreview = InvalidHandle; |
| 244 | } |
| 245 | IsDragging = false; |
| 246 | } |
| 247 | } |
| 248 | |
| 249 | if (DragDropType && OnDragDrop && ImGui::BeginDragDropTarget()) |
| 250 | { |
| 251 | auto payload = ImGui::AcceptDragDropPayload(DragDropType.GetString()); |
| 252 | if (payload) { |
| 253 | auto source = *static_cast<HandleType*>(payload->Data); |
| 254 | Manager->GetEventQueue().Call(OnDragDrop, lua::ImguiHandle(Handle), lua::ImguiHandle(source)); |
| 255 | } |
| 256 | ImGui::EndDragDropTarget(); |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | |
| 261 | void StyledRenderable::DrawTooltip(DrawingContext& context) |
nothing calls this directly
no test coverage detected