1
0
Fork 0
mirror of https://github.com/ocornut/imgui.git synced 2026-01-29 03:00:05 +00:00

Merge branch 'master' into docking

This commit is contained in:
ocornut 2023-09-20 12:53:35 +02:00
commit 3ce6b06feb
4 changed files with 19 additions and 6 deletions

View file

@ -8493,6 +8493,7 @@ bool ImGui::IsRectVisible(const ImVec2& rect_min, const ImVec2& rect_max)
// - IsMouseDragPastThreshold() [Internal]
// - IsMouseDragging()
// - GetMousePos()
// - SetMousePos() [Internal]
// - GetMousePosOnOpeningCurrentPopup()
// - IsMousePosValid()
// - IsAnyMouseDown()
@ -9022,6 +9023,17 @@ ImVec2 ImGui::GetMousePos()
return g.IO.MousePos;
}
// This is called TeleportMousePos() and not SetMousePos() to emphasis that setting MousePosPrev will effectively clear mouse delta as well.
// It is expected you only call this if (io.BackendFlags & ImGuiBackendFlags_HasSetMousePos) is set and supported by backend.
void ImGui::TeleportMousePos(const ImVec2& pos)
{
ImGuiContext& g = *GImGui;
g.IO.MousePos = g.IO.MousePosPrev = pos;
g.IO.MouseDelta = ImVec2(0.0f, 0.0f);
g.IO.WantSetMousePos = true;
//IMGUI_DEBUG_LOG_IO("TeleportMousePos: (%.1f,%.1f)\n", io.MousePos.x, io.MousePos.y);
}
// NB: prefer to call right after BeginPopup(). At the time Selectable/MenuItem is activated, the popup is already closed!
ImVec2 ImGui::GetMousePosOnOpeningCurrentPopup()
{
@ -9514,6 +9526,8 @@ void ImGui::UpdateInputEvents(bool trickle_fast_inputs)
ImGuiInputEvent* e = &g.InputEventsQueue[event_n];
if (e->Type == ImGuiInputEventType_MousePos)
{
if (g.IO.WantSetMousePos)
continue;
// Trickling Rule: Stop processing queued events if we already handled a mouse button change
ImVec2 event_pos(e->MousePos.PosX, e->MousePos.PosY);
if (trickle_fast_inputs && (mouse_button_changed != 0 || mouse_wheeled || key_changed || text_inputted))
@ -12219,11 +12233,7 @@ static void ImGui::NavUpdate()
// Update mouse position if requested
// (This will take into account the possibility that a Scroll was queued in the window to offset our absolute mouse position before scroll has been applied)
if (set_mouse_pos && (io.ConfigFlags & ImGuiConfigFlags_NavEnableSetMousePos) && (io.BackendFlags & ImGuiBackendFlags_HasSetMousePos))
{
io.MousePos = io.MousePosPrev = NavCalcPreferredRefPos();
io.WantSetMousePos = true;
//IMGUI_DEBUG_LOG_IO("SetMousePos: (%.1f,%.1f)\n", io.MousePos.x, io.MousePos.y);
}
TeleportMousePos(NavCalcPreferredRefPos());
// [DEBUG]
g.NavScoringDebugCount = 0;