1
0
mirror of https://github.com/ocornut/imgui.git synced 2024-12-01 02:37:24 +01:00

Demo: Log: removed broken clipping, tweaks.

This commit is contained in:
ocornut 2015-08-13 22:04:31 -06:00
parent 07de0448f9
commit 67b2b5f3a9

View File

@ -1982,26 +1982,19 @@ struct ExampleAppLog
Filter.Draw("Filter", -100.0f); Filter.Draw("Filter", -100.0f);
ImGui::Separator(); ImGui::Separator();
ImGui::BeginChild("scrolling"); ImGui::BeginChild("scrolling");
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0,0)); ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0,1));
if (copy) ImGui::LogToClipboard(); if (copy) ImGui::LogToClipboard();
// We provide coarse vertical clipping of the filtered result to make it a little faster.
if (Filter.IsActive()) if (Filter.IsActive())
{ {
int display_start = 0, display_end = 0, displayed_count = 0;
ImGui::CalcListClipping(INT_MAX, ImGui::GetTextLineHeight(), &display_start, &display_end);
const char* buf_begin = Buf.begin(); const char* buf_begin = Buf.begin();
const char* line = buf_begin; const char* line = buf_begin;
for (int line_no = 0; line != NULL; line_no++) for (int line_no = 0; line != NULL; line_no++)
{ {
const char* line_end = (line_no < LineOffsets.Size) ? buf_begin + LineOffsets[line_no] : NULL; const char* line_end = (line_no < LineOffsets.Size) ? buf_begin + LineOffsets[line_no] : NULL;
if (Filter.PassFilter(line, line_end)) if (Filter.PassFilter(line, line_end))
{ ImGui::TextUnformatted(line, line_end);
if (displayed_count >= display_start && displayed_count < display_end) line = line_end && line_end[1] ? line_end + 1 : NULL;
ImGui::TextUnformatted(line, line_end);
displayed_count++;
}
line = line_end ? (line_end + 1) : NULL;
} }
} }
else else