MCPcopy Create free account
hub / github.com/KebsCS/KBotExt / RenderMouseCursor

Method RenderMouseCursor

KBotExt/imgui/imgui.cpp:3470–3494  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3468}
3469
3470void ImGui::RenderMouseCursor(ImVec2 base_pos, float base_scale, ImGuiMouseCursor mouse_cursor, ImU32 col_fill, ImU32 col_border, ImU32 col_shadow)
3471{
3472 ImGuiContext& g = *GImGui;
3473 IM_ASSERT(mouse_cursor > ImGuiMouseCursor_None && mouse_cursor < ImGuiMouseCursor_COUNT);
3474 ImFontAtlas* font_atlas = g.DrawListSharedData.Font->ContainerAtlas;
3475 for (ImGuiViewportP* viewport : g.Viewports)
3476 {
3477 // We scale cursor with current viewport/monitor, however Windows 10 for its own hardware cursor seems to be using a different scale factor.
3478 ImVec2 offset, size, uv[4];
3479 if (!font_atlas->GetMouseCursorTexData(mouse_cursor, &offset, &size, &uv[0], &uv[2]))
3480 continue;
3481 const ImVec2 pos = base_pos - offset;
3482 const float scale = base_scale;
3483 if (!viewport->GetMainRect().Overlaps(ImRect(pos, pos + ImVec2(size.x + 2, size.y + 2) * scale)))
3484 continue;
3485 ImDrawList* draw_list = GetForegroundDrawList(viewport);
3486 ImTextureID tex_id = font_atlas->TexID;
3487 draw_list->PushTextureID(tex_id);
3488 draw_list->AddImage(tex_id, pos + ImVec2(1, 0) * scale, pos + (ImVec2(1, 0) + size) * scale, uv[2], uv[3], col_shadow);
3489 draw_list->AddImage(tex_id, pos + ImVec2(2, 0) * scale, pos + (ImVec2(2, 0) + size) * scale, uv[2], uv[3], col_shadow);
3490 draw_list->AddImage(tex_id, pos, pos + size * scale, uv[2], uv[3], col_border);
3491 draw_list->AddImage(tex_id, pos, pos + size * scale, uv[0], uv[1], col_fill);
3492 draw_list->PopTextureID();
3493 }
3494}
3495
3496//-----------------------------------------------------------------------------
3497// [SECTION] INITIALIZATION, SHUTDOWN

Callers

nothing calls this directly

Calls 8

ImVec2Function · 0.85
GetForegroundDrawListFunction · 0.85
GetMouseCursorTexDataMethod · 0.80
GetMainRectMethod · 0.80
PushTextureIDMethod · 0.80
AddImageMethod · 0.80
PopTextureIDMethod · 0.80
ImRectFunction · 0.70

Tested by

no test coverage detected