mirror of
https://github.com/ocornut/imgui.git
synced 2026-01-11 00:04:24 +00:00
Fonts: reworked text ellipsis logic to ensure a "..." is always displayed instead of a single character. (#7024)
Requires97d85338e8ande4a865177e
This commit is contained in:
parent
97d85338e8
commit
69d572bb10
2 changed files with 2 additions and 6 deletions
|
|
@ -84,6 +84,8 @@ Other changes:
|
||||||
EndPopup() call. (#1651, #8499)
|
EndPopup() call. (#1651, #8499)
|
||||||
- Error Handling: added better error report and recovery when calling EndFrame()
|
- Error Handling: added better error report and recovery when calling EndFrame()
|
||||||
or Render() without NewFrame(). Was previously only an assert.
|
or Render() without NewFrame(). Was previously only an assert.
|
||||||
|
- Fonts: reworked text ellipsis logic to ensure a "..." is always displayed instead
|
||||||
|
of a single character. (#7024)
|
||||||
- Fonts: word-wrapping code handle ideographic comma & full stop (U+3001, U+3002). (#8540)
|
- Fonts: word-wrapping code handle ideographic comma & full stop (U+3001, U+3002). (#8540)
|
||||||
- Fonts: fixed CalcWordWrapPositionA() fallback when width is too small to wrap:
|
- Fonts: fixed CalcWordWrapPositionA() fallback when width is too small to wrap:
|
||||||
would use a +1 offset instead of advancing to the next UTF-8 codepoint. (#8540)
|
would use a +1 offset instead of advancing to the next UTF-8 codepoint. (#8540)
|
||||||
|
|
|
||||||
|
|
@ -3720,12 +3720,6 @@ 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
|
// 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);
|
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;
|
float text_size_clipped_x = font->CalcTextSizeA(font_size, text_avail_width, 0.0f, text, text_end_full, &text_end_ellipsis).x;
|
||||||
if (text == text_end_ellipsis && text_end_ellipsis < text_end_full)
|
|
||||||
{
|
|
||||||
// Always display at least 1 character if there's no room for character + ellipsis
|
|
||||||
text_end_ellipsis = text + ImTextCountUtf8BytesFromChar(text, text_end_full);
|
|
||||||
text_size_clipped_x = font->CalcTextSizeA(font_size, FLT_MAX, 0.0f, text, text_end_ellipsis).x;
|
|
||||||
}
|
|
||||||
while (text_end_ellipsis > text && ImCharIsBlankA(text_end_ellipsis[-1]))
|
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)
|
// 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)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue