|
|
@ -1401,6 +1401,7 @@ void ImDrawList::AddLine(const ImVec2& p1, const ImVec2& p2, ImU32 col, float th |
|
|
|
// flags should contains a mask indicating which corners should be drawn rounded
|
|
|
|
// flags should contains a mask indicating which corners should be drawn rounded
|
|
|
|
// Returns true if the rectangle was drawn, false for some reason it couldn't
|
|
|
|
// Returns true if the rectangle was drawn, false for some reason it couldn't
|
|
|
|
// be (in which case the caller should try again with the regular path drawing API)
|
|
|
|
// be (in which case the caller should try again with the regular path drawing API)
|
|
|
|
|
|
|
|
// We are using the textures generated by ImFontAtlasBuildRenderRoundCornersTexData()
|
|
|
|
inline bool AddRoundCornerRect(ImDrawList* draw_list, const ImVec2& a, const ImVec2& b, ImU32 col, float rounding, ImDrawFlags flags, bool fill) |
|
|
|
inline bool AddRoundCornerRect(ImDrawList* draw_list, const ImVec2& a, const ImVec2& b, ImU32 col, float rounding, ImDrawFlags flags, bool fill) |
|
|
|
{ |
|
|
|
{ |
|
|
|
#if 1 |
|
|
|
#if 1 |
|
|
@ -1676,13 +1677,8 @@ void ImDrawList::AddRect(const ImVec2& p_min, const ImVec2& p_max, ImU32 col, fl |
|
|
|
|
|
|
|
|
|
|
|
// Try to use fast path if we can
|
|
|
|
// Try to use fast path if we can
|
|
|
|
if (rounding > 0) |
|
|
|
if (rounding > 0) |
|
|
|
{ |
|
|
|
|
|
|
|
if (AddRoundCornerRect(this, p_min, p_max, col, rounding, flags, /* fill */ false)) |
|
|
|
if (AddRoundCornerRect(this, p_min, p_max, col, rounding, flags, /* fill */ false)) |
|
|
|
{ |
|
|
|
|
|
|
|
// Fast path handled this
|
|
|
|
|
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (Flags & ImDrawListFlags_AntiAliasedLines) |
|
|
|
if (Flags & ImDrawListFlags_AntiAliasedLines) |
|
|
|
PathRect(p_min + ImVec2(0.50f, 0.50f), p_max - ImVec2(0.50f, 0.50f), rounding, flags); |
|
|
|
PathRect(p_min + ImVec2(0.50f, 0.50f), p_max - ImVec2(0.50f, 0.50f), rounding, flags); |
|
|
@ -1711,14 +1707,10 @@ void ImDrawList::AddRectFilled(const ImVec2& p_min, const ImVec2& p_max, ImU32 c |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Try fast path first
|
|
|
|
// Try fast path first
|
|
|
|
if (AddRoundCornerRect(this, p_min, p_max, col, rounding, flags, /* fill */ true)) |
|
|
|
if (AddRoundCornerRect(this, p_min, p_max, col, rounding, flags, /* fill */ true)) |
|
|
|
{ |
|
|
|
|
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
PathRect(p_min, p_max, rounding, flags); |
|
|
|
{ |
|
|
|
PathFillConvex(col); |
|
|
|
PathRect(p_min, p_max, rounding, flags); |
|
|
|
|
|
|
|
PathFillConvex(col); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1794,8 +1786,7 @@ inline bool AddRoundCornerCircle(ImDrawList* draw_list, const ImVec2& center, fl |
|
|
|
IM_ASSERT(tex_id == draw_list->_TextureIdStack.back()); // Use high-level ImGui::PushFont() or low-level ImDrawList::PushTextureId() to change font.
|
|
|
|
IM_ASSERT(tex_id == draw_list->_TextureIdStack.back()); // Use high-level ImGui::PushFont() or low-level ImDrawList::PushTextureId() to change font.
|
|
|
|
|
|
|
|
|
|
|
|
const int rad = (int)radius; |
|
|
|
const int rad = (int)radius; |
|
|
|
if ((rad < 1) || // Radius 0 will cause issues with the UV lookup below
|
|
|
|
if (rad < 1 || rad > data->Font->ContainerAtlas->RoundCornersMaxSize) // Radius 0 will cause issues with the UV lookup below
|
|
|
|
(rad > data->Font->ContainerAtlas->RoundCornersMaxSize)) |
|
|
|
|
|
|
|
return false; // We can't handle this
|
|
|
|
return false; // We can't handle this
|
|
|
|
|
|
|
|
|
|
|
|
// Debug command to force this render path to only execute when shift is held
|
|
|
|
// Debug command to force this render path to only execute when shift is held
|
|
|
@ -1827,7 +1818,6 @@ inline bool AddRoundCornerCircle(ImDrawList* draw_list, const ImVec2& center, fl |
|
|
|
|
|
|
|
|
|
|
|
// Some useful constants for our calculations
|
|
|
|
// Some useful constants for our calculations
|
|
|
|
const float half_sqrt_two = 0.70710678f; // sqrtf(2.0f) * 0.5f
|
|
|
|
const float half_sqrt_two = 0.70710678f; // sqrtf(2.0f) * 0.5f
|
|
|
|
const float sqrt_two_minus_one = 0.41421356f; // sqrt(2.0f) - 1.0f
|
|
|
|
|
|
|
|
const float width_offset_parametric = line_width / rad; // Line width in our parametric coordinate space
|
|
|
|
const float width_offset_parametric = line_width / rad; // Line width in our parametric coordinate space
|
|
|
|
|
|
|
|
|
|
|
|
const int num_verts = fill ? 9 : 16; // Number of vertices we are going to write
|
|
|
|
const int num_verts = fill ? 9 : 16; // Number of vertices we are going to write
|
|
|
@ -3710,7 +3700,11 @@ static void ImFontAtlasBuildRegisterRoundCornersCustomRects(ImFontAtlas* atlas) |
|
|
|
const int pad = FONT_ATLAS_ROUNDED_CORNER_TEX_PADDING; |
|
|
|
const int pad = FONT_ATLAS_ROUNDED_CORNER_TEX_PADDING; |
|
|
|
const int max = atlas->RoundCornersMaxSize; |
|
|
|
const int max = atlas->RoundCornersMaxSize; |
|
|
|
for (int n = 0; n < max; n++) |
|
|
|
for (int n = 0; n < max; n++) |
|
|
|
atlas->RoundCornersRectIds.push_back(atlas->AddCustomRectRegular(n + 1 + pad * 2, n + 1 + FONT_ATLAS_ROUNDED_CORNER_TEX_CENTER_PADDING + pad * 2)); |
|
|
|
{ |
|
|
|
|
|
|
|
const int width = n + 1 + pad * 2; |
|
|
|
|
|
|
|
const int height = n + 1 + FONT_ATLAS_ROUNDED_CORNER_TEX_CENTER_PADDING + pad * 2; |
|
|
|
|
|
|
|
atlas->RoundCornersRectIds.push_back(atlas->AddCustomRectRegular(width, height)); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Generate the actual pixel data for rounded corners in the atlas
|
|
|
|
// Generate the actual pixel data for rounded corners in the atlas
|
|
|
@ -3763,7 +3757,6 @@ static void ImFontAtlasBuildRenderRoundCornersTexData(ImFontAtlas* atlas) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const float dist = ImSqrt((float)(cx*cx+cy*cy)) - (float)(radius - (filled ? 0 : stroke_width)); |
|
|
|
const float dist = ImSqrt((float)(cx*cx+cy*cy)) - (float)(radius - (filled ? 0 : stroke_width)); |
|
|
|
|
|
|
|
|
|
|
|
float alpha = 0.0f; |
|
|
|
float alpha = 0.0f; |
|
|
|
if (filled) |
|
|
|
if (filled) |
|
|
|
{ |
|
|
|
{ |
|
|
|