mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-23 21:09:01 +08:00
ImDrawList: Fixed clipping of leading lines above the clipping rectangle from counting in the worst case vertices reservation. (fix code added in #200!)
This commit is contained in:
parent
2dc5ec95d7
commit
975b5a7310
@ -73,6 +73,7 @@ Other Changes:
|
||||
- Fixed PushID() from keeping alive the new ID Stack top value (if a previously active widget shared the ID it would be erroneously kept alive).
|
||||
- Fixed horizontal mouse wheel not forwarding the request to the parent window if ImGuiWindowFlags_NoScrollWithMouse is set. (#1463, #1380, #1502)
|
||||
- Fixed a include build issue for Cygwin in non-POSIX (Win32) mode. (#1917, #1319, #276)
|
||||
- ImDrawList: Fixed clipping of leading lines above the clipping rectangle from counting in the worst-case vertices reservation. (fix code added in #200!)
|
||||
- OS/Windows: Fixed missing ImmReleaseContext() call in the default Win32 IME handler. (#1932) [@vby]
|
||||
- Metrics: Changed io.MetricsActiveWindows to reflect the number of active windows (!= from visible windows), which is useful
|
||||
for lazy/idle render mechanisms as new windows are typically not visible for one frame.
|
||||
|
@ -2632,11 +2632,16 @@ void ImFont::RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col
|
||||
const bool word_wrap_enabled = (wrap_width > 0.0f);
|
||||
const char* word_wrap_eol = NULL;
|
||||
|
||||
// Skip non-visible lines
|
||||
// Fast-forward to first visible line
|
||||
const char* s = text_begin;
|
||||
if (!word_wrap_enabled && y + line_height < clip_rect.y)
|
||||
while (s < text_end && *s != '\n') // Fast-forward to next line
|
||||
s++;
|
||||
while (y + line_height < clip_rect.y)
|
||||
{
|
||||
while (s < text_end)
|
||||
if (*s++ == '\n')
|
||||
break;
|
||||
y += line_height;
|
||||
}
|
||||
|
||||
// Reserve vertices for remaining worse case (over-reserving is useful and easily amortized)
|
||||
const int vtx_count_max = (int)(text_end - s) * 4;
|
||||
@ -2695,12 +2700,8 @@ void ImFont::RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col
|
||||
{
|
||||
x = pos.x;
|
||||
y += line_height;
|
||||
|
||||
if (y > clip_rect.w)
|
||||
break;
|
||||
if (!word_wrap_enabled && y + line_height < clip_rect.y)
|
||||
while (s < text_end && *s != '\n') // Fast-forward to next line
|
||||
s++;
|
||||
break; // break out of main loop
|
||||
continue;
|
||||
}
|
||||
if (c == '\r')
|
||||
|
Loading…
Reference in New Issue
Block a user