From aa35547f949d759f5b2e7207ec1a10b36dac6092 Mon Sep 17 00:00:00 2001 From: ocornut Date: Sun, 30 Aug 2015 00:03:08 +0100 Subject: [PATCH] Demo: long text example uses ImGuiListClipper --- imgui_demo.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/imgui_demo.cpp b/imgui_demo.cpp index 94db0a66c..d8a54bfff 100644 --- a/imgui_demo.cpp +++ b/imgui_demo.cpp @@ -2110,16 +2110,16 @@ static void ShowExampleAppLongText(bool* opened) ImGui::TextUnformatted(log.begin(), log.end()); break; case 1: - // Multiple calls to Text(), manually coarsely clipped - demonstrate how to use the CalcListClipping() helper. - ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0,0)); - int display_start, display_end; - ImGui::CalcListClipping(lines, ImGui::GetTextLineHeight(), &display_start, &display_end); - ImGui::SetCursorPosY(ImGui::GetCursorPosY() + (display_start) * ImGui::GetTextLineHeight()); - for (int i = display_start; i < display_end; i++) - ImGui::Text("%i The quick brown fox jumps over the lazy dog\n", i); - ImGui::SetCursorPosY(ImGui::GetCursorPosY() + (lines - display_end) * ImGui::GetTextLineHeight()); - ImGui::PopStyleVar(); - break; + { + // Multiple calls to Text(), manually coarsely clipped - demonstrate how to use the ImGuiListClipper helper. + ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0,0)); + ImGuiListClipper clipper(lines, ImGui::GetTextLineHeight()); + for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) + ImGui::Text("%i The quick brown fox jumps over the lazy dog\n", i); + clipper.End(); + ImGui::PopStyleVar(); + break; + } case 2: // Multiple calls to Text(), not clipped (slow) ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0,0));