Nav/Examples: honoring the io.WantMoveMouse flag in most common examples (#323)

Missing support Vulkan (#549), Apple (#575, #247), SDL (#58, #356),
Allegro, Marmalade (#368, #375)
docking
ocornut 8 years ago committed by omar
parent 1ff27d7db8
commit d5d825debb

@ -89,3 +89,4 @@ vulkan_example/
Vulkan example. Vulkan example.
This is quite long and tedious, because: Vulkan. This is quite long and tedious, because: Vulkan.
TODO: Apple, SDL GL/GL3, Allegro, Marmalade, Vulkan examples do not honor the io.WantMoveMouse flag.

@ -572,6 +572,14 @@ void ImGui_ImplDX10_NewFrame()
// io.MouseDown : filled by WM_*BUTTON* events // io.MouseDown : filled by WM_*BUTTON* events
// io.MouseWheel : filled by WM_MOUSEWHEEL events // io.MouseWheel : filled by WM_MOUSEWHEEL events
// Set OS mouse position if requested last frame by io.WantMoveMouse flag (used when io.NavMovesTrue is enabled by user and using directional navigation)
if (io.WantMoveMouse)
{
POINT pos = { (int)io.MousePos.x, (int)io.MousePos.y };
ClientToScreen(g_hWnd, &pos);
SetCursorPos(pos.x, pos.y);
}
// Hide OS mouse cursor if ImGui is drawing it // Hide OS mouse cursor if ImGui is drawing it
if (io.MouseDrawCursor) if (io.MouseDrawCursor)
SetCursor(NULL); SetCursor(NULL);

@ -575,6 +575,14 @@ void ImGui_ImplDX11_NewFrame()
// io.MouseDown : filled by WM_*BUTTON* events // io.MouseDown : filled by WM_*BUTTON* events
// io.MouseWheel : filled by WM_MOUSEWHEEL events // io.MouseWheel : filled by WM_MOUSEWHEEL events
// Set OS mouse position if requested last frame by io.WantMoveMouse flag (used when io.NavMovesTrue is enabled by user and using directional navigation)
if (io.WantMoveMouse)
{
POINT pos = { (int)io.MousePos.x, (int)io.MousePos.y };
ClientToScreen(g_hWnd, &pos);
SetCursorPos(pos.x, pos.y);
}
// Hide OS mouse cursor if ImGui is drawing it // Hide OS mouse cursor if ImGui is drawing it
if (io.MouseDrawCursor) if (io.MouseDrawCursor)
SetCursor(NULL); SetCursor(NULL);

@ -349,6 +349,14 @@ void ImGui_ImplDX9_NewFrame()
// io.MouseDown : filled by WM_*BUTTON* events // io.MouseDown : filled by WM_*BUTTON* events
// io.MouseWheel : filled by WM_MOUSEWHEEL events // io.MouseWheel : filled by WM_MOUSEWHEEL events
// Set OS mouse position if requested last frame by io.WantMoveMouse flag (used when io.NavMovesTrue is enabled by user and using directional navigation)
if (io.WantMoveMouse)
{
POINT pos = { (int)io.MousePos.x, (int)io.MousePos.y };
ClientToScreen(g_hWnd, &pos);
SetCursorPos(pos.x, pos.y);
}
// Hide OS mouse cursor if ImGui is drawing it // Hide OS mouse cursor if ImGui is drawing it
if (io.MouseDrawCursor) if (io.MouseDrawCursor)
SetCursor(NULL); SetCursor(NULL);

@ -268,10 +268,17 @@ void ImGui_ImplGlfwGL2_NewFrame()
// Setup inputs // Setup inputs
// (we already got mouse wheel, keyboard keys & characters from glfw callbacks polled in glfwPollEvents()) // (we already got mouse wheel, keyboard keys & characters from glfw callbacks polled in glfwPollEvents())
if (glfwGetWindowAttrib(g_Window, GLFW_FOCUSED)) if (glfwGetWindowAttrib(g_Window, GLFW_FOCUSED))
{
if (io.WantMoveMouse)
{
glfwSetCursorPos(g_Window, (double)io.MousePos.x, (double)io.MousePos.y); // Set mouse position if requested by io.WantMoveMouse flag (used when io.NavMovesTrue is enabled by user and using directional navigation)
}
else
{ {
double mouse_x, mouse_y; double mouse_x, mouse_y;
glfwGetCursorPos(g_Window, &mouse_x, &mouse_y); glfwGetCursorPos(g_Window, &mouse_x, &mouse_y);
io.MousePos = ImVec2((float)mouse_x, (float)mouse_y); // Mouse position in screen coordinates (set to -1,-1 if no mouse / on another screen, etc.) io.MousePos = ImVec2((float)mouse_x, (float)mouse_y); // Get mouse position in screen coordinates (set to -1,-1 if no mouse / on another screen, etc.)
}
} }
else else
{ {

@ -382,10 +382,17 @@ void ImGui_ImplGlfwGL3_NewFrame()
// Setup inputs // Setup inputs
// (we already got mouse wheel, keyboard keys & characters from glfw callbacks polled in glfwPollEvents()) // (we already got mouse wheel, keyboard keys & characters from glfw callbacks polled in glfwPollEvents())
if (glfwGetWindowAttrib(g_Window, GLFW_FOCUSED)) if (glfwGetWindowAttrib(g_Window, GLFW_FOCUSED))
{
if (io.WantMoveMouse)
{
glfwSetCursorPos(g_Window, (double)io.MousePos.x, (double)io.MousePos.y); // Set mouse position if requested by io.WantMoveMouse flag (used when io.NavMovesTrue is enabled by user and using directional navigation)
}
else
{ {
double mouse_x, mouse_y; double mouse_x, mouse_y;
glfwGetCursorPos(g_Window, &mouse_x, &mouse_y); glfwGetCursorPos(g_Window, &mouse_x, &mouse_y);
io.MousePos = ImVec2((float)mouse_x, (float)mouse_y); // Mouse position in screen coordinates (set to -1,-1 if no mouse / on another screen, etc.) io.MousePos = ImVec2((float)mouse_x, (float)mouse_y); // Get mouse position in screen coordinates (set to -1,-1 if no mouse / on another screen, etc.)
}
} }
else else
{ {

Loading…
Cancel
Save