MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / ShowExampleAppLongText

Function ShowExampleAppLongText

Source/3rdParty/imgui/imgui_demo.cpp:9724–9780  ·  view source on GitHub ↗

Demonstrate/test rendering huge amount of text, and the incidence of clipping.

Source from the content-addressed store, hash-verified

9722
9723// Demonstrate/test rendering huge amount of text, and the incidence of clipping.
9724static void ShowExampleAppLongText(bool* p_open)
9725{
9726 ImGui::SetNextWindowSize(ImVec2(520, 600), ImGuiCond_FirstUseEver);
9727 if (!ImGui::Begin("Example: Long text display", p_open))
9728 {
9729 ImGui::End();
9730 return;
9731 }
9732 IMGUI_DEMO_MARKER("Examples/Long text display");
9733
9734 static int test_type = 0;
9735 static ImGuiTextBuffer log;
9736 static int lines = 0;
9737 ImGui::Text("Printing unusually long amount of text.");
9738 ImGui::Combo("Test type", &test_type,
9739 "Single call to TextUnformatted()\0"
9740 "Multiple calls to Text(), clipped\0"
9741 "Multiple calls to Text(), not clipped (slow)\0");
9742 ImGui::Text("Buffer contents: %d lines, %d bytes", lines, log.size());
9743 if (ImGui::Button("Clear")) { log.clear(); lines = 0; }
9744 ImGui::SameLine();
9745 if (ImGui::Button("Add 1000 lines"))
9746 {
9747 for (int i = 0; i < 1000; i++)
9748 log.appendf("%i The quick brown fox jumps over the lazy dog\n", lines + i);
9749 lines += 1000;
9750 }
9751 ImGui::BeginChild("Log");
9752 switch (test_type)
9753 {
9754 case 0:
9755 // Single call to TextUnformatted() with a big buffer
9756 ImGui::TextUnformatted(log.begin(), log.end());
9757 break;
9758 case 1:
9759 {
9760 // Multiple calls to Text(), manually coarsely clipped - demonstrate how to use the ImGuiListClipper helper.
9761 ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0));
9762 ImGuiListClipper clipper;
9763 clipper.Begin(lines);
9764 while (clipper.Step())
9765 for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++)
9766 ImGui::Text("%i The quick brown fox jumps over the lazy dog", i);
9767 ImGui::PopStyleVar();
9768 break;
9769 }
9770 case 2:
9771 // Multiple calls to Text(), not clipped (slow)
9772 ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0));
9773 for (int i = 0; i < lines; i++)
9774 ImGui::Text("%i The quick brown fox jumps over the lazy dog", i);
9775 ImGui::PopStyleVar();
9776 break;
9777 }
9778 ImGui::EndChild();
9779 ImGui::End();
9780}
9781

Callers 1

ShowDemoWindowMethod · 0.85

Calls 15

SetNextWindowSizeFunction · 0.85
ImVec2Function · 0.85
EndFunction · 0.85
ComboFunction · 0.85
BeginChildFunction · 0.85
PopStyleVarFunction · 0.85
appendfMethod · 0.80
clearMethod · 0.65
BeginFunction · 0.50
TextFunction · 0.50
ButtonFunction · 0.50
PushStyleVarFunction · 0.50

Tested by

no test coverage detected