diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index f366c9b22..8a5cc05b4 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -103,7 +103,7 @@ HOW TO UPDATE? - Helps fills minor gaps if combining multiple individual lines. - Enabling AA Ends by default would be more "correct", but it is slower and increase vertex/index data.s - Added `ImDrawFlags_MiterOnly` flag to disable using beveled corner (closer to legacy - rendering, slightly faster, but corners sharpers than 90 degrees may expand far out). + rendering, slightly faster, but corners sharper than 90 degrees may expand far out). Automatically used by AddRect(), AddCircle(), AddNgon(), AddEllipse() etc functions since we know that the input path does not contains sharper corners. - Added `ImDrawFlags_SquareCap` flag to use extend lines ends using square caps. @@ -127,9 +127,9 @@ HOW TO UPDATE? - Added flags to specify stroke position in all `ImDrawList` stroking functions: - `ImDrawFlags_StrokeInside` (default for closed primitives and AddLineH, AddLineV) - `ImDrawFlags_StrokeCenter` (default for paths, bezier and AddLine) - - `ImDrawFlags_StrokeCenterAligned` + - `ImDrawFlags_StrokeCenterBiased` - `ImDrawFlags_StrokeOutside` - - `ImDrawFlags_StrokeLegacy` (may be set as default for a given scope using PushItemFlag()). + - `ImDrawFlags_StrokeLegacy` (may be set as default for a given scope using PushDrawFlag()). - Legacy code was generally applying +0.50f offset which meant that, - with thickness=1.0f: the stroke would appear inside. - with thickness>1.0f: the stroke would start expanding on both sides but starting from that slightly initial offset. @@ -139,7 +139,7 @@ HOW TO UPDATE? regardless of thickness, as long as input coordinates/sizes are integers. (#9359) - Read our Wiki guides! Recap: ------------------------------------------------------------------------ - Legacy Inside Outside Center CenterAligned + Legacy Inside Outside Center CenterBiased -------------------------------------------------------------------------------- Thickness=1.0f sharp sharp sharp blurry sharp Thickness=2.0f blurry sharp sharp sharp sharp diff --git a/imgui.cpp b/imgui.cpp index 0dafad7bd..c9f203ff3 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -5782,6 +5782,8 @@ static void SetupDrawListSharedData() g.DrawListSharedData.CurveTessellationMaxError = g.Style.CurveTessellationMaxError; g.DrawListSharedData.SetCircleTessellationMaxError(g.Style.CircleTessellationMaxError); g.DrawListSharedData.InitialDrawFlags = ImDrawFlags_None; + if (g.IO.Fonts->Flags & ImFontAtlasFlags_NoBakedLines) + g.Style.AntiAliasedLines = g.Style.AntiAliasedLineEnds = false; if (g.Style.AntiAliasedFill) g.DrawListSharedData.InitialDrawFlags |= ImDrawFlags_AAFill; if (g.Style.AntiAliasedLines) diff --git a/imgui.h b/imgui.h index 635f302a4..cbb48a17a 100644 --- a/imgui.h +++ b/imgui.h @@ -3550,7 +3550,7 @@ struct ImDrawList IMGUI_API void AddRectFilledMultiColor(const ImVec2& p_min, const ImVec2& p_max, ImU32 col_upr_left, ImU32 col_upr_right, ImU32 col_bot_right, ImU32 col_bot_left); IMGUI_API void AddQuad(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, ImU32 col, float thickness = 1.0f, ImDrawFlags flags = 0); IMGUI_API void AddQuadFilled(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, ImU32 col); - IMGUI_API void AddTriangle(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, ImU32 col, float thickness = 1.0f, ImDrawFlags = 0); + IMGUI_API void AddTriangle(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, ImU32 col, float thickness = 1.0f, ImDrawFlags flags = 0); IMGUI_API void AddTriangleFilled(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, ImU32 col); IMGUI_API void AddCircle(const ImVec2& center, float radius, ImU32 col, int num_segments = 0, float thickness = 1.0f, ImDrawFlags flags = 0); IMGUI_API void AddCircleFilled(const ImVec2& center, float radius, ImU32 col, int num_segments = 0); @@ -3886,7 +3886,7 @@ enum ImFontAtlasFlags_ ImFontAtlasFlags_None = 0, ImFontAtlasFlags_NoPowerOfTwoHeight = 1 << 0, // Don't round the height to next power of two ImFontAtlasFlags_NoMouseCursors = 1 << 1, // Don't build software mouse cursors into the atlas (save a little texture memory) - ImFontAtlasFlags_NoBakedLines = 1 << 2, // [OBSOLETE] Don't build line textures into the atlas (save a little texture memory). SINCE 1.93.0 THIS PREVENT ANTI-ALIASED STROKES FROM WORKING. + ImFontAtlasFlags_NoBakedLines = 1 << 2, // [OBSOLETE] Don't build line textures into the atlas (save a little texture memory). SINCE 1.93.0 THIS PREVENT ANTI-ALIASED STROKES FROM WORKING AND WILL DISABLE AA. ImFontAtlasFlags_NoBakedRoundCorners= 1 << 3, // Don't build round corners into the atlas. }; diff --git a/imgui_draw.cpp b/imgui_draw.cpp index e4fd10156..a6bb4a405 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -723,6 +723,7 @@ void ImDrawList::PopTexture() void ImDrawList::PushDrawFlag(ImDrawFlags flags, bool enabled) { IM_ASSERT((flags & ~ImDrawFlags_AllowedInScope_) == 0); + IM_ASSERT((flags & ImDrawFlags_StrokeMask_) == 0 || (flags & ImDrawFlags_StrokeMask_) == ImDrawFlags_StrokeLegacy); _DrawFlagsStack.push_back(Flags); if (enabled) Flags |= flags; @@ -732,7 +733,7 @@ void ImDrawList::PushDrawFlag(ImDrawFlags flags, bool enabled) void ImDrawList::PopDrawFlag() { - IM_ASSERT_USER_ERROR_RET(_DrawFlagsStack.Size > 0, "Calling PopDrawFlags() too many times!"); + IM_ASSERT_USER_ERROR_RET(_DrawFlagsStack.Size > 0, "Calling PopDrawFlag() too many times!"); Flags = _DrawFlagsStack.back(); _DrawFlagsStack.pop_back(); } @@ -900,7 +901,7 @@ IM_MSVC_RUNTIME_CHECKS_RESTORE IM_MSVC_RUNTIME_CHECKS_OFF static ImU32 ImAlphaMultiply(ImU32 col, float alpha_mul) { - IM_ASSERT_PARANOID(a >= 0.0f && a < 1.0f); // We don't clamp! + IM_ASSERT_PARANOID(alpha_mul >= 0.0f && alpha_mul < 1.0f); // We don't clamp! ImU32 a = (col & IM_COL32_A_MASK) >> IM_COL32_A_SHIFT; a = (ImU32)(a * alpha_mul); // We don't need to clamp 0..255 because alpha is in 0..1 range. return (col & ~IM_COL32_A_MASK) | (a << IM_COL32_A_SHIFT); @@ -2028,7 +2029,7 @@ void ImDrawList::AddLineH(float min_x, float max_x, float y, ImU32 col, float th } else { - // Replace stroke pos with the already calculated one. + // Replace stroke pos with the already calculated one, as AddPolyline() default is different. flags = (flags & ~ImDrawFlags_StrokeMask_) | stroke_pos; // For generic case use line, since it needs less triangles than AA rectangle. @@ -2074,7 +2075,7 @@ void ImDrawList::AddLineV(float x, float min_y, float max_y, ImU32 col, float th } else { - // Replace stroke pos with the already calculated one. + // Replace stroke pos with the already calculated one, as AddPolyline() default is different. flags = (flags & ~ImDrawFlags_StrokeMask_) | stroke_pos; // For generic case use line, since it needs less triangles than AA rectangle. @@ -2623,8 +2624,9 @@ void ImDrawList::AddQuad(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, c if ((col & IM_COL32_A_MASK) == 0) return; + //flags |= Flags; // Not needed. ImDrawFlags stroke_pos = _GetStrokePos(flags, ImDrawFlags_StrokeInside); - flags = (flags & ~ImDrawFlags_StrokeMask_) | stroke_pos; + flags = (flags & ~ImDrawFlags_StrokeMask_) | stroke_pos; // As AddPolyline() default is different const ImVec2 points[4] = { p1, p2, p3, p4 }; AddPolyline(points, 4, col, thickness, flags | ImDrawFlags_Closed); @@ -2644,8 +2646,9 @@ void ImDrawList::AddTriangle(const ImVec2& p1, const ImVec2& p2, const ImVec2& p if ((col & IM_COL32_A_MASK) == 0) return; + //flags |= Flags; // Not needed. ImDrawFlags stroke_pos = _GetStrokePos(flags, ImDrawFlags_StrokeInside); - flags = (flags & ~ImDrawFlags_StrokeMask_) | stroke_pos; + flags = (flags & ~ImDrawFlags_StrokeMask_) | stroke_pos; // As AddPolyline() default is different const ImVec2 points[3] = { p1, p2, p3 }; AddPolyline(points, 3, col, thickness, flags | ImDrawFlags_Closed);