MCPcopy Create free account
hub / github.com/clementgallet/libTAS / ShowExampleAppLongText

Function ShowExampleAppLongText

src/external/imgui/imgui_demo.cpp:7587–7643  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

7585
7586// Demonstrate/test rendering huge amount of text, and the incidence of clipping.
7587static void ShowExampleAppLongText(bool* p_open)
7588{
7589 ImGui::SetNextWindowSize(ImVec2(520, 600), ImGuiCond_FirstUseEver);
7590 if (!ImGui::Begin("Example: Long text display", p_open))
7591 {
7592 ImGui::End();
7593 return;
7594 }
7595 IMGUI_DEMO_MARKER("Examples/Long text display");
7596
7597 static int test_type = 0;
7598 static ImGuiTextBuffer log;
7599 static int lines = 0;
7600 ImGui::Text("Printing unusually long amount of text.");
7601 ImGui::Combo("Test type", &test_type,
7602 "Single call to TextUnformatted()\0"
7603 "Multiple calls to Text(), clipped\0"
7604 "Multiple calls to Text(), not clipped (slow)\0");
7605 ImGui::Text("Buffer contents: %d lines, %d bytes", lines, log.size());
7606 if (ImGui::Button("Clear")) { log.clear(); lines = 0; }
7607 ImGui::SameLine();
7608 if (ImGui::Button("Add 1000 lines"))
7609 {
7610 for (int i = 0; i < 1000; i++)
7611 log.appendf("%i The quick brown fox jumps over the lazy dog\n", lines + i);
7612 lines += 1000;
7613 }
7614 ImGui::BeginChild("Log");
7615 switch (test_type)
7616 {
7617 case 0:
7618 // Single call to TextUnformatted() with a big buffer
7619 ImGui::TextUnformatted(log.begin(), log.end());
7620 break;
7621 case 1:
7622 {
7623 // Multiple calls to Text(), manually coarsely clipped - demonstrate how to use the ImGuiListClipper helper.
7624 ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0));
7625 ImGuiListClipper clipper;
7626 clipper.Begin(lines);
7627 while (clipper.Step())
7628 for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++)
7629 ImGui::Text("%i The quick brown fox jumps over the lazy dog", i);
7630 ImGui::PopStyleVar();
7631 break;
7632 }
7633 case 2:
7634 // Multiple calls to Text(), not clipped (slow)
7635 ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0));
7636 for (int i = 0; i < lines; i++)
7637 ImGui::Text("%i The quick brown fox jumps over the lazy dog", i);
7638 ImGui::PopStyleVar();
7639 break;
7640 }
7641 ImGui::EndChild();
7642 ImGui::End();
7643}
7644

Callers 1

ShowDemoWindowMethod · 0.85

Calls 10

ImVec2Function · 0.85
PushStyleVarFunction · 0.85
PopStyleVarFunction · 0.85
appendfMethod · 0.80
sizeMethod · 0.45
clearMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
BeginMethod · 0.45
StepMethod · 0.45

Tested by

no test coverage detected