Queue a mouse move event
| 1414 | |
| 1415 | // Queue a mouse move event |
| 1416 | void ImGuiIO::AddMousePosEvent(float x, float y) |
| 1417 | { |
| 1418 | ImGuiContext& g = *GImGui; |
| 1419 | IM_ASSERT(&g.IO == this && "Can only add events to current context."); |
| 1420 | if (!AppAcceptingEvents) |
| 1421 | return; |
| 1422 | |
| 1423 | // Apply same flooring as UpdateMouseInputs() |
| 1424 | ImVec2 pos((x > -FLT_MAX) ? ImFloorSigned(x) : x, (y > -FLT_MAX) ? ImFloorSigned(y) : y); |
| 1425 | |
| 1426 | // Filter duplicate |
| 1427 | const ImGuiInputEvent* latest_event = FindLatestInputEvent(ImGuiInputEventType_MousePos); |
| 1428 | const ImVec2 latest_pos = latest_event ? ImVec2(latest_event->MousePos.PosX, latest_event->MousePos.PosY) : g.IO.MousePos; |
| 1429 | if (latest_pos.x == pos.x && latest_pos.y == pos.y) |
| 1430 | return; |
| 1431 | |
| 1432 | ImGuiInputEvent e; |
| 1433 | e.Type = ImGuiInputEventType_MousePos; |
| 1434 | e.Source = ImGuiInputSource_Mouse; |
| 1435 | e.MousePos.PosX = pos.x; |
| 1436 | e.MousePos.PosY = pos.y; |
| 1437 | g.InputEventsQueue.push_back(e); |
| 1438 | } |
| 1439 | |
| 1440 | void ImGuiIO::AddMouseButtonEvent(int mouse_button, bool down) |
| 1441 | { |
no test coverage detected