MCPcopy Create free account
hub / github.com/TheForceEngine/TheForceEngine / RenderMouseCursor

Method RenderMouseCursor

TheForceEngine/TFE_Ui/imGUI/imgui.cpp:3616–3640  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3614}
3615
3616void ImGui::RenderMouseCursor(ImVec2 base_pos, float base_scale, ImGuiMouseCursor mouse_cursor, ImU32 col_fill, ImU32 col_border, ImU32 col_shadow)
3617{
3618 ImGuiContext& g = *GImGui;
3619 IM_ASSERT(mouse_cursor > ImGuiMouseCursor_None && mouse_cursor < ImGuiMouseCursor_COUNT);
3620 ImFontAtlas* font_atlas = g.DrawListSharedData.Font->ContainerAtlas;
3621 for (ImGuiViewportP* viewport : g.Viewports)
3622 {
3623 // We scale cursor with current viewport/monitor, however Windows 10 for its own hardware cursor seems to be using a different scale factor.
3624 ImVec2 offset, size, uv[4];
3625 if (!font_atlas->GetMouseCursorTexData(mouse_cursor, &offset, &size, &uv[0], &uv[2]))
3626 continue;
3627 const ImVec2 pos = base_pos - offset;
3628 const float scale = base_scale;
3629 if (!viewport->GetMainRect().Overlaps(ImRect(pos, pos + ImVec2(size.x + 2, size.y + 2) * scale)))
3630 continue;
3631 ImDrawList* draw_list = GetForegroundDrawList(viewport);
3632 ImTextureID tex_id = font_atlas->TexID;
3633 draw_list->PushTextureID(tex_id);
3634 draw_list->AddImage(tex_id, pos + ImVec2(1, 0) * scale, pos + (ImVec2(1, 0) + size) * scale, uv[2], uv[3], col_shadow);
3635 draw_list->AddImage(tex_id, pos + ImVec2(2, 0) * scale, pos + (ImVec2(2, 0) + size) * scale, uv[2], uv[3], col_shadow);
3636 draw_list->AddImage(tex_id, pos, pos + size * scale, uv[2], uv[3], col_border);
3637 draw_list->AddImage(tex_id, pos, pos + size * scale, uv[0], uv[1], col_fill);
3638 draw_list->PopTextureID();
3639 }
3640}
3641
3642//-----------------------------------------------------------------------------
3643// [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