mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-05 04:28:47 +02:00
IO: Added ImGuiConfigFlags_NoSetMouseCursors. Added ImGuiBackendFlags_HasMouseCursors, ImGuiBackendFlags_HasSetMousePos. (#787, #1495, #1202)
This commit is contained in:
@ -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.
|
||||
|
Reference in New Issue
Block a user