Queue a mouse move event
| 1455 | |
| 1456 | // Queue a mouse move event |
| 1457 | void ImGuiIO::AddMousePosEvent(float x, float y) |
| 1458 | { |
| 1459 | ImGuiContext& g = *GImGui; |
| 1460 | IM_ASSERT(&g.IO == this && "Can only add events to current context."); |
| 1461 | if (!AppAcceptingEvents) |
| 1462 | return; |
| 1463 | |
| 1464 | // Apply same flooring as UpdateMouseInputs() |
| 1465 | ImVec2 pos((x > -FLT_MAX) ? ImFloorSigned(x) : x, (y > -FLT_MAX) ? ImFloorSigned(y) : y); |
| 1466 | |
| 1467 | // Filter duplicate |
| 1468 | const ImGuiInputEvent* latest_event = FindLatestInputEvent(ImGuiInputEventType_MousePos); |
| 1469 | const ImVec2 latest_pos = latest_event ? ImVec2(latest_event->MousePos.PosX, latest_event->MousePos.PosY) : g.IO.MousePos; |
| 1470 | if (latest_pos.x == pos.x && latest_pos.y == pos.y) |
| 1471 | return; |
| 1472 | |
| 1473 | ImGuiInputEvent e; |
| 1474 | e.Type = ImGuiInputEventType_MousePos; |
| 1475 | e.Source = ImGuiInputSource_Mouse; |
| 1476 | e.MousePos.PosX = pos.x; |
| 1477 | e.MousePos.PosY = pos.y; |
| 1478 | g.InputEventsQueue.push_back(e); |
| 1479 | } |
| 1480 | |
| 1481 | void ImGuiIO::AddMouseButtonEvent(int mouse_button, bool down) |
| 1482 | { |
no test coverage detected