| 3869 | } |
| 3870 | |
| 3871 | void ImGui::RenderMouseCursor(ImVec2 base_pos, float base_scale, ImGuiMouseCursor mouse_cursor, ImU32 col_fill, ImU32 col_border, ImU32 col_shadow) |
| 3872 | { |
| 3873 | ImGuiContext& g = *GImGui; |
| 3874 | if (mouse_cursor <= ImGuiMouseCursor_None || mouse_cursor >= ImGuiMouseCursor_COUNT) // We intentionally accept out of bound values. |
| 3875 | mouse_cursor = ImGuiMouseCursor_Arrow; |
| 3876 | ImFontAtlas* font_atlas = g.DrawListSharedData.Font->ContainerAtlas; |
| 3877 | for (ImGuiViewportP* viewport : g.Viewports) |
| 3878 | { |
| 3879 | // We scale cursor with current viewport/monitor, however Windows 10 for its own hardware cursor seems to be using a different scale factor. |
| 3880 | ImVec2 offset, size, uv[4]; |
| 3881 | if (!ImFontAtlasGetMouseCursorTexData(font_atlas, mouse_cursor, &offset, &size, &uv[0], &uv[2])) |
| 3882 | continue; |
| 3883 | const ImVec2 pos = base_pos - offset; |
| 3884 | const float scale = base_scale * viewport->DpiScale; |
| 3885 | if (!viewport->GetMainRect().Overlaps(ImRect(pos, pos + ImVec2(size.x + 2, size.y + 2) * scale))) |
| 3886 | continue; |
| 3887 | ImDrawList* draw_list = GetForegroundDrawList(viewport); |
| 3888 | ImTextureID tex_id = font_atlas->TexID; |
| 3889 | draw_list->PushTextureID(tex_id); |
| 3890 | draw_list->AddImage(tex_id, pos + ImVec2(1, 0) * scale, pos + (ImVec2(1, 0) + size) * scale, uv[2], uv[3], col_shadow); |
| 3891 | draw_list->AddImage(tex_id, pos + ImVec2(2, 0) * scale, pos + (ImVec2(2, 0) + size) * scale, uv[2], uv[3], col_shadow); |
| 3892 | draw_list->AddImage(tex_id, pos, pos + size * scale, uv[2], uv[3], col_border); |
| 3893 | draw_list->AddImage(tex_id, pos, pos + size * scale, uv[0], uv[1], col_fill); |
| 3894 | if (mouse_cursor == ImGuiMouseCursor_Wait || mouse_cursor == ImGuiMouseCursor_Progress) |
| 3895 | { |
| 3896 | float a_min = ImFmod((float)g.Time * 5.0f, 2.0f * IM_PI); |
| 3897 | float a_max = a_min + IM_PI * 1.65f; |
| 3898 | draw_list->PathArcTo(pos + ImVec2(14, -1) * scale, 6.0f * scale, a_min, a_max); |
| 3899 | draw_list->PathStroke(col_fill, ImDrawFlags_None, 3.0f * scale); |
| 3900 | } |
| 3901 | draw_list->PopTextureID(); |
| 3902 | } |
| 3903 | } |
| 3904 | |
| 3905 | //----------------------------------------------------------------------------- |
| 3906 | // [SECTION] INITIALIZATION, SHUTDOWN |
nothing calls this directly
no test coverage detected