Skip to content

Commit

Permalink
Added ImGuiMouseCursor_Progress mouse cursor 8a35386+ support in SDL2…
Browse files Browse the repository at this point in the history
…,SDL3,Win32,Allegro5 backends.

Amend 8a35386
  • Loading branch information
ocornut committed Feb 18, 2025
1 parent 8a35386 commit eec097f
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 11 deletions.
3 changes: 2 additions & 1 deletion backends/imgui_impl_allegro5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

// CHANGELOG
// (minor and older changes stripped away, please see git history for details)
// 2025-02-18: Added ImGuiMouseCursor_Wait mouse cursor support.
// 2025-02-18: Added ImGuiMouseCursor_Wait and ImGuiMouseCursor_Progress mouse cursor support.
// 2025-01-06: Avoid calling al_set_mouse_cursor() repeatedly since it appears to leak on on X11 (#8256).
// 2024-08-22: moved some OS/backend related function pointers from ImGuiIO to ImGuiPlatformIO:
// - io.GetClipboardTextFn -> platform_io.Platform_GetClipboardTextFn
Expand Down Expand Up @@ -596,6 +596,7 @@ static void ImGui_ImplAllegro5_UpdateMouseCursor()
case ImGuiMouseCursor_ResizeNESW: cursor_id = ALLEGRO_SYSTEM_MOUSE_CURSOR_RESIZE_NE; break;
case ImGuiMouseCursor_ResizeNWSE: cursor_id = ALLEGRO_SYSTEM_MOUSE_CURSOR_RESIZE_NW; break;
case ImGuiMouseCursor_Wait: cursor_id = ALLEGRO_SYSTEM_MOUSE_CURSOR_BUSY; break;
case ImGuiMouseCursor_Progress: cursor_id = ALLEGRO_SYSTEM_MOUSE_CURSOR_PROGRESS; break;
case ImGuiMouseCursor_NotAllowed: cursor_id = ALLEGRO_SYSTEM_MOUSE_CURSOR_UNAVAILABLE; break;
}
al_set_system_mouse_cursor(bd->Display, cursor_id);
Expand Down
2 changes: 1 addition & 1 deletion backends/imgui_impl_glfw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// [X] Platform: Mouse cursor shape and visibility (ImGuiBackendFlags_HasMouseCursors). Resizing cursors requires GLFW 3.4+! Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
// Missing features or Issues:
// [ ] Touch events are only correctly identified as Touch on Windows. This create issues with some interactions. GLFW doesn't provide a way to identify touch inputs from mouse inputs, we cannot call io.AddMouseSourceEvent() to identify the source. We provide a Windows-specific workaround.
// [ ] Missing ImGuiMouseCursor_Wait cursor.
// [ ] Missing ImGuiMouseCursor_Wait and ImGuiMouseCursor_Progress cursors.

// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
Expand Down
2 changes: 1 addition & 1 deletion backends/imgui_impl_glfw.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
// [X] Platform: Mouse cursor shape and visibility (ImGuiBackendFlags_HasMouseCursors). Resizing cursors requires GLFW 3.4+! Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
// Missing features or Issues:
// [ ] Touch events are only correctly identified as Touch on Windows. This create issues with some interactions. GLFW doesn't provide a way to identify touch inputs from mouse inputs, we cannot call io.AddMouseSourceEvent() to identify the source. We provide a Windows-specific workaround.
// [ ] Missing ImGuiMouseCursor_Wait cursor.
// [ ] Missing ImGuiMouseCursor_Wait and ImGuiMouseCursor_Progress cursors.

// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
Expand Down
2 changes: 1 addition & 1 deletion backends/imgui_impl_osx.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// [X] Platform: Mouse cursor shape and visibility (ImGuiBackendFlags_HasMouseCursors). Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
// [X] Platform: IME support.
// Missing features or Issues:
// [ ] Missing ImGuiMouseCursor_Wait cursor.
// [ ] Missing ImGuiMouseCursor_Wait and ImGuiMouseCursor_Progress cursors.

// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
Expand Down
2 changes: 1 addition & 1 deletion backends/imgui_impl_osx.mm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// [X] Platform: Mouse cursor shape and visibility (ImGuiBackendFlags_HasMouseCursors). Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
// [X] Platform: IME support.
// Missing features or Issues:
// [ ] Missing ImGuiMouseCursor_Wait cursor.
// [ ] Missing ImGuiMouseCursor_Wait and ImGuiMouseCursor_Progress cursors.

// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
Expand Down
3 changes: 2 additions & 1 deletion backends/imgui_impl_sdl2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

// CHANGELOG
// (minor and older changes stripped away, please see git history for details)
// 2025-02-18: Added ImGuiMouseCursor_Wait mouse cursor support.
// 2025-02-18: Added ImGuiMouseCursor_Wait and ImGuiMouseCursor_Progress mouse cursor support.
// 2025-02-10: Using SDL_OpenURL() in platform_io.Platform_OpenInShellFn handler.
// 2025-01-20: Made ImGui_ImplSDL2_SetGamepadMode(ImGui_ImplSDL2_GamepadMode_Manual) accept an empty array.
// 2024-10-24: Emscripten: from SDL 2.30.9, SDL_EVENT_MOUSE_WHEEL event doesn't require dividing by 100.0f.
Expand Down Expand Up @@ -501,6 +501,7 @@ static bool ImGui_ImplSDL2_Init(SDL_Window* window, SDL_Renderer* renderer, void
bd->MouseCursors[ImGuiMouseCursor_ResizeNWSE] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENWSE);
bd->MouseCursors[ImGuiMouseCursor_Hand] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_HAND);
bd->MouseCursors[ImGuiMouseCursor_Wait] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_WAIT);
bd->MouseCursors[ImGuiMouseCursor_Progress] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_WAITARROW);
bd->MouseCursors[ImGuiMouseCursor_NotAllowed] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_NO);

// Set platform dependent data in viewport
Expand Down
3 changes: 2 additions & 1 deletion backends/imgui_impl_sdl3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

// CHANGELOG
// (minor and older changes stripped away, please see git history for details)
// 2025-02-18: Added ImGuiMouseCursor_Wait mouse cursor support.
// 2025-02-18: Added ImGuiMouseCursor_Wait and ImGuiMouseCursor_Progress mouse cursor support.
// 2025-02-10: Using SDL_OpenURL() in platform_io.Platform_OpenInShellFn handler.
// 2025-01-20: Made ImGui_ImplSDL3_SetGamepadMode(ImGui_ImplSDL3_GamepadMode_Manual) accept an empty array.
// 2024-10-24: Emscripten: SDL_EVENT_MOUSE_WHEEL event doesn't require dividing by 100.0f on Emscripten.
Expand Down Expand Up @@ -482,6 +482,7 @@ static bool ImGui_ImplSDL3_Init(SDL_Window* window, SDL_Renderer* renderer, void
bd->MouseCursors[ImGuiMouseCursor_ResizeNWSE] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_NWSE_RESIZE);
bd->MouseCursors[ImGuiMouseCursor_Hand] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_POINTER);
bd->MouseCursors[ImGuiMouseCursor_Wait] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_WAIT);
bd->MouseCursors[ImGuiMouseCursor_Progress] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_PROGRESS);
bd->MouseCursors[ImGuiMouseCursor_NotAllowed] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_NOT_ALLOWED);

// Set platform dependent data in viewport
Expand Down
3 changes: 2 additions & 1 deletion backends/imgui_impl_win32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

