|
|
|
@ -7,8 +7,8 @@
|
|
|
|
|
// ANTI-ALIASED PRIMITIVES BRANCH
|
|
|
|
|
// TODO
|
|
|
|
|
// - settle on where to the 0.5f offset for lines
|
|
|
|
|
// - checkbox, slider grabs are not centered properly if you enable border (relate to point above)
|
|
|
|
|
// - thick lines? recently been added to the ImDrawList API as a convenience.
|
|
|
|
|
// - check-box, slider grabs are not centered properly if you enable border (relate to point above)
|
|
|
|
|
// - support for thickness stroking. recently been added to the ImDrawList API as a convenience.
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
|
@ -398,6 +398,7 @@
|
|
|
|
|
#include <new> // new (ptr)
|
|
|
|
|
|
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
|
#pragma warning (disable: 4127) // conditional expression is constant
|
|
|
|
|
#pragma warning (disable: 4505) // unreferenced local function has been removed (stb stuff)
|
|
|
|
|
#pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen
|
|
|
|
|
#endif
|
|
|
|
@ -7723,18 +7724,14 @@ void ImDrawList::PrimRectUV(const ImVec2& a, const ImVec2& c, const ImVec2& uv_a
|
|
|
|
|
|
|
|
|
|
static ImVector<ImVec2> GTempPolyData;
|
|
|
|
|
|
|
|
|
|
void ImDrawList::AddPolyline(const ImVec2* points, const int points_count, ImU32 col, bool closed)
|
|
|
|
|
void ImDrawList::AddPolyline(const ImVec2* points, const int points_count, ImU32 col, float thickness, bool closed)
|
|
|
|
|
{
|
|
|
|
|
(void)thickness; // Unsupported
|
|
|
|
|
|
|
|
|
|
if (points_count < 2)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
const float aa_size = 1.0f;
|
|
|
|
|
|
|
|
|
|
// Temporary buffer
|
|
|
|
|
GTempPolyData.resize(points_count * 3);
|
|
|
|
|
ImVec2* temp_inner = >empPolyData[0];
|
|
|
|
|
ImVec2* temp_outer = >empPolyData[points_count];
|
|
|
|
|
ImVec2* temp_normals = >empPolyData[points_count * 2];
|
|
|
|
|
const ImVec2 uv = GImGui->FontTexUvWhitePixel;
|
|
|
|
|
|
|
|
|
|
int start = 0, count = points_count;
|
|
|
|
|
if (!closed)
|
|
|
|
@ -7743,6 +7740,18 @@ void ImDrawList::AddPolyline(const ImVec2* points, const int points_count, ImU32
|
|
|
|
|
count = points_count-1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const bool aa_enabled = true;//!ImGui::GetIO().KeyCtrl;
|
|
|
|
|
if (aa_enabled)
|
|
|
|
|
{
|
|
|
|
|
// Anti-aliased stroke
|
|
|
|
|
const float aa_size = 1.0f;
|
|
|
|
|
|
|
|
|
|
// Temporary buffer
|
|
|
|
|
GTempPolyData.resize(points_count * 3);
|
|
|
|
|
ImVec2* temp_inner = >empPolyData[0];
|
|
|
|
|
ImVec2* temp_outer = >empPolyData[points_count];
|
|
|
|
|
ImVec2* temp_normals = >empPolyData[points_count * 2];
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < count; i++)
|
|
|
|
|
{
|
|
|
|
|
const int ni = (i+1) < points_count ? i+1 : 0;
|
|
|
|
@ -7784,8 +7793,6 @@ void ImDrawList::AddPolyline(const ImVec2* points, const int points_count, ImU32
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const ImU32 col_trans = col & 0x00ffffff;
|
|
|
|
|
const ImVec2 uv = GImGui->FontTexUvWhitePixel;
|
|
|
|
|
|
|
|
|
|
const int vertex_count = count*12;
|
|
|
|
|
PrimReserve(vertex_count);
|
|
|
|
|
|
|
|
|
@ -7809,10 +7816,53 @@ void ImDrawList::AddPolyline(const ImVec2* points, const int points_count, ImU32
|
|
|
|
|
PrimVtx(points[ni], uv, col);
|
|
|
|
|
PrimVtx(temp_inner[ni], uv, col_trans);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Non Anti-aliased Stroke
|
|
|
|
|
const int vertex_count = count*6;
|
|
|
|
|
PrimReserve(vertex_count);
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < count; i++)
|
|
|
|
|
{
|
|
|
|
|
const int ni = (i+1) < points_count ? i+1 : 0;
|
|
|
|
|
const ImVec2& v0 = points[i];
|
|
|
|
|
const ImVec2& v1 = points[ni];
|
|
|
|
|
ImVec2 diff = v1 - v0;
|
|
|
|
|
float d = ImLengthSqr(diff);
|
|
|
|
|
if (d > 0)
|
|
|
|
|
diff *= 1.0f / sqrtf(d);
|
|
|
|
|
|
|
|
|
|
ImVec2 hn;
|
|
|
|
|
hn.x = diff.y * 0.5f;
|
|
|
|
|
hn.y = -diff.x * 0.5f;
|
|
|
|
|
|
|
|
|
|
PrimVtx(v0 - hn, uv, col);
|
|
|
|
|
PrimVtx(v0 + hn, uv, col);
|
|
|
|
|
PrimVtx(v1 + hn, uv, col);
|
|
|
|
|
PrimVtx(v0 - hn, uv, col);
|
|
|
|
|
PrimVtx(v1 + hn, uv, col);
|
|
|
|
|
PrimVtx(v1 - hn, uv, col);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
const float inv_length = 1.0f / sqrtf(ImLengthSqr(b - a));
|
|
|
|
|
const float aa_size = 1.0f;
|
|
|
|
|
const ImVec2 hn = (b - a) * (thickness * 0.5f * inv_length);// half normalized
|
|
|
|
|
const ImVec2 hp0 = ImVec2(+hn.y, -hn.x); // half perpendiculars + user offset
|
|
|
|
|
const ImVec2 hp1 = ImVec2(-hn.y, +hn.x);
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ImDrawList::AddConvexPolyFilled(const ImVec2* points, const int points_count, ImU32 col)
|
|
|
|
|
{
|
|
|
|
|
const ImVec2 uv = GImGui->FontTexUvWhitePixel;
|
|
|
|
|
|
|
|
|
|
const bool aa_enabled = true;//!ImGui::GetIO().KeyCtrl;
|
|
|
|
|
if (aa_enabled)
|
|
|
|
|
{
|
|
|
|
|
// Anti-aliased Fill
|
|
|
|
|
const float aa_size = 1.0f;
|
|
|
|
|
|
|
|
|
|
// Temporary buffer
|
|
|
|
@ -7850,9 +7900,7 @@ void ImDrawList::AddConvexPolyFilled(const ImVec2* points, const int points_coun
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const ImU32 col_trans = col & 0x00ffffff;
|
|
|
|
|
const ImVec2 uv = GImGui->FontTexUvWhitePixel;
|
|
|
|
|
|
|
|
|
|
int vertex_count = (points_count-2)*3 + points_count*6;
|
|
|
|
|
const int vertex_count = (points_count-2)*3 + points_count*6;
|
|
|
|
|
PrimReserve(vertex_count);
|
|
|
|
|
|
|
|
|
|
// Fill
|
|
|
|
@ -7874,6 +7922,19 @@ void ImDrawList::AddConvexPolyFilled(const ImVec2* points, const int points_coun
|
|
|
|
|
PrimVtx(temp_outer[i], uv, col_trans);
|
|
|
|
|
PrimVtx(temp_inner[i], uv, col);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Non Anti-aliased Fill
|
|
|
|
|
const int vertex_count = (points_count-2)*3;
|
|
|
|
|
PrimReserve(vertex_count);
|
|
|
|
|
for (int i = 2; i < points_count; i++)
|
|
|
|
|
{
|
|
|
|
|
PrimVtx(points[0], uv, col);
|
|
|
|
|
PrimVtx(points[i-1], uv, col);
|
|
|
|
|
PrimVtx(points[i], uv, col);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ImDrawList::ClearPath()
|
|
|
|
@ -7936,10 +7997,10 @@ void ImDrawList::Fill(ImU32 col)
|
|
|
|
|
ClearPath();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ImDrawList::Stroke(ImU32 col, bool closed)
|
|
|
|
|
void ImDrawList::Stroke(ImU32 col, float thickness, bool closed)
|
|
|
|
|
{
|
|
|
|
|
// Remove duplicates
|
|
|
|
|
AddPolyline(&path[0], (int)path.size(), col, closed);
|
|
|
|
|
AddPolyline(&path[0], (int)path.size(), col, thickness, closed);
|
|
|
|
|
ClearPath();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|