Skip to content

Commit b8516b3

Browse files
committed
DrawList: rename ImDrawFlags_MiterOnly->ImDrawFlags_JoinMiter, ImDrawFlags_SquareCap->ImDrawFlags_CapSquare.
1 parent 32b4600 commit b8516b3

4 files changed

Lines changed: 30 additions & 30 deletions

File tree

docs/CHANGELOG.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,18 +175,18 @@ Other Changes:
175175
slower and increases vertex/index data we decided to not enable it by default.
176176
This keeps situations such as "throw tens of thousands of lines at ImDrawList"
177177
optimal. You can opt-in for a given shape or in a scope using `PushDrawFlag()`.
178-
- Added `ImDrawFlags_MiterOnly` flag to disable using beveled corner.
178+
- Added `ImDrawFlags_JoinMiter` flag to disable using beveled corner.
179179
- Closer to legacy rendering and slightly faster, but corners sharper than
180180
90 degrees may expand far out.
181181
- Automatically used by AddRect(), AddCircle(), AddNgon(), AddEllipse() functions
182182
since we know that the input path does not contain sharper corners.
183-
- Added `ImDrawFlags_SquareCap` flag to extend lines ends using square caps. (#9360)
183+
- Added `ImDrawFlags_CapSquare` flag to extend lines ends using square caps. (#9360)
184184
- AddConvexPolyFilled()/PathFillConvex(): improved to handle input geometry more robustly.
185185
The rendering of sharp corners was improved. Earlier there were issues with sharp corners
186186
either creating long spikes, or messing up the adjacent edge's anti-aliasing. Now the
187187
anti-aliasing fringe calculation is more consistent, and sharp corners get bevelled to
188188
avoid spikes. There might still be issues when the smallest extent of a long thin polygon
189-
is less than a pixel. Also supports `ImDrawFlags_MiterOnly`, to facilitate matching
189+
is less than a pixel. Also supports `ImDrawFlags_JoinMiter`, to facilitate matching
190190
a stroke using the same flag.
191191
- AddRect(), AddRectFilled(): various optimizations for rounded rectangles. (#1962)
192192
- Integer-aligned coordinates and thicknesses will automatically use baked textures,

imgui.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3449,8 +3449,8 @@ enum ImDrawFlags_
34493449

34503450
// Stroke Options ----------------------------- // Prim/Scope?
34513451
ImDrawFlags_Closed = 1 << 9, // OK -- // PathStroke(), AddPolyline(): specify that shape should be closed.
3452-
ImDrawFlags_MiterOnly = 1 << 10, // OK -- // PathStroke(), AddPolyline(): use miter corners only. This assumes that the input polyline does not have corners sharper than 90 degrees. Slightly faster.
3453-
ImDrawFlags_SquareCap = 1 << 11, // OK -- // PathStroke(), AddPolyline(): use square cap line ends.
3452+
ImDrawFlags_JoinMiter = 1 << 10, // OK -- // PathStroke(), AddPolyline(): use miter joins/corners only. This assumes that the input polyline does not have corners sharper than 90 degrees. Slightly faster.
3453+
ImDrawFlags_CapSquare = 1 << 11, // OK -- // PathStroke(), AddPolyline(): use square cap line ends.
34543454

34553455
// About Stroke Ends:
34563456
// - Rendering is optimized for fast pixel-perfect UI, so line ends are not anti-aliased by default. It's cheaper (we can emit less vertices).
@@ -3472,7 +3472,7 @@ enum ImDrawFlags_
34723472
ImDrawFlags_StrokeCenter = 2 << 17, // OK -- // Draw stroke at the center of the shape outline (default for paths, bezier, and AddLine functions)
34733473
ImDrawFlags_StrokeCenterBiased = 3 << 17, // OK -- // Draw stroke at the center of the shape outline, so that half thickness rounded down will be outside, and the rest inside the shape outline. Useful for axis-aligned shapes: AddLineH, AddLineV, AddRect. Does not animate well!
34743474
ImDrawFlags_StrokeOutside = 4 << 17, // OK -- // Draw stroke outside of the shape outline
3475-
ImDrawFlags_StrokeLegacy = 7 << 17, // OK OK(0) // Use legacy positioning + enable MiterOnly + disable AALineEnds. Must be all bits set.
3475+
ImDrawFlags_StrokeLegacy = 7 << 17, // OK OK(0) // Use legacy positioning + enable JoinMiter + disable AALineEnds. Must be all bits set.
34763476

34773477
// Other Options ------------------------------ // Prim/Scope?
34783478
ImDrawFlags_TextNoPixelSnap = 1 << 20, // OK OK(0) // Disable automatically snapping AddText() calls to pixel boundaries.

imgui_demo.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10472,8 +10472,8 @@ static void ShowExampleAppCustomRendering(bool* p_open)
1047210472
ImGui::CheckboxFlags("AAFill", &prim_other_flags, ImDrawFlags_AAFill); ImGui::SameLine(); // Note: Only for functions taking flags.
1047310473
ImGui::CheckboxFlags("AALines", &prim_other_flags, ImDrawFlags_AALines); ImGui::SameLine(); // Note: Only for functions taking flags.
1047410474
ImGui::CheckboxFlags("AALineEnds", &prim_other_flags, ImDrawFlags_AALineEnds); ImGui::SameLine();
10475-
ImGui::CheckboxFlags("MiterOnly", &prim_other_flags, ImDrawFlags_MiterOnly); ImGui::SameLine();
10476-
ImGui::CheckboxFlags("SquareCap", &prim_other_flags, ImDrawFlags_SquareCap);
10475+
ImGui::CheckboxFlags("JoinMiter", &prim_other_flags, ImDrawFlags_JoinMiter); ImGui::SameLine();
10476+
ImGui::CheckboxFlags("CapSquare", &prim_other_flags, ImDrawFlags_CapSquare);
1047710477
//ImGui::CheckboxFlags("UseTexForRoundCorners", &prim_other_flags, ImDrawFlags_UseTexForRoundCorners);
1047810478

1047910479
static ImDrawFlags scope_flags = draw_list->Flags & ImDrawFlags_AllowInPushScope_; // First init copy current state.

imgui_draw.cpp

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,10 +1013,10 @@ void ImDrawList::_AddPolyline(const ImVec2* points, const int points_count, ImU3
10131013

10141014
const ImDrawFlags stroke_pos = _GetStrokePos(flags, ImDrawFlags_StrokeCenter);
10151015
if (stroke_pos == ImDrawFlags_StrokeLegacy)
1016-
flags = (flags | ImDrawFlags_MiterOnly) & ~ImDrawFlags_AALineEnds;
1016+
flags = (flags | ImDrawFlags_JoinMiter) & ~ImDrawFlags_AALineEnds;
10171017

10181018
const bool closed = (flags & ImDrawFlags_Closed) != 0;
1019-
const bool miters_only = (flags & ImDrawFlags_MiterOnly) != 0;
1019+
const bool miters_only = (flags & ImDrawFlags_JoinMiter) != 0;
10201020
const float miter_distance_limit_sqr = IM_POLYLINE_MITER_LIMIT * IM_POLYLINE_MITER_LIMIT;
10211021

10221022
float thickness0 = (thickness + fringe) * 0.5f; // Center (or legacy)
@@ -1082,7 +1082,7 @@ void ImDrawList::_AddPolyline(const ImVec2* points, const int points_count, ImU3
10821082

10831083
dir.x = n1.y;
10841084
dir.y = -n1.x;
1085-
if (flags & ImDrawFlags_SquareCap)
1085+
if (flags & ImDrawFlags_CapSquare)
10861086
{
10871087
p1.x -= dir.x * half_thickness;
10881088
p1.y -= dir.y * half_thickness;
@@ -1268,7 +1268,7 @@ void ImDrawList::_AddPolyline(const ImVec2* points, const int points_count, ImU3
12681268
// End cap
12691269
dir.x = n1.y;
12701270
dir.y = -n1.x;
1271-
if (flags & ImDrawFlags_SquareCap)
1271+
if (flags & ImDrawFlags_CapSquare)
12721272
{
12731273
p1.x += dir.x * half_thickness;
12741274
p1.y += dir.y * half_thickness;
@@ -1336,7 +1336,7 @@ void ImDrawList::AddConvexPolyFilled(const ImVec2* points, const int points_coun
13361336
{
13371337
const float half_aa = _FringeScale * 0.5f;
13381338
ImU32 col_trans = col & ~IM_COL32_A_MASK;
1339-
const bool miters_only = (flags & ImDrawFlags_MiterOnly) != 0;
1339+
const bool miters_only = (flags & ImDrawFlags_JoinMiter) != 0;
13401340
const float miter_distance_limit_sqr = IM_POLYLINE_MITER_LIMIT * IM_POLYLINE_MITER_LIMIT;
13411341

13421342
const int idx_count = ((points_count - 2) + points_count * 2 + IM_POLYLINE_CONVEX_POLY_MAX_BEVELS) * 3;
@@ -1891,7 +1891,7 @@ void ImDrawList::_AddLine(const ImVec2& p1, const ImVec2& p2, ImU32 col, float t
18911891

18921892
const ImDrawFlags stroke_pos = _GetStrokePos(flags, ImDrawFlags_StrokeCenter);
18931893
if (stroke_pos == ImDrawFlags_StrokeLegacy)
1894-
flags = (flags | ImDrawFlags_MiterOnly) & ~ImDrawFlags_AALineEnds;
1894+
flags = (flags | ImDrawFlags_JoinMiter) & ~ImDrawFlags_AALineEnds;
18951895

18961896
float thickness0 = (thickness + fringe) * 0.5f; // Center (or legacy)
18971897
if (stroke_pos == ImDrawFlags_StrokeOutside)
@@ -1920,7 +1920,7 @@ void ImDrawList::_AddLine(const ImVec2& p1, const ImVec2& p2, ImU32 col, float t
19201920
float p1_y = p1.y;
19211921
float p2_x = p2.x;
19221922
float p2_y = p2.y;
1923-
if (flags & ImDrawFlags_SquareCap)
1923+
if (flags & ImDrawFlags_CapSquare)
19241924
{
19251925
p1_x -= dir_x * half_thickness;
19261926
p1_y -= dir_y * half_thickness;
@@ -2025,7 +2025,7 @@ void ImDrawList::AddLineH(float min_x, float max_x, float y, ImU32 col, float th
20252025
top_y -= thickness;
20262026

20272027
const bool is_truncated = IM_IS_TRUNCATED4(min_x, max_x, top_y, thickness);
2028-
if (_FringeScaleIsInteger && is_truncated && (flags & ImDrawFlags_SquareCap) == 0)
2028+
if (_FringeScaleIsInteger && is_truncated && (flags & ImDrawFlags_CapSquare) == 0)
20292029
{
20302030
if (thickness < _FringeScale) IM_UNLIKELY
20312031
{
@@ -2071,7 +2071,7 @@ void ImDrawList::AddLineV(float x, float min_y, float max_y, ImU32 col, float th
20712071
left_x -= thickness;
20722072

20732073
const bool is_truncated = IM_IS_TRUNCATED4(left_x, min_y, max_y, thickness);
2074-
if (_FringeScaleIsInteger && is_truncated && (flags & ImDrawFlags_SquareCap) == 0)
2074+
if (_FringeScaleIsInteger && is_truncated && (flags & ImDrawFlags_CapSquare) == 0)
20752075
{
20762076
if (thickness < _FringeScale) IM_UNLIKELY
20772077
{
@@ -2352,7 +2352,7 @@ void ImDrawList::AddRect(const ImVec2& p_min, const ImVec2& p_max, ImU32 col, fl
23522352
PathRect(ImVec2(p_min.x + 0.50f, p_min.y + 0.50f), ImVec2(p_max.x - 0.50f, p_max.y - 0.50f), rounding, flags);
23532353
else
23542354
PathRect(ImVec2(p_min.x + 0.50f, p_min.y + 0.50f), ImVec2(p_max.x - 0.49f, p_max.y - 0.49f), rounding, flags); // Better looking lower-right corner and rounded non-AA shapes.
2355-
PathStroke(col, thickness, ImDrawFlags_Closed | ImDrawFlags_MiterOnly | ImDrawFlags_StrokeCenter | (flags & ~ImDrawFlags_StrokeMask_));
2355+
PathStroke(col, thickness, ImDrawFlags_Closed | ImDrawFlags_JoinMiter | ImDrawFlags_StrokeCenter | (flags & ~ImDrawFlags_StrokeMask_));
23562356
return;
23572357
}
23582358

@@ -2452,7 +2452,7 @@ void ImDrawList::AddRect(const ImVec2& p_min, const ImVec2& p_max, ImU32 col, fl
24522452
if (!has_rounding || (flags & ImDrawFlags_RoundCornersMask_) == ImDrawFlags_RoundCornersNone)
24532453
{
24542454
const ImVec2 points[4] = { outer_min, ImVec2(outer_max.x, outer_min.y), outer_max, ImVec2(outer_min.x, outer_max.y) };
2455-
_AddPolyline(points, 4, col, thickness, ImDrawFlags_Closed | ImDrawFlags_MiterOnly | ImDrawFlags_StrokeInside, half_min_dim);
2455+
_AddPolyline(points, 4, col, thickness, ImDrawFlags_Closed | ImDrawFlags_JoinMiter | ImDrawFlags_StrokeInside, half_min_dim);
24562456
_Path.Size = 0;
24572457
}
24582458
else
@@ -2474,7 +2474,7 @@ void ImDrawList::AddRect(const ImVec2& p_min, const ImVec2& p_max, ImU32 col, fl
24742474
PathArcToFast(ImVec2(outer_max.x - rounding_br, outer_max.y - rounding_br), rounding_br, 0, 3);
24752475
PathArcToFast(ImVec2(outer_min.x + rounding_bl, outer_max.y - rounding_bl), rounding_bl, 3, 6);
24762476

2477-
_AddPolyline(_Path.Data, _Path.Size, col, thickness, ImDrawFlags_Closed | ImDrawFlags_MiterOnly | ImDrawFlags_StrokeInside | (flags & ~ImDrawFlags_StrokeMask_), half_min_dim);
2477+
_AddPolyline(_Path.Data, _Path.Size, col, thickness, ImDrawFlags_Closed | ImDrawFlags_JoinMiter | ImDrawFlags_StrokeInside | (flags & ~ImDrawFlags_StrokeMask_), half_min_dim);
24782478
_Path.Size = 0;
24792479
}
24802480
}
@@ -2553,7 +2553,7 @@ void ImDrawList::AddRectFilled(const ImVec2& p_min, const ImVec2& p_max, ImU32 c
25532553
height = _FringeScale;
25542554
}
25552555
const ImVec2 points[4] = { p_min, ImVec2(p_min.x + width, p_min.y), ImVec2(p_min.x + width, p_min.y + height), ImVec2(p_min.x, p_min.y + height) };
2556-
AddConvexPolyFilled(points, 4, col, ImDrawFlags_MiterOnly);
2556+
AddConvexPolyFilled(points, 4, col, ImDrawFlags_JoinMiter);
25572557
return;
25582558
}
25592559

@@ -2605,12 +2605,12 @@ void ImDrawList::AddRectFilled(const ImVec2& p_min, const ImVec2& p_max, ImU32 c
26052605
if (!has_rounding)
26062606
{
26072607
const ImVec2 points[4] = { p_min, ImVec2(p_max.x, p_min.y), p_max, ImVec2(p_min.x, p_max.y) };
2608-
AddConvexPolyFilled(points, 4, col, ImDrawFlags_MiterOnly);
2608+
AddConvexPolyFilled(points, 4, col, ImDrawFlags_JoinMiter);
26092609
}
26102610
else
26112611
{
26122612
PathRect(p_min, p_max, rounding, flags);
2613-
PathFillConvex(col, ImDrawFlags_MiterOnly);
2613+
PathFillConvex(col, ImDrawFlags_JoinMiter);
26142614
}
26152615
}
26162616

@@ -2740,7 +2740,7 @@ void ImDrawList::AddCircle(const ImVec2& center, float radius, ImU32 col, int nu
27402740
// This will be used by _AddPolyline() to clamp the inner stroke expansion, to avoid creating rendering artifacts.
27412741
const float unit_apothem = ApproxApothem(_Path.Size);
27422742
const float edge_dist = radius * unit_apothem;
2743-
_AddPolyline(_Path.Data, _Path.Size, col, thickness, ImDrawFlags_Closed | ImDrawFlags_MiterOnly | stroke_pos, edge_dist);
2743+
_AddPolyline(_Path.Data, _Path.Size, col, thickness, ImDrawFlags_Closed | ImDrawFlags_JoinMiter | stroke_pos, edge_dist);
27442744
_Path.Size = 0;
27452745
}
27462746

@@ -2776,7 +2776,7 @@ void ImDrawList::AddCircleFilled(const ImVec2& center, float radius, ImU32 col,
27762776
PathArcTo(center, radius, 0.0f, a_max, num_segments - 1);
27772777
}
27782778

2779-
PathFillConvex(col, ImDrawFlags_MiterOnly);
2779+
PathFillConvex(col, ImDrawFlags_JoinMiter);
27802780
}
27812781

27822782
// Guaranteed to honor 'num_segments'
@@ -2822,7 +2822,7 @@ void ImDrawList::AddNgon(const ImVec2& center, float radius, ImU32 col, int num_
28222822
// Because we are filling a closed shape we remove 1 from the count of segments/points
28232823
const float a_max = (IM_PI * 2.0f) * ((float)num_segments - 1.0f) / (float)num_segments;
28242824
PathArcTo(center, radius, 0.0f, a_max, num_segments - 1);
2825-
_AddPolyline(_Path.Data, _Path.Size, col, thickness, ImDrawFlags_Closed | ImDrawFlags_MiterOnly | stroke_pos, edge_dist);
2825+
_AddPolyline(_Path.Data, _Path.Size, col, thickness, ImDrawFlags_Closed | ImDrawFlags_JoinMiter | stroke_pos, edge_dist);
28262826
_Path.Size = 0;
28272827
}
28282828

@@ -2844,7 +2844,7 @@ void ImDrawList::AddNgonFilled(const ImVec2& center, float radius, ImU32 col, in
28442844
// Because we are filling a closed shape we remove 1 from the count of segments/points
28452845
const float a_max = (IM_PI * 2.0f) * ((float)num_segments - 1.0f) / (float)num_segments;
28462846
PathArcTo(center, radius, 0.0f, a_max, num_segments - 1);
2847-
PathFillConvex(col, ImDrawFlags_MiterOnly);
2847+
PathFillConvex(col, ImDrawFlags_JoinMiter);
28482848
}
28492849

28502850
// Ellipse
@@ -2872,7 +2872,7 @@ void ImDrawList::AddEllipse(const ImVec2& center, const ImVec2& radius, ImU32 co
28722872

28732873
// Prevent the inside part of the stroke to be expanded too much to prevent some rendering artifacts.
28742874
const float max_inner_offset = ImMin(rad.x, rad.y);
2875-
_AddPolyline(_Path.Data, _Path.Size, col, thickness, ImDrawFlags_Closed | ImDrawFlags_MiterOnly | stroke_pos, max_inner_offset);
2875+
_AddPolyline(_Path.Data, _Path.Size, col, thickness, ImDrawFlags_Closed | ImDrawFlags_JoinMiter | stroke_pos, max_inner_offset);
28762876
_Path.Size = 0;
28772877
}
28782878

@@ -3019,7 +3019,7 @@ void ImDrawList::AddImageRounded(ImTextureRef tex_ref, const ImVec2& p_min, cons
30193019

30203020
int vert_start_idx = VtxBuffer.Size;
30213021
PathRect(p_min, p_max, rounding, flags);
3022-
PathFillConvex(col, ImDrawFlags_MiterOnly);
3022+
PathFillConvex(col, ImDrawFlags_JoinMiter);
30233023
int vert_end_idx = VtxBuffer.Size;
30243024
ImGui::ShadeVertsLinearUV(this, vert_start_idx, vert_end_idx, p_min, p_max, uv_min, uv_max, true);
30253025

@@ -7642,7 +7642,7 @@ void ImGui::RenderRectFilledInRangeH(ImDrawList* draw_list, const ImRect& rect,
76427642
draw_list->PathArcTo(ImVec2(x1, p1.y - rounding), rounding, +arc1_b, +arc1_e); // BR
76437643
}
76447644
}
7645-
draw_list->PathFillConvex(col, ImDrawFlags_MiterOnly);
7645+
draw_list->PathFillConvex(col, ImDrawFlags_JoinMiter);
76467646
}
76477647

76487648
void ImGui::RenderRectFilledWithHole(ImDrawList* draw_list, const ImRect& outer, const ImRect& inner, ImU32 col, float rounding)

0 commit comments

Comments
 (0)