mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-04 03:58:47 +02:00
Allow easily implementing wrapping behaviors.
This commit is contained in:
18
imgui.cpp
18
imgui.cpp
@ -7888,6 +7888,7 @@ bool ImGui::IsRectVisible(const ImVec2& rect_min, const ImVec2& rect_max)
|
||||
// - IsMouseDragPastThreshold() [Internal]
|
||||
// - IsMouseDragging()
|
||||
// - GetMousePos()
|
||||
// - SetMousePos() [Internal]
|
||||
// - GetMousePosOnOpeningCurrentPopup()
|
||||
// - IsMousePosValid()
|
||||
// - IsAnyMouseDown()
|
||||
@ -8415,6 +8416,15 @@ ImVec2 ImGui::GetMousePos()
|
||||
return g.IO.MousePos;
|
||||
}
|
||||
|
||||
// It is expected you only call this if (io.BackendFlags & ImGuiBackendFlags_HasSetMousePos) is set and supported by backend.
|
||||
void ImGui::SetMousePos(const ImVec2& pos)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
g.IO.MousePos = g.IO.MousePosPrev = pos;
|
||||
g.IO.WantSetMousePos = true;
|
||||
//IMGUI_DEBUG_LOG_IO("SetMousePos: (%.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()
|
||||
{
|
||||
@ -8903,6 +8913,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))
|
||||
@ -11550,11 +11562,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);
|
||||
}
|
||||
SetMousePos(NavCalcPreferredRefPos());
|
||||
|
||||
// [DEBUG]
|
||||
g.NavScoringDebugCount = 0;
|
||||
|
Reference in New Issue
Block a user