MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/PositionBasedDynamics / RenderMouseCursor

Method RenderMouseCursor

extern/imgui/imgui.cpp:3438–3463  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3436}
3437
3438void ImGui::RenderMouseCursor(ImVec2 base_pos, float base_scale, ImGuiMouseCursor mouse_cursor, ImU32 col_fill, ImU32 col_border, ImU32 col_shadow)
3439{
3440 ImGuiContext& g = *GImGui;
3441 IM_ASSERT(mouse_cursor > ImGuiMouseCursor_None && mouse_cursor < ImGuiMouseCursor_COUNT);
3442 ImFontAtlas* font_atlas = g.DrawListSharedData.Font->ContainerAtlas;
3443 for (int n = 0; n < g.Viewports.Size; n++)
3444 {
3445 // We scale cursor with current viewport/monitor, however Windows 10 for its own hardware cursor seems to be using a different scale factor.
3446 ImVec2 offset, size, uv[4];
3447 if (!font_atlas->GetMouseCursorTexData(mouse_cursor, &offset, &size, &uv[0], &uv[2]))
3448 continue;
3449 ImGuiViewportP* viewport = g.Viewports[n];
3450 const ImVec2 pos = base_pos - offset;
3451 const float scale = base_scale * viewport->DpiScale;
3452 if (!viewport->GetMainRect().Overlaps(ImRect(pos, pos + ImVec2(size.x + 2, size.y + 2) * scale)))
3453 continue;
3454 ImDrawList* draw_list = GetForegroundDrawList(viewport);
3455 ImTextureID tex_id = font_atlas->TexID;
3456 draw_list->PushTextureID(tex_id);
3457 draw_list->AddImage(tex_id, pos + ImVec2(1, 0) * scale, pos + (ImVec2(1, 0) + size) * scale, uv[2], uv[3], col_shadow);
3458 draw_list->AddImage(tex_id, pos + ImVec2(2, 0) * scale, pos + (ImVec2(2, 0) + size) * scale, uv[2], uv[3], col_shadow);
3459 draw_list->AddImage(tex_id, pos, pos + size * scale, uv[2], uv[3], col_border);
3460 draw_list->AddImage(tex_id, pos, pos + size * scale, uv[0], uv[1], col_fill);
3461 draw_list->PopTextureID();
3462 }
3463}
3464
3465
3466//-----------------------------------------------------------------------------

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