From 52deb415e0ed9bc042f8eacfea5114ad3d562455 Mon Sep 17 00:00:00 2001 From: omar Date: Mon, 23 Sep 2019 14:53:49 +0200 Subject: [PATCH] Internal: Refactored internal RenderMouseCursor so colors can be specified. (#2614) --- imgui.cpp | 2 +- imgui_draw.cpp | 6 +----- imgui_internal.h | 2 +- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index e25ca076..1557d595 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -4274,7 +4274,7 @@ void ImGui::Render() // Draw software mouse cursor if requested if (g.IO.MouseDrawCursor) - RenderMouseCursor(&g.ForegroundDrawList, g.IO.MousePos, g.Style.MouseCursorScale, g.MouseCursor); + RenderMouseCursor(&g.ForegroundDrawList, g.IO.MousePos, g.Style.MouseCursorScale, g.MouseCursor, IM_COL32_WHITE, IM_COL32_BLACK, IM_COL32(0, 0, 0, 48)); if (!g.ForegroundDrawList.VtxBuffer.empty()) AddDrawListToDrawData(&g.DrawDataBuilder.Layers[0], &g.ForegroundDrawList); diff --git a/imgui_draw.cpp b/imgui_draw.cpp index eb173b44..2cbf209b 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -3038,16 +3038,12 @@ void ImFont::RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col // - RenderRectFilledRangeH() //----------------------------------------------------------------------------- -void ImGui::RenderMouseCursor(ImDrawList* draw_list, ImVec2 pos, float scale, ImGuiMouseCursor mouse_cursor) +void ImGui::RenderMouseCursor(ImDrawList* draw_list, ImVec2 pos, float scale, ImGuiMouseCursor mouse_cursor, ImU32 col_fill, ImU32 col_border, ImU32 col_shadow) { if (mouse_cursor == ImGuiMouseCursor_None) return; IM_ASSERT(mouse_cursor > ImGuiMouseCursor_None && mouse_cursor < ImGuiMouseCursor_COUNT); - const ImU32 col_shadow = IM_COL32(0, 0, 0, 48); - const ImU32 col_border = IM_COL32(0, 0, 0, 255); // Black - const ImU32 col_fill = IM_COL32(255, 255, 255, 255); // White - ImFontAtlas* font_atlas = draw_list->_Data->Font->ContainerAtlas; ImVec2 offset, size, uv[4]; if (font_atlas->GetMouseCursorTexData(mouse_cursor, &offset, &size, &uv[0], &uv[2])) diff --git a/imgui_internal.h b/imgui_internal.h index 0a585f34..acd2d256 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -1636,7 +1636,7 @@ namespace ImGui // Render helpers (those functions don't access any ImGui state!) IMGUI_API void RenderArrow(ImDrawList* draw_list, ImVec2 pos, ImU32 col, ImGuiDir dir, float scale = 1.0f); IMGUI_API void RenderBullet(ImDrawList* draw_list, ImVec2 pos, ImU32 col); - IMGUI_API void RenderMouseCursor(ImDrawList* draw_list, ImVec2 pos, float scale, ImGuiMouseCursor mouse_cursor = ImGuiMouseCursor_Arrow); + IMGUI_API void RenderMouseCursor(ImDrawList* draw_list, ImVec2 pos, float scale, ImGuiMouseCursor mouse_cursor, ImU32 col_fill, ImU32 col_border, ImU32 col_shadow); IMGUI_API void RenderArrowPointingAt(ImDrawList* draw_list, ImVec2 pos, ImVec2 half_sz, ImGuiDir direction, ImU32 col); IMGUI_API void RenderRectFilledRangeH(ImDrawList* draw_list, const ImRect& rect, ImU32 col, float x_start_norm, float x_end_norm, float rounding);