MCPcopy Create free account
hub / github.com/cinder/Cinder / ShowExampleAppLongText

Function ShowExampleAppLongText

src/imgui/imgui_demo.cpp:9506–9562  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

9504
9505// Demonstrate/test rendering huge amount of text, and the incidence of clipping.
9506static void ShowExampleAppLongText(bool* p_open)
9507{
9508 ImGui::SetNextWindowSize(ImVec2(520, 600), ImGuiCond_FirstUseEver);
9509 if (!ImGui::Begin("Example: Long text display", p_open))
9510 {
9511 ImGui::End();
9512 return;
9513 }
9514 IMGUI_DEMO_MARKER("Examples/Long text display");
9515
9516 static int test_type = 0;
9517 static ImGuiTextBuffer log;
9518 static int lines = 0;
9519 ImGui::Text("Printing unusually long amount of text.");
9520 ImGui::Combo("Test type", &test_type,
9521 "Single call to TextUnformatted()\0"
9522 "Multiple calls to Text(), clipped\0"
9523 "Multiple calls to Text(), not clipped (slow)\0");
9524 ImGui::Text("Buffer contents: %d lines, %d bytes", lines, log.size());
9525 if (ImGui::Button("Clear")) { log.clear(); lines = 0; }
9526 ImGui::SameLine();
9527 if (ImGui::Button("Add 1000 lines"))
9528 {
9529 for (int i = 0; i < 1000; i++)
9530 log.appendf("%i The quick brown fox jumps over the lazy dog\n", lines + i);
9531 lines += 1000;
9532 }
9533 ImGui::BeginChild("Log");
9534 switch (test_type)
9535 {
9536 case 0:
9537 // Single call to TextUnformatted() with a big buffer
9538 ImGui::TextUnformatted(log.begin(), log.end());
9539 break;
9540 case 1:
9541 {
9542 // Multiple calls to Text(), manually coarsely clipped - demonstrate how to use the ImGuiListClipper helper.
9543 ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0));
9544 ImGuiListClipper clipper;
9545 clipper.Begin(lines);
9546 while (clipper.Step())
9547 for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++)
9548 ImGui::Text("%i The quick brown fox jumps over the lazy dog", i);
9549 ImGui::PopStyleVar();
9550 break;
9551 }
9552 case 2:
9553 // Multiple calls to Text(), not clipped (slow)
9554 ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0));
9555 for (int i = 0; i < lines; i++)
9556 ImGui::Text("%i The quick brown fox jumps over the lazy dog", i);
9557 ImGui::PopStyleVar();
9558 break;
9559 }
9560 ImGui::EndChild();
9561 ImGui::End();
9562}
9563

Callers 1

ShowDemoWindowMethod · 0.85

Calls 9

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

Tested by

no test coverage detected