| 4104 | } |
| 4105 | |
| 4106 | void ImGui::RenderMouseCursor(ImVec2 base_pos, float base_scale, ImGuiMouseCursor mouse_cursor, ImU32 col_fill, ImU32 col_border, ImU32 col_shadow) |
| 4107 | { |
| 4108 | ImGuiContext& g = *GImGui; |
| 4109 | if (mouse_cursor <= ImGuiMouseCursor_None || mouse_cursor >= ImGuiMouseCursor_COUNT) // We intentionally accept out of bound values. |
| 4110 | mouse_cursor = ImGuiMouseCursor_Arrow; |
| 4111 | ImFontAtlas* font_atlas = g.DrawListSharedData.FontAtlas; |
| 4112 | for (ImGuiViewportP* viewport : g.Viewports) |
| 4113 | { |
| 4114 | // We scale cursor with current viewport/monitor, however Windows 10 for its own hardware cursor seems to be using a different scale factor. |
| 4115 | ImVec2 offset, size, uv[4]; |
| 4116 | if (!ImFontAtlasGetMouseCursorTexData(font_atlas, mouse_cursor, &offset, &size, &uv[0], &uv[2])) |
| 4117 | continue; |
| 4118 | const ImVec2 pos = base_pos - offset; |
| 4119 | const float scale = base_scale * viewport->DpiScale; |
| 4120 | if (!viewport->GetMainRect().Overlaps(ImRect(pos, pos + ImVec2(size.x + 2, size.y + 2) * scale))) |
| 4121 | continue; |
| 4122 | ImDrawList* draw_list = GetForegroundDrawList(viewport); |
| 4123 | ImTextureRef tex_ref = font_atlas->TexRef; |
| 4124 | draw_list->PushTexture(tex_ref); |
| 4125 | draw_list->AddImage(tex_ref, pos + ImVec2(1, 0) * scale, pos + (ImVec2(1, 0) + size) * scale, uv[2], uv[3], col_shadow); |
| 4126 | draw_list->AddImage(tex_ref, pos + ImVec2(2, 0) * scale, pos + (ImVec2(2, 0) + size) * scale, uv[2], uv[3], col_shadow); |
| 4127 | draw_list->AddImage(tex_ref, pos, pos + size * scale, uv[2], uv[3], col_border); |
| 4128 | draw_list->AddImage(tex_ref, pos, pos + size * scale, uv[0], uv[1], col_fill); |
| 4129 | if (mouse_cursor == ImGuiMouseCursor_Wait || mouse_cursor == ImGuiMouseCursor_Progress) |
| 4130 | { |
| 4131 | float a_min = ImFmod((float)g.Time * 5.0f, 2.0f * IM_PI); |
| 4132 | float a_max = a_min + IM_PI * 1.65f; |
| 4133 | draw_list->PathArcTo(pos + ImVec2(14, -1) * scale, 6.0f * scale, a_min, a_max); |
| 4134 | draw_list->PathStroke(col_fill, ImDrawFlags_None, 3.0f * scale); |
| 4135 | } |
| 4136 | draw_list->PopTexture(); |
| 4137 | } |
| 4138 | } |
| 4139 | |
| 4140 | //----------------------------------------------------------------------------- |
| 4141 | // [SECTION] INITIALIZATION, SHUTDOWN |
nothing calls this directly
no test coverage detected