MCPcopy Create free account
hub / github.com/cinder/Cinder / RenderMouseCursor

Method RenderMouseCursor

src/imgui/imgui.cpp:3928–3960  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3926}
3927
3928void ImGui::RenderMouseCursor(ImVec2 base_pos, float base_scale, ImGuiMouseCursor mouse_cursor, ImU32 col_fill, ImU32 col_border, ImU32 col_shadow)
3929{
3930 ImGuiContext& g = *GImGui;
3931 if (mouse_cursor <= ImGuiMouseCursor_None || mouse_cursor >= ImGuiMouseCursor_COUNT) // We intentionally accept out of bound values.
3932 mouse_cursor = ImGuiMouseCursor_Arrow;
3933 ImFontAtlas* font_atlas = g.DrawListSharedData.FontAtlas;
3934 for (ImGuiViewportP* viewport : g.Viewports)
3935 {
3936 // We scale cursor with current viewport/monitor, however Windows 10 for its own hardware cursor seems to be using a different scale factor.
3937 ImVec2 offset, size, uv[4];
3938 if (!ImFontAtlasGetMouseCursorTexData(font_atlas, mouse_cursor, &offset, &size, &uv[0], &uv[2]))
3939 continue;
3940 const ImVec2 pos = base_pos - offset;
3941 const float scale = base_scale;
3942 if (!viewport->GetMainRect().Overlaps(ImRect(pos, pos + ImVec2(size.x + 2, size.y + 2) * scale)))
3943 continue;
3944 ImDrawList* draw_list = GetForegroundDrawList(viewport);
3945 ImTextureRef tex_ref = font_atlas->TexRef;
3946 draw_list->PushTexture(tex_ref);
3947 draw_list->AddImage(tex_ref, pos + ImVec2(1, 0) * scale, pos + (ImVec2(1, 0) + size) * scale, uv[2], uv[3], col_shadow);
3948 draw_list->AddImage(tex_ref, pos + ImVec2(2, 0) * scale, pos + (ImVec2(2, 0) + size) * scale, uv[2], uv[3], col_shadow);
3949 draw_list->AddImage(tex_ref, pos, pos + size * scale, uv[2], uv[3], col_border);
3950 draw_list->AddImage(tex_ref, pos, pos + size * scale, uv[0], uv[1], col_fill);
3951 if (mouse_cursor == ImGuiMouseCursor_Wait || mouse_cursor == ImGuiMouseCursor_Progress)
3952 {
3953 float a_min = ImFmod((float)g.Time * 5.0f, 2.0f * IM_PI);
3954 float a_max = a_min + IM_PI * 1.65f;
3955 draw_list->PathArcTo(pos + ImVec2(14, -1) * scale, 6.0f * scale, a_min, a_max);
3956 draw_list->PathStroke(col_fill, ImDrawFlags_None, 3.0f * scale);
3957 }
3958 draw_list->PopTexture();
3959 }
3960}
3961
3962//-----------------------------------------------------------------------------
3963// [SECTION] INITIALIZATION, SHUTDOWN

Callers

nothing calls this directly

Calls 10

ImVec2Function · 0.85
GetForegroundDrawListFunction · 0.85
GetMainRectMethod · 0.80
PushTextureMethod · 0.80
AddImageMethod · 0.80
PathArcToMethod · 0.80
PathStrokeMethod · 0.80
PopTextureMethod · 0.80
ImRectFunction · 0.50

Tested by

no test coverage detected