mirror of
https://github.com/ocornut/imgui.git
synced 2026-02-13 23:33:26 +00:00
Changed RenderTextEllipsis() logic to not trim trailing blanks before the ellipsis. (#9229)
This commit is contained in:
@@ -171,6 +171,9 @@ Other Changes:
|
||||
end of a line rather than at the beginning of next line. (#8990, #3237)
|
||||
- Fixed low-level word-wrapping function reading from *text_end when passed
|
||||
a string range. (#9107) [@achabense]
|
||||
- Changed RenderTextEllipsis() logic to not trim trailing blanks before
|
||||
the ellipsis, making ellipsis position more consistent and not arbitrary
|
||||
hiding the possibility of multiple blanks. (#9229)
|
||||
- Nav:
|
||||
- Fixed remote/shortcut InputText() not teleporting mouse cursor when
|
||||
nav cursor is visible and `io.ConfigNavMoveSetMousePos` is enabled.
|
||||
|
||||
@@ -3905,13 +3905,7 @@ void ImGui::RenderTextEllipsis(ImDrawList* draw_list, const ImVec2& pos_min, con
|
||||
|
||||
// We can now claim the space between pos_max.x and ellipsis_max.x
|
||||
const float text_avail_width = ImMax((ImMax(pos_max.x, ellipsis_max_x) - ellipsis_width) - pos_min.x, 1.0f);
|
||||
float text_size_clipped_x = font->CalcTextSizeA(font_size, text_avail_width, 0.0f, text, text_end_full, &text_end_ellipsis).x;
|
||||
while (text_end_ellipsis > text && ImCharIsBlankA(text_end_ellipsis[-1]))
|
||||
{
|
||||
// Trim trailing space before ellipsis (FIXME: Supporting non-ascii blanks would be nice, for this we need a function to backtrack in UTF-8 text)
|
||||
text_end_ellipsis--;
|
||||
text_size_clipped_x -= font->CalcTextSizeA(font_size, FLT_MAX, 0.0f, text_end_ellipsis, text_end_ellipsis + 1).x; // Ascii blanks are always 1 byte
|
||||
}
|
||||
const float text_size_clipped_x = font->CalcTextSizeA(font_size, text_avail_width, 0.0f, text, text_end_full, &text_end_ellipsis).x;
|
||||
|
||||
// Render text, render ellipsis
|
||||
RenderTextClippedEx(draw_list, pos_min, pos_max, text, text_end_ellipsis, &text_size, ImVec2(0.0f, 0.0f));
|
||||
|
||||
Reference in New Issue
Block a user