mirror of
				https://github.com/Drezil/imgui.git
				synced 2025-10-30 20:51:06 +01:00 
			
		
		
		
	IO: Added ImGuiConfigFlags_NoSetMouseCursors. Added ImGuiBackendFlags_HasMouseCursors, ImGuiBackendFlags_HasSetMousePos. (#787, #1495, #1202)
This commit is contained in:
		| @@ -91,6 +91,8 @@ Other Changes: | ||||
| - Context: Removed allocator parameters from CreateContext(), they are now setup with SetAllocatorFunctions() and shared by all contexts. (#1565, #586, #992, #1007, #1558) | ||||
| - Context: You may pass a ImFontAtlas to CreateContext() to specify a font atlas to share. Shared font atlas are not owned by the context and not destroyed along with it. | ||||
| - Context: Added IMGUI_DISABLE_DEFAULT_ALLOCATORS to disable linking with malloc/free. (#1565, #586, #992, #1007, #1558) | ||||
| - IO: Added io.ConfigFlags for user application to store settings for imgui and for the back-end (currently: _NavEnableKeyboard, _NavEnableGamepad, _NavEnableSetMousePos, _NoSetMouseCursor). | ||||
| - IO: Added io.BackendFlags for back-end to store its capabilities (currently: _HasGamepad, _HasMouseCursors, _HasSetMousePos). This will be used more in the next version. | ||||
| - IO: Added ImGuiKey_Insert, ImGuiKey_Space keys. Setup in all example bindings. (#1541) | ||||
| - IO: Added Horizontal Mouse Wheel support for horizontal scrolling. (#1463) [@tseeker] | ||||
| - IO: Added IsAnyMouseDown() helper which is helpful for bindings to handle mouse capturing. | ||||
| @@ -159,6 +161,7 @@ Other Changes: | ||||
| - Examples: Files in examples/ now include their own changelog so it is easier to occasionally update your bindings if needed. | ||||
| - Examples: Using Dark theme by default. (#707). Tweaked demo code. | ||||
| - Examples: Added support for horizontal mouse wheel for API that allows it. (#1463) [@tseeker] | ||||
| - Examples: All examples now setup the io.BackendFlags to signify they can honor mouse cursors, gamepad, etc. | ||||
| - Examples: DirectX12: Added DirectX 12 example. (#301) [@jdm3] | ||||
| - Examples: OpenGL3+GLFW,SDL: Changed GLSL shader version from 330 to 150. (#1466, #1504) | ||||
| - Examples: OpenGL3+GLFW,SDL: Added a way to override the GLSL version string in the Init function. (#1466, #1504). | ||||
|   | ||||
| @@ -10,6 +10,7 @@ | ||||
|  | ||||
| // CHANGELOG  | ||||
| // (minor and older changes stripped away, please see git history for details) | ||||
| //  2018-03-20: Misc: Setup io.BackendFlags ImGuiBackendFlags_HasMouseCursors and ImGuiBackendFlags_HasSetMousePos flags + honor ImGuiConfigFlags_NoSetMouseCursor flag. | ||||
| //  2018-02-20: Inputs: Added support for mouse cursors (ImGui::GetMouseCursor() value and WM_SETCURSOR message handling). | ||||
| //  2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_ImplDX10_RenderDrawData() in the .h file so you can call it yourself. | ||||
| //  2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves. | ||||
| @@ -243,9 +244,12 @@ void ImGui_ImplDX10_RenderDrawData(ImDrawData* draw_data) | ||||
|     ctx->IASetInputLayout(old.InputLayout); if (old.InputLayout) old.InputLayout->Release(); | ||||
| } | ||||
|  | ||||
| static void ImGui_ImplWin32_UpdateMouseCursor() | ||||
| static bool ImGui_ImplWin32_UpdateMouseCursor() | ||||
| { | ||||
|     ImGuiIO& io = ImGui::GetIO(); | ||||
|     if (io.ConfigFlags & ImGuiConfigFlags_NoSetMouseCursor) | ||||
|         return false; | ||||
|  | ||||
|     ImGuiMouseCursor imgui_cursor = io.MouseDrawCursor ? ImGuiMouseCursor_None : ImGui::GetMouseCursor(); | ||||
|     if (imgui_cursor == ImGuiMouseCursor_None) | ||||
|     { | ||||
| @@ -268,6 +272,7 @@ static void ImGui_ImplWin32_UpdateMouseCursor() | ||||
|         } | ||||
|         ::SetCursor(::LoadCursor(NULL, win32_cursor)); | ||||
|     } | ||||
|     return true; | ||||
| } | ||||
|  | ||||
| // Process Win32 mouse/keyboard inputs.  | ||||
| @@ -337,11 +342,8 @@ IMGUI_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARAM wPa | ||||
|             io.AddInputCharacter((unsigned short)wParam); | ||||
|         return 0; | ||||
|     case WM_SETCURSOR: | ||||
|         if (LOWORD(lParam) == HTCLIENT) | ||||
|         { | ||||
|             ImGui_ImplWin32_UpdateMouseCursor(); | ||||
|         if (LOWORD(lParam) == HTCLIENT && ImGui_ImplWin32_UpdateMouseCursor()) | ||||
|             return 1; | ||||
|         } | ||||
|         return 0; | ||||
|     } | ||||
|     return 0; | ||||
| @@ -584,8 +586,13 @@ bool    ImGui_ImplDX10_Init(void* hwnd, ID3D10Device* device) | ||||
|     if (!QueryPerformanceCounter((LARGE_INTEGER *)&g_Time)) | ||||
|         return false; | ||||
|  | ||||
|     // Setup back-end capabilities flags | ||||
|     ImGuiIO& io = ImGui::GetIO(); | ||||
|     io.KeyMap[ImGuiKey_Tab] = VK_TAB;                       // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array that we will update during the application lifetime. | ||||
|     io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors;   // We can honor GetMouseCursor() values | ||||
|     io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos;    // We can honor io.WantSetMousePos requests (optional, rarely used) | ||||
|  | ||||
|     // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array that we will update during the application lifetime. | ||||
|     io.KeyMap[ImGuiKey_Tab] = VK_TAB; | ||||
|     io.KeyMap[ImGuiKey_LeftArrow] = VK_LEFT; | ||||
|     io.KeyMap[ImGuiKey_RightArrow] = VK_RIGHT; | ||||
|     io.KeyMap[ImGuiKey_UpArrow] = VK_UP; | ||||
|   | ||||
| @@ -10,6 +10,7 @@ | ||||
|  | ||||
| // CHANGELOG | ||||
| // (minor and older changes stripped away, please see git history for details) | ||||
| //  2018-03-20: Misc: Setup io.BackendFlags ImGuiBackendFlags_HasMouseCursors and ImGuiBackendFlags_HasSetMousePos flags + honor ImGuiConfigFlags_NoSetMouseCursor flag. | ||||
| //  2018-02-20: Inputs: Added support for mouse cursors (ImGui::GetMouseCursor() value and WM_SETCURSOR message handling). | ||||
| //  2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_ImplDX11_RenderDrawData() in the .h file so you can call it yourself. | ||||
| //  2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves. | ||||
| @@ -250,9 +251,12 @@ void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data) | ||||
|     ctx->IASetInputLayout(old.InputLayout); if (old.InputLayout) old.InputLayout->Release(); | ||||
| } | ||||
|  | ||||
| static void ImGui_ImplWin32_UpdateMouseCursor() | ||||
| static bool ImGui_ImplWin32_UpdateMouseCursor() | ||||
| { | ||||
|     ImGuiIO& io = ImGui::GetIO(); | ||||
|     if (io.ConfigFlags & ImGuiConfigFlags_NoSetMouseCursor) | ||||
|         return false; | ||||
|  | ||||
|     ImGuiMouseCursor imgui_cursor = io.MouseDrawCursor ? ImGuiMouseCursor_None : ImGui::GetMouseCursor(); | ||||
|     if (imgui_cursor == ImGuiMouseCursor_None) | ||||
|     { | ||||
| @@ -275,6 +279,7 @@ static void ImGui_ImplWin32_UpdateMouseCursor() | ||||
|         } | ||||
|         ::SetCursor(::LoadCursor(NULL, win32_cursor)); | ||||
|     } | ||||
|     return true; | ||||
| } | ||||
|  | ||||
| // Process Win32 mouse/keyboard inputs.  | ||||
| @@ -344,11 +349,8 @@ IMGUI_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARAM wPa | ||||
|             io.AddInputCharacter((unsigned short)wParam); | ||||
|         return 0; | ||||
|     case WM_SETCURSOR: | ||||
|         if (LOWORD(lParam) == HTCLIENT) | ||||
|         { | ||||
|             ImGui_ImplWin32_UpdateMouseCursor(); | ||||
|         if (LOWORD(lParam) == HTCLIENT && ImGui_ImplWin32_UpdateMouseCursor()) | ||||
|             return 1; | ||||
|         } | ||||
|         return 0; | ||||
|     } | ||||
|     return 0; | ||||
| @@ -586,8 +588,13 @@ bool    ImGui_ImplDX11_Init(void* hwnd, ID3D11Device* device, ID3D11DeviceContex | ||||
|     if (!QueryPerformanceCounter((LARGE_INTEGER *)&g_Time)) | ||||
|         return false; | ||||
|  | ||||
|     // Setup back-end capabilities flags | ||||
|     ImGuiIO& io = ImGui::GetIO(); | ||||
|     io.KeyMap[ImGuiKey_Tab] = VK_TAB;                       // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array that we will update during the application lifetime. | ||||
|     io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors;   // We can honor GetMouseCursor() values (optional) | ||||
|     io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos;    // We can honor io.WantSetMousePos requests (optional, rarely used) | ||||
|  | ||||
|     // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array that we will update during the application lifetime. | ||||
|     io.KeyMap[ImGuiKey_Tab] = VK_TAB; | ||||
|     io.KeyMap[ImGuiKey_LeftArrow] = VK_LEFT; | ||||
|     io.KeyMap[ImGuiKey_RightArrow] = VK_RIGHT; | ||||
|     io.KeyMap[ImGuiKey_UpArrow] = VK_UP; | ||||
|   | ||||
| @@ -11,6 +11,7 @@ | ||||
|  | ||||
| // CHANGELOG | ||||
| // (minor and older changes stripped away, please see git history for details) | ||||
| //  2018-03-20: Misc: Setup io.BackendFlags ImGuiBackendFlags_HasMouseCursors and ImGuiBackendFlags_HasSetMousePos flags + honor ImGuiConfigFlags_NoSetMouseCursor flag. | ||||
| //  2018-02-22: Merged into master with all Win32 code synchronized to other examples. | ||||
|  | ||||
| #include "imgui.h" | ||||
| @@ -221,9 +222,12 @@ void ImGui_ImplDX12_RenderDrawData(ImDrawData* draw_data) | ||||
|     } | ||||
| } | ||||
|  | ||||
| static void ImGui_ImplWin32_UpdateMouseCursor() | ||||
| static bool ImGui_ImplWin32_UpdateMouseCursor() | ||||
| { | ||||
|     ImGuiIO& io = ImGui::GetIO(); | ||||
|     if (io.ConfigFlags & ImGuiConfigFlags_NoSetMouseCursor) | ||||
|         return false; | ||||
|  | ||||
|     ImGuiMouseCursor imgui_cursor = io.MouseDrawCursor ? ImGuiMouseCursor_None : ImGui::GetMouseCursor(); | ||||
|     if (imgui_cursor == ImGuiMouseCursor_None) | ||||
|     { | ||||
| @@ -246,6 +250,7 @@ static void ImGui_ImplWin32_UpdateMouseCursor() | ||||
|         } | ||||
|         ::SetCursor(::LoadCursor(NULL, win32_cursor)); | ||||
|     } | ||||
|     return true; | ||||
| } | ||||
|  | ||||
| // Process Win32 mouse/keyboard inputs.  | ||||
| @@ -315,11 +320,8 @@ IMGUI_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARAM wPa | ||||
|             io.AddInputCharacter((unsigned short)wParam); | ||||
|         return 0; | ||||
|     case WM_SETCURSOR: | ||||
|         if (LOWORD(lParam) == HTCLIENT) | ||||
|         { | ||||
|             ImGui_ImplWin32_UpdateMouseCursor(); | ||||
|         if (LOWORD(lParam) == HTCLIENT && ImGui_ImplWin32_UpdateMouseCursor()) | ||||
|             return 1; | ||||
|         } | ||||
|         return 0; | ||||
|     } | ||||
|     return 0; | ||||
| @@ -718,8 +720,13 @@ bool    ImGui_ImplDX12_Init(void* hwnd, int num_frames_in_flight, | ||||
|     if (!QueryPerformanceCounter((LARGE_INTEGER *)&g_Time)) | ||||
|         return false; | ||||
|  | ||||
|     // Setup back-end capabilities flags | ||||
|     ImGuiIO& io = ImGui::GetIO(); | ||||
|     io.KeyMap[ImGuiKey_Tab] = VK_TAB;                       // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array that we will update during the application lifetime. | ||||
|     io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors;   // We can honor GetMouseCursor() values (optional) | ||||
|     io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos;    // We can honor io.WantSetMousePos requests (optional, rarely used) | ||||
|  | ||||
|     // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array that we will update during the application lifetime. | ||||
|     io.KeyMap[ImGuiKey_Tab] = VK_TAB; | ||||
|     io.KeyMap[ImGuiKey_LeftArrow] = VK_LEFT; | ||||
|     io.KeyMap[ImGuiKey_RightArrow] = VK_RIGHT; | ||||
|     io.KeyMap[ImGuiKey_UpArrow] = VK_UP; | ||||
|   | ||||
| @@ -10,6 +10,7 @@ | ||||
|  | ||||
| // CHANGELOG  | ||||
| // (minor and older changes stripped away, please see git history for details) | ||||
| //  2018-03-20: Misc: Setup io.BackendFlags ImGuiBackendFlags_HasMouseCursors and ImGuiBackendFlags_HasSetMousePos flags + honor ImGuiConfigFlags_NoSetMouseCursor flag. | ||||
| //  2018-02-20: Inputs: Added support for mouse cursors (ImGui::GetMouseCursor() value and WM_SETCURSOR message handling). | ||||
| //  2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_ImplDX9_RenderDrawData() in the .h file so you can call it yourself. | ||||
| //  2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves. | ||||
| @@ -183,9 +184,12 @@ void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data) | ||||
|     d3d9_state_block->Release(); | ||||
| } | ||||
|  | ||||
| static void ImGui_ImplWin32_UpdateMouseCursor() | ||||
| static bool ImGui_ImplWin32_UpdateMouseCursor() | ||||
| { | ||||
|     ImGuiIO& io = ImGui::GetIO(); | ||||
|     if (io.ConfigFlags & ImGuiConfigFlags_NoSetMouseCursor) | ||||
|         return false; | ||||
|  | ||||
|     ImGuiMouseCursor imgui_cursor = io.MouseDrawCursor ? ImGuiMouseCursor_None : ImGui::GetMouseCursor(); | ||||
|     if (imgui_cursor == ImGuiMouseCursor_None) | ||||
|     { | ||||
| @@ -208,6 +212,7 @@ static void ImGui_ImplWin32_UpdateMouseCursor() | ||||
|         } | ||||
|         ::SetCursor(::LoadCursor(NULL, win32_cursor)); | ||||
|     } | ||||
|     return true; | ||||
| } | ||||
|  | ||||
| // Process Win32 mouse/keyboard inputs.  | ||||
| @@ -277,11 +282,8 @@ IMGUI_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARAM wPa | ||||
|             io.AddInputCharacter((unsigned short)wParam); | ||||
|         return 0; | ||||
|     case WM_SETCURSOR: | ||||
|         if (LOWORD(lParam) == HTCLIENT) | ||||
|         { | ||||
|             ImGui_ImplWin32_UpdateMouseCursor(); | ||||
|         if (LOWORD(lParam) == HTCLIENT && ImGui_ImplWin32_UpdateMouseCursor()) | ||||
|             return 1; | ||||
|         } | ||||
|         return 0; | ||||
|     } | ||||
|     return 0; | ||||
| @@ -297,8 +299,13 @@ bool    ImGui_ImplDX9_Init(void* hwnd, IDirect3DDevice9* device) | ||||
|     if (!QueryPerformanceCounter((LARGE_INTEGER *)&g_Time)) | ||||
|         return false; | ||||
|  | ||||
|     // Setup back-end capabilities flags | ||||
|     ImGuiIO& io = ImGui::GetIO(); | ||||
|     io.KeyMap[ImGuiKey_Tab] = VK_TAB;                       // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array that we will update during the application lifetime. | ||||
|     io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors;   // We can honor GetMouseCursor() values (optional) | ||||
|     io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos;    // We can honor io.WantSetMousePos requests (optional, rarely used) | ||||
|  | ||||
|     // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array that we will update during the application lifetime. | ||||
|     io.KeyMap[ImGuiKey_Tab] = VK_TAB; | ||||
|     io.KeyMap[ImGuiKey_LeftArrow] = VK_LEFT; | ||||
|     io.KeyMap[ImGuiKey_RightArrow] = VK_RIGHT; | ||||
|     io.KeyMap[ImGuiKey_UpArrow] = VK_UP; | ||||
|   | ||||
| @@ -19,6 +19,7 @@ | ||||
|  | ||||
| // CHANGELOG | ||||
| // (minor and older changes stripped away, please see git history for details) | ||||
| //  2018-03-20: Misc: Setup io.BackendFlags ImGuiBackendFlags_HasMouseCursors and ImGuiBackendFlags_HasSetMousePos flags + honor ImGuiConfigFlags_NoSetMouseCursor flag. | ||||
| //  2018-02-20: Inputs: Added support for mouse cursors (ImGui::GetMouseCursor() value and WM_SETCURSOR message handling). | ||||
| //  2018-02-20: Inputs: Renamed GLFW callbacks exposed in .h to not include GL2 in their name. | ||||
| //  2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_ImplGlfwGL2_RenderDrawData() in the .h file so you can call it yourself. | ||||
| @@ -233,8 +234,13 @@ bool    ImGui_ImplGlfwGL2_Init(GLFWwindow* window, bool install_callbacks) | ||||
| { | ||||
|     g_Window = window; | ||||
|  | ||||
|     // Setup back-end capabilities flags | ||||
|     ImGuiIO& io = ImGui::GetIO(); | ||||
|     io.KeyMap[ImGuiKey_Tab] = GLFW_KEY_TAB;                     // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array. | ||||
|     io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors;   // We can honor GetMouseCursor() values (optional) | ||||
|     io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos;    // We can honor io.WantSetMousePos requests (optional, rarely used) | ||||
|  | ||||
|     // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array. | ||||
|     io.KeyMap[ImGuiKey_Tab] = GLFW_KEY_TAB; | ||||
|     io.KeyMap[ImGuiKey_LeftArrow] = GLFW_KEY_LEFT; | ||||
|     io.KeyMap[ImGuiKey_RightArrow] = GLFW_KEY_RIGHT; | ||||
|     io.KeyMap[ImGuiKey_UpArrow] = GLFW_KEY_UP; | ||||
| @@ -339,15 +345,18 @@ void ImGui_ImplGlfwGL2_NewFrame() | ||||
|     } | ||||
|  | ||||
|     // Update OS/hardware mouse cursor if imgui isn't drawing a software cursor | ||||
|     ImGuiMouseCursor cursor = ImGui::GetMouseCursor(); | ||||
|     if (io.MouseDrawCursor || cursor == ImGuiMouseCursor_None) | ||||
|     if ((io.ConfigFlags & ImGuiConfigFlags_NoSetMouseCursor) == 0) | ||||
|     { | ||||
|         glfwSetInputMode(g_Window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN); | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         glfwSetCursor(g_Window, g_MouseCursors[cursor] ? g_MouseCursors[cursor] : g_MouseCursors[ImGuiMouseCursor_Arrow]); | ||||
|         glfwSetInputMode(g_Window, GLFW_CURSOR, GLFW_CURSOR_NORMAL); | ||||
|         ImGuiMouseCursor cursor = ImGui::GetMouseCursor(); | ||||
|         if (io.MouseDrawCursor || cursor == ImGuiMouseCursor_None) | ||||
|         { | ||||
|             glfwSetInputMode(g_Window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN); | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             glfwSetCursor(g_Window, g_MouseCursors[cursor] ? g_MouseCursors[cursor] : g_MouseCursors[ImGuiMouseCursor_Arrow]); | ||||
|             glfwSetInputMode(g_Window, GLFW_CURSOR, GLFW_CURSOR_NORMAL); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     // Start the frame. This call will update the io.WantCaptureMouse, io.WantCaptureKeyboard flag that you can use to dispatch inputs (or not) to your application. | ||||
|   | ||||
| @@ -13,6 +13,7 @@ | ||||
|  | ||||
| // CHANGELOG | ||||
| // (minor and older changes stripped away, please see git history for details) | ||||
| //  2018-03-20: Misc: Setup io.BackendFlags ImGuiBackendFlags_HasMouseCursors and ImGuiBackendFlags_HasSetMousePos flags + honor ImGuiConfigFlags_NoSetMouseCursor flag. | ||||
| //  2018-03-06: OpenGL: Added const char* glsl_version parameter to ImGui_ImplGlfwGL3_Init() so user can override the GLSL version e.g. "#version 150". | ||||
| //  2018-02-23: OpenGL: Create the VAO in the render function so the setup can more easily be used with multiple shared GL context. | ||||
| //  2018-02-20: Inputs: Added support for mouse cursors (ImGui::GetMouseCursor() value and WM_SETCURSOR message handling). | ||||
| @@ -365,8 +366,12 @@ bool    ImGui_ImplGlfwGL3_Init(GLFWwindow* window, bool install_callbacks, const | ||||
|     strcpy(g_GlslVersion, glsl_version); | ||||
|     strcat(g_GlslVersion, "\n"); | ||||
|  | ||||
|     // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array. | ||||
|     // Setup back-end capabilities flags | ||||
|     ImGuiIO& io = ImGui::GetIO(); | ||||
|     io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors;   // We can honor GetMouseCursor() values (optional) | ||||
|     io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos;    // We can honor io.WantSetMousePos requests (optional, rarely used) | ||||
|  | ||||
|     // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array. | ||||
|     io.KeyMap[ImGuiKey_Tab] = GLFW_KEY_TAB; | ||||
|     io.KeyMap[ImGuiKey_LeftArrow] = GLFW_KEY_LEFT; | ||||
|     io.KeyMap[ImGuiKey_RightArrow] = GLFW_KEY_RIGHT; | ||||
| @@ -472,15 +477,18 @@ void ImGui_ImplGlfwGL3_NewFrame() | ||||
|     } | ||||
|  | ||||
|     // Update OS/hardware mouse cursor if imgui isn't drawing a software cursor | ||||
|     ImGuiMouseCursor cursor = ImGui::GetMouseCursor(); | ||||
|     if (io.MouseDrawCursor || cursor == ImGuiMouseCursor_None) | ||||
|     if ((io.ConfigFlags & ImGuiConfigFlags_NoSetMouseCursor) == 0) | ||||
|     { | ||||
|         glfwSetInputMode(g_Window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN); | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         glfwSetCursor(g_Window, g_MouseCursors[cursor] ? g_MouseCursors[cursor] : g_MouseCursors[ImGuiMouseCursor_Arrow]); | ||||
|         glfwSetInputMode(g_Window, GLFW_CURSOR, GLFW_CURSOR_NORMAL); | ||||
|         ImGuiMouseCursor cursor = ImGui::GetMouseCursor(); | ||||
|         if (io.MouseDrawCursor || cursor == ImGuiMouseCursor_None) | ||||
|         { | ||||
|             glfwSetInputMode(g_Window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN); | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             glfwSetCursor(g_Window, g_MouseCursors[cursor] ? g_MouseCursors[cursor] : g_MouseCursors[ImGuiMouseCursor_Arrow]); | ||||
|             glfwSetInputMode(g_Window, GLFW_CURSOR, GLFW_CURSOR_NORMAL); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     // Gamepad navigation mapping [BETA] | ||||
|   | ||||
| @@ -19,6 +19,7 @@ | ||||
|  | ||||
| // CHANGELOG | ||||
| // (minor and older changes stripped away, please see git history for details) | ||||
| //  2018-03-20: Misc: Setup io.BackendFlags ImGuiBackendFlags_HasMouseCursors flag + honor ImGuiConfigFlags_NoSetMouseCursor flag. | ||||
| //  2018-02-16: Inputs: Added support for mouse cursors, honoring ImGui::GetMouseCursor() value. | ||||
| //  2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_ImplSdlGL2_RenderDrawData() in the .h file so you can call it yourself. | ||||
| //  2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves. | ||||
| @@ -224,8 +225,11 @@ void    ImGui_ImplSdlGL2_InvalidateDeviceObjects() | ||||
|  | ||||
| bool    ImGui_ImplSdlGL2_Init(SDL_Window* window) | ||||
| { | ||||
|     // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array. | ||||
|     // Setup back-end capabilities flags | ||||
|     ImGuiIO& io = ImGui::GetIO(); | ||||
|     io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors;   // We can honor GetMouseCursor() values (optional) | ||||
|  | ||||
|     // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array. | ||||
|     io.KeyMap[ImGuiKey_Tab] = SDL_SCANCODE_TAB; | ||||
|     io.KeyMap[ImGuiKey_LeftArrow] = SDL_SCANCODE_LEFT; | ||||
|     io.KeyMap[ImGuiKey_RightArrow] = SDL_SCANCODE_RIGHT; | ||||
| @@ -330,15 +334,18 @@ void ImGui_ImplSdlGL2_NewFrame(SDL_Window *window) | ||||
| #endif | ||||
|  | ||||
|     // Update OS/hardware mouse cursor if imgui isn't drawing a software cursor | ||||
|     ImGuiMouseCursor cursor = ImGui::GetMouseCursor(); | ||||
|     if (io.MouseDrawCursor || cursor == ImGuiMouseCursor_None) | ||||
|     if ((io.ConfigFlags & ImGuiConfigFlags_NoSetMouseCursor) == 0) | ||||
|     { | ||||
|         SDL_ShowCursor(0); | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         SDL_SetCursor(g_MouseCursors[cursor] ? g_MouseCursors[cursor] : g_MouseCursors[ImGuiMouseCursor_Arrow]); | ||||
|         SDL_ShowCursor(1); | ||||
|         ImGuiMouseCursor cursor = ImGui::GetMouseCursor(); | ||||
|         if (io.MouseDrawCursor || cursor == ImGuiMouseCursor_None) | ||||
|         { | ||||
|             SDL_ShowCursor(0); | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             SDL_SetCursor(g_MouseCursors[cursor] ? g_MouseCursors[cursor] : g_MouseCursors[ImGuiMouseCursor_Arrow]); | ||||
|             SDL_ShowCursor(1); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     // Start the frame. This call will update the io.WantCaptureMouse, io.WantCaptureKeyboard flag that you can use to dispatch inputs (or not) to your application. | ||||
|   | ||||
| @@ -12,6 +12,7 @@ | ||||
|  | ||||
| // CHANGELOG | ||||
| // (minor and older changes stripped away, please see git history for details) | ||||
| //  2018-03-20: Misc: Setup io.BackendFlags ImGuiBackendFlags_HasMouseCursors flag + honor ImGuiConfigFlags_NoSetMouseCursor flag. | ||||
| //  2018-03-06: OpenGL: Added const char* glsl_version parameter to ImGui_ImplSdlGL3_Init() so user can override the GLSL version e.g. "#version 150". | ||||
| //  2018-02-23: OpenGL: Create the VAO in the render function so the setup can more easily be used with multiple shared GL context. | ||||
| //  2018-02-16: Inputs: Added support for mouse cursors, honoring ImGui::GetMouseCursor() value. | ||||
| @@ -357,8 +358,11 @@ bool    ImGui_ImplSdlGL3_Init(SDL_Window* window, const char* glsl_version) | ||||
|     strcpy(g_GlslVersion, glsl_version); | ||||
|     strcat(g_GlslVersion, "\n"); | ||||
|  | ||||
|     // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array. | ||||
|     // Setup back-end capabilities flags | ||||
|     ImGuiIO& io = ImGui::GetIO(); | ||||
|     io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors;   // We can honor GetMouseCursor() values (optional) | ||||
|  | ||||
|     // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array. | ||||
|     io.KeyMap[ImGuiKey_Tab] = SDL_SCANCODE_TAB; | ||||
|     io.KeyMap[ImGuiKey_LeftArrow] = SDL_SCANCODE_LEFT; | ||||
|     io.KeyMap[ImGuiKey_RightArrow] = SDL_SCANCODE_RIGHT; | ||||
| @@ -463,15 +467,18 @@ void ImGui_ImplSdlGL3_NewFrame(SDL_Window* window) | ||||
| #endif | ||||
|  | ||||
|     // Update OS/hardware mouse cursor if imgui isn't drawing a software cursor | ||||
|     ImGuiMouseCursor cursor = ImGui::GetMouseCursor(); | ||||
|     if (io.MouseDrawCursor || cursor == ImGuiMouseCursor_None) | ||||
|     if ((io.ConfigFlags & ImGuiConfigFlags_NoSetMouseCursor) == 0) | ||||
|     { | ||||
|         SDL_ShowCursor(0); | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         SDL_SetCursor(g_MouseCursors[cursor] ? g_MouseCursors[cursor] : g_MouseCursors[ImGuiMouseCursor_Arrow]); | ||||
|         SDL_ShowCursor(1); | ||||
|         ImGuiMouseCursor cursor = ImGui::GetMouseCursor(); | ||||
|         if (io.MouseDrawCursor || cursor == ImGuiMouseCursor_None) | ||||
|         { | ||||
|             SDL_ShowCursor(0); | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             SDL_SetCursor(g_MouseCursors[cursor] ? g_MouseCursors[cursor] : g_MouseCursors[ImGuiMouseCursor_Arrow]); | ||||
|             SDL_ShowCursor(1); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     // Start the frame. This call will update the io.WantCaptureMouse, io.WantCaptureKeyboard flag that you can use to dispatch inputs (or not) to your application. | ||||
|   | ||||
| @@ -10,6 +10,7 @@ | ||||
|  | ||||
| // CHANGELOG | ||||
| // (minor and older changes stripped away, please see git history for details) | ||||
| //  2018-03-20: Misc: Setup io.BackendFlags ImGuiBackendFlags_HasMouseCursors flag + honor ImGuiConfigFlags_NoSetMouseCursor flag. | ||||
| //  2018-02-20: Inputs: Added support for mouse cursors (ImGui::GetMouseCursor() value and WM_SETCURSOR message handling). | ||||
| //  2018-02-20: Inputs: Renamed GLFW callbacks exposed in .h to not include Vulkan in their name. | ||||
| //  2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback, ImGui_ImplGlfwVulkan_Render() calls ImGui_ImplGlfwVulkan_RenderDrawData() itself. | ||||
| @@ -769,8 +770,12 @@ bool    ImGui_ImplGlfwVulkan_Init(GLFWwindow* window, bool install_callbacks, Im | ||||
|  | ||||
|     g_Window = window; | ||||
|  | ||||
|     // Setup back-end capabilities flags | ||||
|     ImGuiIO& io = ImGui::GetIO(); | ||||
|     io.KeyMap[ImGuiKey_Tab] = GLFW_KEY_TAB;                         // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array. | ||||
|     io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors;   // We can honor GetMouseCursor() values (optional) | ||||
|  | ||||
|     // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array. | ||||
|     io.KeyMap[ImGuiKey_Tab] = GLFW_KEY_TAB; | ||||
|     io.KeyMap[ImGuiKey_LeftArrow] = GLFW_KEY_LEFT; | ||||
|     io.KeyMap[ImGuiKey_RightArrow] = GLFW_KEY_RIGHT; | ||||
|     io.KeyMap[ImGuiKey_UpArrow] = GLFW_KEY_UP; | ||||
| @@ -865,15 +870,18 @@ void ImGui_ImplGlfwVulkan_NewFrame() | ||||
|     } | ||||
|  | ||||
|     // Update OS/hardware mouse cursor if imgui isn't drawing a software cursor | ||||
|     ImGuiMouseCursor cursor = ImGui::GetMouseCursor(); | ||||
|     if (io.MouseDrawCursor || cursor == ImGuiMouseCursor_None) | ||||
|     if ((io.ConfigFlags & ImGuiConfigFlags_NoSetMouseCursor) == 0) | ||||
|     { | ||||
|         glfwSetInputMode(g_Window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN); | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         glfwSetCursor(g_Window, g_MouseCursors[cursor] ? g_MouseCursors[cursor] : g_MouseCursors[ImGuiMouseCursor_Arrow]); | ||||
|         glfwSetInputMode(g_Window, GLFW_CURSOR, GLFW_CURSOR_NORMAL); | ||||
|         ImGuiMouseCursor cursor = ImGui::GetMouseCursor(); | ||||
|         if (io.MouseDrawCursor || cursor == ImGuiMouseCursor_None) | ||||
|         { | ||||
|             glfwSetInputMode(g_Window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN); | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             glfwSetCursor(g_Window, g_MouseCursors[cursor] ? g_MouseCursors[cursor] : g_MouseCursors[ImGuiMouseCursor_Arrow]); | ||||
|             glfwSetInputMode(g_Window, GLFW_CURSOR, GLFW_CURSOR_NORMAL); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     // Start the frame. This call will update the io.WantCaptureMouse, io.WantCaptureKeyboard flag that you can use to dispatch inputs (or not) to your application. | ||||
|   | ||||
| @@ -237,7 +237,7 @@ | ||||
|     - PS4 users: Consider emulating a mouse cursor with DualShock4 touch pad or a spare analog stick as a mouse-emulation fallback. | ||||
|     - Consoles/Tablet/Phone users: Consider using a Synergy 1.x server (on your PC) + uSynergy.c (on your console/tablet/phone app) to share your PC mouse/keyboard. | ||||
|     - On a TV/console system where readability may be lower or mouse inputs may be awkward, you may want to set the ImGuiConfigFlags_NavEnableSetMousePos flag. | ||||
|       Enabling ImGuiConfigFlags_NavEnableSetMousePos instructs dear imgui to move your mouse cursor along with navigation movements. | ||||
|       Enabling ImGuiConfigFlags_NavEnableSetMousePos + ImGuiBackendFlags_HasSetMousePos instructs dear imgui to move your mouse cursor along with navigation movements. | ||||
|       When enabled, the NewFrame() function may alter 'io.MousePos' and set 'io.WantSetMousePos' to notify you that it wants the mouse cursor to be moved. | ||||
|       When that happens your back-end NEEDS to move the OS or underlying mouse cursor on the next frame. Some of the binding in examples/ do that. | ||||
|       (If you set the NavEnableSetMousePos flag but don't honor 'io.WantSetMousePos' properly, imgui will misbehave as it will see your mouse as moving back and forth!) | ||||
| @@ -3037,7 +3037,7 @@ static void ImGui::NavUpdate() | ||||
|     if (g.NavMousePosDirty && g.NavIdIsAlive) | ||||
|     { | ||||
|         // Set mouse position given our knowledge of the nav widget position from last frame | ||||
|         if (g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableSetMousePos) | ||||
|         if ((g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableSetMousePos) && (g.IO.BackendFlags & ImGuiBackendFlags_HasSetMousePos)) | ||||
|         { | ||||
|             g.IO.MousePos = g.IO.MousePosPrev = NavCalcPreferredMousePos(); | ||||
|             g.IO.WantSetMousePos = true; | ||||
|   | ||||
							
								
								
									
										5
									
								
								imgui.h
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								imgui.h
									
									
									
									
									
								
							| @@ -777,6 +777,7 @@ enum ImGuiConfigFlags_ | ||||
|     ImGuiConfigFlags_NavEnableGamepad       = 1 << 1,   // Master gamepad navigation enable flag. This is mostly to instruct your imgui back-end to fill io.NavInputs[]. Back-end also needs to set ImGuiBackendFlags_HasGamepad. | ||||
|     ImGuiConfigFlags_NavEnableSetMousePos   = 1 << 2,   // Request navigation to allow moving the mouse cursor. May be useful on TV/console systems where moving a virtual mouse is awkward. Will update io.MousePos and set io.WantSetMousePos=true. If enabled you MUST honor io.WantSetMousePos requests in your binding, otherwise ImGui will react as if the mouse is jumping around back and forth. | ||||
|     ImGuiConfigFlags_NavNoCaptureKeyboard   = 1 << 3,   // Do not set the io.WantCaptureKeyboard flag with io.NavActive is set.  | ||||
|     ImGuiConfigFlags_NoSetMouseCursor       = 1 << 4,   // Request back-end to not alter mouse cursor configuration. | ||||
|  | ||||
|     // User storage (to allow your back-end/engine to communicate to code that may be shared between multiple projects. Those flags are not used by core ImGui) | ||||
|     ImGuiConfigFlags_IsSRGB                 = 1 << 20,  // Application is SRGB-aware. | ||||
| @@ -786,7 +787,9 @@ enum ImGuiConfigFlags_ | ||||
| // Back-end capabilities flags stored in io.BackendFlags. Set by imgui_impl_xxx or custom back-end. | ||||
| enum ImGuiBackendFlags_ | ||||
| { | ||||
|     ImGuiBackendFlags_HasGamepad            = 1 << 0    // Back-end has a connected gamepad | ||||
|     ImGuiBackendFlags_HasGamepad            = 1 << 0,   // Back-end has a connected gamepad. | ||||
|     ImGuiBackendFlags_HasMouseCursors       = 1 << 1,   // Back-end can honor GetMouseCursor() values and change the OS cursor shape. | ||||
|     ImGuiBackendFlags_HasSetMousePos        = 1 << 2    // Back-end can honor io.WantSetMousePos and reposition the mouse (only used if ImGuiConfigFlags_NavEnableSetMousePos is set). | ||||
| }; | ||||
|  | ||||
| // Enumeration for PushStyleColor() / PopStyleColor() | ||||
|   | ||||
| @@ -1849,6 +1849,7 @@ void ImGui::ShowDemoWindow(bool* p_open) | ||||
|         ImGui::CheckboxFlags("io.ConfigFlags: NavEnableGamepad", (unsigned int *)&io.ConfigFlags, ImGuiConfigFlags_NavEnableGamepad); | ||||
|         ImGui::CheckboxFlags("io.ConfigFlags: NavEnableKeyboard", (unsigned int *)&io.ConfigFlags, ImGuiConfigFlags_NavEnableKeyboard); | ||||
|         ImGui::CheckboxFlags("io.ConfigFlags: NavEnableSetMousePos", (unsigned int *)&io.ConfigFlags, ImGuiConfigFlags_NavEnableSetMousePos); | ||||
|         ImGui::CheckboxFlags("io.ConfigFlags: NoSetMouseCursor", (unsigned int *)&io.ConfigFlags, ImGuiConfigFlags_NoSetMouseCursor); | ||||
|         ImGui::SameLine(); ShowHelpMarker("Request ImGui to move your move cursor when using gamepad/keyboard navigation. NewFrame() will change io.MousePos and set the io.WantSetMousePos flag, your backend will need to apply the new mouse position."); | ||||
|  | ||||
|         if (ImGui::TreeNode("Keyboard, Mouse & Navigation State")) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user