mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-12 02:00:58 +01:00
IO: io.MousePos needs to be set to ImVec2(-FLT_MAX,-FLT_MAX) when mouse is unavailable/missing. Previously ImVec2(-1,-1) was enough but we'll now accept negative mouse coordinates.
This commit is contained in:
parent
37f3a718c6
commit
92a6faca6f
@ -262,7 +262,7 @@ void ImGui_ImplA5_NewFrame()
|
||||
}
|
||||
else
|
||||
{
|
||||
io.MousePos = ImVec2(-1, -1);
|
||||
io.MousePos = ImVec2(-FLT_MAX, -FLT_MAX);
|
||||
}
|
||||
|
||||
al_get_mouse_state(&mouse);
|
||||
|
@ -272,7 +272,7 @@ void ImGui_ImplGlfw_NewFrame()
|
||||
}
|
||||
else
|
||||
{
|
||||
io.MousePos = ImVec2(-1,-1);
|
||||
io.MousePos = ImVec2(-FLT_MAX,-FLT_MAX);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
|
@ -383,7 +383,7 @@ void ImGui_ImplGlfwGL3_NewFrame()
|
||||
}
|
||||
else
|
||||
{
|
||||
io.MousePos = ImVec2(-1,-1);
|
||||
io.MousePos = ImVec2(-FLT_MAX,-FLT_MAX);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
|
@ -265,7 +265,7 @@ void ImGui_ImplSdl_NewFrame(SDL_Window *window)
|
||||
if (SDL_GetWindowFlags(window) & SDL_WINDOW_MOUSE_FOCUS)
|
||||
io.MousePos = ImVec2((float)mx, (float)my); // Mouse position, in pixels (set to -1,-1 if no mouse / on another screen, etc.)
|
||||
else
|
||||
io.MousePos = ImVec2(-1,-1);
|
||||
io.MousePos = ImVec2(-FLT_MAX,-FLT_MAX);
|
||||
|
||||
io.MouseDown[0] = g_MousePressed[0] || (mouseMask & SDL_BUTTON(SDL_BUTTON_LEFT)) != 0; // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame.
|
||||
io.MouseDown[1] = g_MousePressed[1] || (mouseMask & SDL_BUTTON(SDL_BUTTON_RIGHT)) != 0;
|
||||
|
@ -377,7 +377,7 @@ void ImGui_ImplSdlGL3_NewFrame(SDL_Window* window)
|
||||
if (SDL_GetWindowFlags(window) & SDL_WINDOW_MOUSE_FOCUS)
|
||||
io.MousePos = ImVec2((float)mx, (float)my); // Mouse position, in pixels (set to -1,-1 if no mouse / on another screen, etc.)
|
||||
else
|
||||
io.MousePos = ImVec2(-1, -1);
|
||||
io.MousePos = ImVec2(-FLT_MAX, -FLT_MAX);
|
||||
|
||||
io.MouseDown[0] = g_MousePressed[0] || (mouseMask & SDL_BUTTON(SDL_BUTTON_LEFT)) != 0; // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame.
|
||||
io.MouseDown[1] = g_MousePressed[1] || (mouseMask & SDL_BUTTON(SDL_BUTTON_RIGHT)) != 0;
|
||||
|
@ -815,7 +815,7 @@ void ImGui_ImplGlfwVulkan_NewFrame()
|
||||
}
|
||||
else
|
||||
{
|
||||
io.MousePos = ImVec2(-1,-1);
|
||||
io.MousePos = ImVec2(-FLT_MAX,-FLT_MAX);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
|
11
imgui.cpp
11
imgui.cpp
@ -204,6 +204,7 @@
|
||||
Here is a change-log of API breaking changes, if you are using one of the functions listed, expect to have to fix some code.
|
||||
Also read releases logs https://github.com/ocornut/imgui/releases for more details.
|
||||
|
||||
- 2017/08/25 (1.52) - io.MousePos needs to be set to ImVec2(-FLT_MAX,-FLT_MAX) when mouse is unavailable/missing. Previously ImVec2(-1,-1) was enough but we now accept negative mouse coordinates. In your binding if you need to support unavailable mouse, make sure to replace "io.MousePos = ImVec2(-1,-1)" with "io.MousePos = ImVec2(-FLT_MAX,-FLT_MAX)".
|
||||
- 2017/08/22 (1.51) - renamed IsItemHoveredRect() to IsItemRectHovered(). Kept inline redirection function (will obsolete).
|
||||
- renamed IsMouseHoveringAnyWindow() to IsAnyWindowHovered() for consistency. Kept inline redirection function (will obsolete).
|
||||
- renamed IsMouseHoveringWindow() to IsWindowRectHovered() for consistency. Kept inline redirection function (will obsolete).
|
||||
@ -754,8 +755,8 @@ ImGuiIO::ImGuiIO()
|
||||
FontGlobalScale = 1.0f;
|
||||
FontDefault = NULL;
|
||||
DisplayFramebufferScale = ImVec2(1.0f, 1.0f);
|
||||
MousePos = ImVec2(-1,-1);
|
||||
MousePosPrev = ImVec2(-1,-1);
|
||||
MousePos = ImVec2(-FLT_MAX, -FLT_MAX);
|
||||
MousePosPrev = ImVec2(-FLT_MAX, -FLT_MAX);
|
||||
MouseDoubleClickTime = 0.30f;
|
||||
MouseDoubleClickMaxDist = 6.0f;
|
||||
MouseDragThreshold = 6.0f;
|
||||
@ -2151,9 +2152,9 @@ void ImGui::NewFrame()
|
||||
g.RenderDrawData.CmdListsCount = g.RenderDrawData.TotalVtxCount = g.RenderDrawData.TotalIdxCount = 0;
|
||||
|
||||
// Update mouse input state
|
||||
if (g.IO.MousePos.x < 0 && g.IO.MousePos.y < 0)
|
||||
g.IO.MousePos = ImVec2(-9999.0f, -9999.0f);
|
||||
if ((g.IO.MousePos.x < 0 && g.IO.MousePos.y < 0) || (g.IO.MousePosPrev.x < 0 && g.IO.MousePosPrev.y < 0)) // if mouse just appeared or disappeared (negative coordinate) we cancel out movement in MouseDelta
|
||||
// If mouse just appeared or disappeared (usually denoted by -FLT_MAX component, but in reality we test for -256000.0f) we cancel out movement in MouseDelta
|
||||
const float MOUSE_INVALID = -256000.0f;
|
||||
if ((g.IO.MousePos.x < MOUSE_INVALID && g.IO.MousePos.y < MOUSE_INVALID) || (g.IO.MousePosPrev.x < MOUSE_INVALID && g.IO.MousePosPrev.y < MOUSE_INVALID))
|
||||
g.IO.MouseDelta = ImVec2(0.0f, 0.0f);
|
||||
else
|
||||
g.IO.MouseDelta = g.IO.MousePos - g.IO.MousePosPrev;
|
||||
|
2
imgui.h
2
imgui.h
@ -828,7 +828,7 @@ struct ImGuiIO
|
||||
// Input - Fill before calling NewFrame()
|
||||
//------------------------------------------------------------------
|
||||
|
||||
ImVec2 MousePos; // Mouse position, in pixels (set to -1,-1 if no mouse / on another screen, etc.)
|
||||
ImVec2 MousePos; // Mouse position, in pixels. Set to ImVec2(-FLT_MAX,-FLT_MAX) if mouse is unavailable (on another screen, etc.)
|
||||
bool MouseDown[5]; // Mouse buttons: left, right, middle + extras. ImGui itself mostly only uses left button (BeginPopupContext** are using right button). Others buttons allows us to track if the mouse is being used by your application + available to user as a convenience via IsMouse** API.
|
||||
float MouseWheel; // Mouse wheel: 1 unit scrolls about 5 lines text.
|
||||
bool MouseDrawCursor; // Request ImGui to draw a mouse cursor for you (if you are on a platform without a mouse cursor).
|
||||
|
Loading…
Reference in New Issue
Block a user