diff --git a/imgui.h b/imgui.h index ef702a8af..16b468ad9 100644 --- a/imgui.h +++ b/imgui.h @@ -3459,7 +3459,7 @@ enum ImDrawFlags_ // Stroke/Fill Anti-aliasing ------------------ // Prim/Scope? ImDrawFlags_AAFill = 1 << 12, // OK* OK(1) // Enable anti-aliasing for Filled shapes. ImDrawFlags_AALines = 1 << 13, // OK* OK(1) // Enable anti-aliasing for Strokes (lines, borders). - ImDrawFlags_AALineEnds = 1 << 14, // OK OK(0) // Enable anti-aliasing for Strokes Ends. Useful on thick strokes or for precise continuity of multiple lines. A little more costly. + ImDrawFlags_AALineEnds = 1 << 14, // OK OK(0) // Enable anti-aliasing for Strokes Ends. Requires AALines to also be enabled. Useful on thick strokes or for precise continuity of multiple lines. A little more costly. //ImDrawFlags_NoAA = 1 << 15, // OK -- // Disable anti-aliasing for a given primitive. //ImDrawFlags_NoAALineEnds = 1 << 16, // OK -- // Disable anti-aliasing ends for a given primitive. diff --git a/imgui_demo.cpp b/imgui_demo.cpp index 9be3d43be..ea1da4006 100644 --- a/imgui_demo.cpp +++ b/imgui_demo.cpp @@ -8935,8 +8935,9 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref) Checkbox("Anti-aliased lines", &style.AntiAliasedLines); SameLine(); HelpMarker("When disabling anti-aliasing lines, you'll probably want to disable borders in your style as well."); - + BeginDisabled(style.AntiAliasedLines == false); Checkbox("Anti-aliased line ends", &style.AntiAliasedLineEnds); + EndDisabled(); #ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS BeginDisabled(); diff --git a/imgui_draw.cpp b/imgui_draw.cpp index 385bdae05..2ff3d8f63 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -1051,6 +1051,7 @@ void ImDrawList::AddPolyline(const ImVec2* points, const int points_count, ImU32 const float half_aa = _FringeScale * 0.5f; // Used for end caps, does not use "fringe" since end cap AA is not using the texture. const float half_thickness = thickness * 0.5f; + const bool use_aa_ends = (flags & (ImDrawFlags_AALines | ImDrawFlags_AALineEnds)) == (ImDrawFlags_AALines | ImDrawFlags_AALineEnds); const int first_vtx_offset = (int)(_VtxWritePtr - VtxBuffer.Data); int base_idx = (int)_VtxCurrentIdx; @@ -1079,7 +1080,7 @@ void ImDrawList::AddPolyline(const ImVec2* points, const int points_count, ImU32 p1.y -= dir.y * half_thickness; } - if ((flags & ImDrawFlags_AALineEnds) == 0) + if (!use_aa_ends) { base_idx = (int)_VtxCurrentIdx; IM_APPEND_VTX(p1.x - n1.x * thickness0, p1.y - n1.y * thickness0, uv0, col); @@ -1265,7 +1266,7 @@ void ImDrawList::AddPolyline(const ImVec2* points, const int points_count, ImU32 p1.y += dir.y * half_thickness; } - if ((flags & ImDrawFlags_AALineEnds) == 0) + if (!use_aa_ends) { IM_APPEND_VTX(p1.x - n1.x * thickness0, p1.y - n1.y * thickness0, uv0, col); IM_APPEND_VTX(p1.x + n1.x * thickness1, p1.y + n1.y * thickness1, uv1, col); @@ -1895,8 +1896,9 @@ void ImDrawList::_AddLine(const ImVec2& p1, const ImVec2& p2, ImU32 col, float t const float half_aa = _FringeScale * 0.5f; // Used for end caps, does not use "fringe" since end cap AA is not using the texture. const float half_thickness = thickness * 0.5f; + const bool use_aa_ends = (flags & (ImDrawFlags_AALines | ImDrawFlags_AALineEnds)) == (ImDrawFlags_AALines | ImDrawFlags_AALineEnds); - if ((flags & ImDrawFlags_AALineEnds) == 0) + if (!use_aa_ends) PrimReserve(2*3, 4); else PrimReserve(6*3, 8); @@ -1916,7 +1918,7 @@ void ImDrawList::_AddLine(const ImVec2& p1, const ImVec2& p2, ImU32 col, float t } // Start cap - if ((flags & ImDrawFlags_AALineEnds) == 0) + if (!use_aa_ends) { base_idx = (int)_VtxCurrentIdx; IM_APPEND_VTX(p1_x - norm_x * thickness0, p1_y - norm_y * thickness0, uv0, col); @@ -7583,7 +7585,7 @@ void ImGui::RenderCheckMark(ImDrawList* draw_list, ImVec2 pos, ImU32 col, float draw_list->PathLineTo(ImVec2(bx - third, by - third)); draw_list->PathLineTo(ImVec2(bx, by)); draw_list->PathLineTo(ImVec2(bx + third * 2.0f, by - third * 2.0f)); - draw_list->PathStroke(col, thickness, (draw_list->Flags & ImDrawFlags_AALines) ? ImDrawFlags_AALineEnds : 0); // FIXME: Design idiomatic selection/threshold for this? + draw_list->PathStroke(col, thickness, ImDrawFlags_AALineEnds); } // Render an arrow. 'pos' is position of the arrow tip. half_sz.x is length from base to tip. half_sz.y is length on each side.