AA branch: ImDrawList: renaming of Path based functions so both code paths can cohabit with no confusion

This commit is contained in:
ocornut 2015-06-29 19:25:41 -06:00
parent 5bf30bd6c4
commit d57ee2458c
2 changed files with 32 additions and 32 deletions

View File

@ -3951,9 +3951,9 @@ bool ImGui::Begin(const char* name, bool* p_opened, const ImVec2& size_on_first_
const float min_size = window_rounding + 1.0f + g.FontSize * 0.2f;
const float corner_size = ImMax(base_size, min_size);
const ImVec2 br = window->Rect().GetBR();
window->DrawList->LineTo(br + ImVec2(-corner_size, 0.0f));
window->DrawList->LineTo(br + ImVec2(0.0f, -corner_size));
window->DrawList->ArcToFast(ImVec2(br.x - window_rounding, br.y - window_rounding), window_rounding, 6, 9);
window->DrawList->PathLineTo(br + ImVec2(-corner_size, 0.0f));
window->DrawList->PathLineTo(br + ImVec2(0.0f, -corner_size));
window->DrawList->PathArcToFast(ImVec2(br.x - window_rounding, br.y - window_rounding), window_rounding, 6, 9);
window->DrawList->Fill(resize_col);
}
}
@ -9165,17 +9165,17 @@ void ImDrawList::AddConvexPolyFilled(const ImVec2* points, const int points_coun
}
}
void ImDrawList::ClearPath()
void ImDrawList::PathClear()
{
path.resize(0);
}
void ImDrawList::LineTo(const ImVec2& p)
void ImDrawList::PathLineTo(const ImVec2& p)
{
path.push_back(p);
}
void ImDrawList::ArcToFast(const ImVec2& centre, float radius, int amin, int amax)
void ImDrawList::PathArcToFast(const ImVec2& centre, float radius, int amin, int amax)
{
static ImVec2 circle_vtx[12];
static bool circle_vtx_builds = false;
@ -9205,7 +9205,7 @@ void ImDrawList::ArcToFast(const ImVec2& centre, float radius, int amin, int ama
}
}
void ImDrawList::ArcTo(const ImVec2& centre, float radius, float amin, float amax, int num_segments)
void ImDrawList::PathArcTo(const ImVec2& centre, float radius, float amin, float amax, int num_segments)
{
if (radius == 0.0f)
{
@ -9222,17 +9222,17 @@ void ImDrawList::ArcTo(const ImVec2& centre, float radius, float amin, float ama
void ImDrawList::Fill(ImU32 col)
{
AddConvexPolyFilled(&path[0], (int)path.size(), col);
ClearPath();
PathClear();
}
void ImDrawList::Stroke(ImU32 col, float thickness, bool closed)
{
// Remove duplicates
AddPolyline(&path[0], (int)path.size(), col, thickness, closed);
ClearPath();
PathClear();
}
void ImDrawList::Rect(const ImVec2& a, const ImVec2& b, float rounding, int rounding_corners)
void ImDrawList::PathRect(const ImVec2& a, const ImVec2& b, float rounding, int rounding_corners)
{
float r = rounding;
r = ImMin(r, fabsf(b.x-a.x) * ( ((rounding_corners&(1|2))==(1|2)) || ((rounding_corners&(4|8))==(4|8)) ? 0.5f : 1.0f ) - 1.0f);
@ -9240,10 +9240,10 @@ void ImDrawList::Rect(const ImVec2& a, const ImVec2& b, float rounding, int roun
if (r == 0.0f || rounding_corners == 0)
{
LineTo(a);
LineTo(ImVec2(b.x,a.y));
LineTo(b);
LineTo(ImVec2(a.x,b.y));
PathLineTo(a);
PathLineTo(ImVec2(b.x,a.y));
PathLineTo(b);
PathLineTo(ImVec2(a.x,b.y));
}
else
{
@ -9251,10 +9251,10 @@ void ImDrawList::Rect(const ImVec2& a, const ImVec2& b, float rounding, int roun
const float r1 = (rounding_corners & 2) ? r : 0.0f;
const float r2 = (rounding_corners & 4) ? r : 0.0f;
const float r3 = (rounding_corners & 8) ? r : 0.0f;
ArcToFast(ImVec2(a.x+r0,a.y+r0), r0, 0, 3);
ArcToFast(ImVec2(b.x-r1,a.y+r1), r1, 3, 6);
ArcToFast(ImVec2(b.x-r2,b.y-r2), r2, 6, 9);
ArcToFast(ImVec2(a.x+r3,b.y-r3), r3, 9, 12);
PathArcToFast(ImVec2(a.x+r0,a.y+r0), r0, 0, 3);
PathArcToFast(ImVec2(b.x-r1,a.y+r1), r1, 3, 6);
PathArcToFast(ImVec2(b.x-r2,b.y-r2), r2, 6, 9);
PathArcToFast(ImVec2(a.x+r3,b.y-r3), r3, 9, 12);
}
}
@ -9262,8 +9262,8 @@ void ImDrawList::AddLine(const ImVec2& a, const ImVec2& b, ImU32 col, float thic
{
if ((col >> 24) == 0)
return;
LineTo(a);
LineTo(b);
PathLineTo(a);
PathLineTo(b);
Stroke(col, thickness, false);
}
@ -9271,7 +9271,7 @@ void ImDrawList::AddRect(const ImVec2& a, const ImVec2& b, ImU32 col, float roun
{
if ((col >> 24) == 0)
return;
Rect(a + ImVec2(0.5f,0.5f), b + ImVec2(0.5f,0.5f), rounding, rounding_corners);
PathRect(a + ImVec2(0.5f,0.5f), b + ImVec2(0.5f,0.5f), rounding, rounding_corners);
Stroke(col, 1.0f, true);
}
@ -9279,7 +9279,7 @@ void ImDrawList::AddRectFilled(const ImVec2& a, const ImVec2& b, ImU32 col, floa
{
if ((col >> 24) == 0)
return;
Rect(a, b, rounding, rounding_corners);
PathRect(a, b, rounding, rounding_corners);
Fill(col);
}
@ -9287,9 +9287,9 @@ void ImDrawList::AddTriangleFilled(const ImVec2& a, const ImVec2& b, const ImVec
{
if ((col >> 24) == 0)
return;
LineTo(a);
LineTo(b);
LineTo(c);
PathLineTo(a);
PathLineTo(b);
PathLineTo(c);
Fill(col);
}
@ -9299,7 +9299,7 @@ void ImDrawList::AddCircle(const ImVec2& centre, float radius, ImU32 col, int nu
return;
const float a_max = IM_PI*2.0f * ((float)num_segments - 1.0f) / (float)num_segments;
ArcTo(centre, radius, 0.0f, a_max, num_segments);
PathArcTo(centre, radius, 0.0f, a_max, num_segments);
Stroke(col, 1.0f, true);
}
@ -9309,7 +9309,7 @@ void ImDrawList::AddCircleFilled(const ImVec2& centre, float radius, ImU32 col,
return;
const float a_max = IM_PI*2.0f * ((float)num_segments - 1.0f) / (float)num_segments;
ArcTo(centre, radius, 0.0f, a_max, num_segments);
PathArcTo(centre, radius, 0.0f, a_max, num_segments);
Fill(col);
}

10
imgui.h
View File

@ -1030,11 +1030,11 @@ struct ImDrawList
IMGUI_API void PopTextureID();
// Stateful path API (finish with Fill or Stroke)
IMGUI_API void ClearPath();
IMGUI_API void LineTo(const ImVec2& p);
IMGUI_API void ArcToFast(const ImVec2& centre, float radius, int a_min, int a_max);
IMGUI_API void ArcTo(const ImVec2& centre, float radius, float a_min, float a_max, int num_segments = 12);
IMGUI_API void Rect(const ImVec2& a, const ImVec2& b, float rounding = 0.0f, int rounding_corners = 0x0F);
IMGUI_API void PathClear();
IMGUI_API void PathLineTo(const ImVec2& p);
IMGUI_API void PathArcToFast(const ImVec2& centre, float radius, int a_min, int a_max);
IMGUI_API void PathArcTo(const ImVec2& centre, float radius, float a_min, float a_max, int num_segments = 12);
IMGUI_API void PathRect(const ImVec2& a, const ImVec2& b, float rounding = 0.0f, int rounding_corners = 0x0F);
IMGUI_API void Fill(ImU32 col);
IMGUI_API void Stroke(ImU32 col, float thickness, bool closed);