// CHANGELOG
// (minor and older changes stripped away, please see git history for details)
// 2025-02-18: Added ImGuiMouseCursor_Wait mouse cursor support.
// 2025-02-18: Added ImGuiMouseCursor_Wait and ImGuiMouseCursor_Progress mouse cursor support.
// 2024-07-08: Inputs: Fixed ImGuiMod_Super being mapped to VK_APPS instead of VK_LWIN||VK_RWIN. (#7768)
// 2023-10-05: Inputs: Added support for extra ImGuiKey values: F13 to F24 function keys, app back/forward keys.
// 2023-09-25: Inputs: Synthesize key-down event on key-up for VK_SNAPSHOT / ImGuiKey_PrintScreen as Windows doesn't emit it (same behavior as GLFW/SDL).
Expand Down Expand Up @@ -258,6 +258,7 @@ static bool ImGui_ImplWin32_UpdateMouseCursor(ImGuiIO& io, ImGuiMouseCursor imgu
case ImGuiMouseCursor_ResizeNWSE: win32_cursor = IDC_SIZENWSE; break;
case ImGuiMouseCursor_Hand: win32_cursor = IDC_HAND; break;
case ImGuiMouseCursor_Wait: win32_cursor = IDC_WAIT; break;
case ImGuiMouseCursor_Progress: win32_cursor = IDC_APPSTARTING; break;
case ImGuiMouseCursor_NotAllowed: win32_cursor = IDC_NO; break;
}
::SetCursor(::LoadCursor(nullptr, win32_cursor));
Expand Down
6 changes: 4 additions & 2 deletions docs/CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,14 @@ Other changes:
is hovered, merely it's visibility. (#8399, #8387) [@nicovanbentum]
- TextLinkOpenURL(): fixed default Win32 io.PlatformOpenInShellFn handler to
handle UTF-8 regardless of system regional settings. (#7660) [@achabense]
- Misc: Added ImGuiMouseCursor_Wait mouse cursor (busy/wait/hourglass shape).
- Misc: Added ImGuiMouseCursor_Wait and ImGuiMouseCursor_Progress mouse cursors
(busy/wait/hourglass shape, with or without an arrow cursor).
- Demo: Combos: demonstrate a very simple way to add a filter to a combo,
by showing the filter inside the combo contents. (#718)
- Backends: SDL2, SDL3: Using SDL_OpenURL() in platform_io.Platform_OpenInShellFn
handler. (#7660) [@achabense]
- Backends: SDL2, SDL3, Win32, Allegro5: Added support for ImGuiMouseCursor_Wait.
- Backends: SDL2, SDL3, Win32, Allegro5: Added support for ImGuiMouseCursor_Wait
and ImGuiMouseCursor_Progress cursors.
- Backends: OpenGL3: Lazily reinitialize embedded GL loader for when calling backend
from e.g. other DLL boundaries. (#8406)
- Backends: Metal: Fixed a crash on application resources. (#8367, #7419) [@anszom]
Expand Down
1 change: 1 addition & 0 deletions imgui.h
Original file line number Diff line number Diff line change
Expand Up @@ -1834,6 +1834,7 @@ enum ImGuiMouseCursor_
ImGuiMouseCursor_ResizeNWSE, // When hovering over the bottom-right corner of a window
ImGuiMouseCursor_Hand, // (Unused by Dear ImGui functions. Use for e.g. hyperlinks)
ImGuiMouseCursor_Wait, // When waiting for something to process/load.
ImGuiMouseCursor_Progress, // When waiting for something to process/load, but application is still interactive.
ImGuiMouseCursor_NotAllowed, // When hovering something with disallowed interaction. Usually a crossed circle.
ImGuiMouseCursor_COUNT
};
Expand Down
2 changes: 1 addition & 1 deletion imgui_demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7593,7 +7593,7 @@ static void ShowDemoWindowInputs()
IMGUI_DEMO_MARKER("Inputs & Focus/Mouse Cursors");
if (ImGui::TreeNode("Mouse Cursors"))
{
const char* mouse_cursors_names[] = { "Arrow", "TextInput", "ResizeAll", "ResizeNS", "ResizeEW", "ResizeNESW", "ResizeNWSE", "Hand", "Wait", "NotAllowed" };
const char* mouse_cursors_names[] = { "Arrow", "TextInput", "ResizeAll", "ResizeNS", "ResizeEW", "ResizeNESW", "ResizeNWSE", "Hand", "Wait", "Progress", "NotAllowed" };
IM_ASSERT(IM_ARRAYSIZE(mouse_cursors_names) == ImGuiMouseCursor_COUNT);

ImGuiMouseCursor current = ImGui::GetMouseCursor();
Expand Down

0 comments on commit eec097f

Please sign in to comment.