MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / ShowExampleAppLongText

Function ShowExampleAppLongText

3rdparty/imgui/src/imgui_demo.cpp:9822–9878  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

9820
9821// Demonstrate/test rendering huge amount of text, and the incidence of clipping.
9822static void ShowExampleAppLongText(bool* p_open)
9823{
9824 ImGui::SetNextWindowSize(ImVec2(520, 600), ImGuiCond_FirstUseEver);
9825 if (!ImGui::Begin("Example: Long text display", p_open))
9826 {
9827 ImGui::End();
9828 return;
9829 }
9830 IMGUI_DEMO_MARKER("Examples/Long text display");
9831
9832 static int test_type = 0;
9833 static ImGuiTextBuffer log;
9834 static int lines = 0;
9835 ImGui::Text("Printing unusually long amount of text.");
9836 ImGui::Combo("Test type", &test_type,
9837 "Single call to TextUnformatted()\0"
9838 "Multiple calls to Text(), clipped\0"
9839 "Multiple calls to Text(), not clipped (slow)\0");
9840 ImGui::Text("Buffer contents: %d lines, %d bytes", lines, log.size());
9841 if (ImGui::Button("Clear")) { log.clear(); lines = 0; }
9842 ImGui::SameLine();
9843 if (ImGui::Button("Add 1000 lines"))
9844 {
9845 for (int i = 0; i < 1000; i++)
9846 log.appendf("%i The quick brown fox jumps over the lazy dog\n", lines + i);
9847 lines += 1000;
9848 }
9849 ImGui::BeginChild("Log");
9850 switch (test_type)
9851 {
9852 case 0:
9853 // Single call to TextUnformatted() with a big buffer
9854 ImGui::TextUnformatted(log.begin(), log.end());
9855 break;
9856 case 1:
9857 {
9858 // Multiple calls to Text(), manually coarsely clipped - demonstrate how to use the ImGuiListClipper helper.
9859 ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0));
9860 ImGuiListClipper clipper;
9861 clipper.Begin(lines);
9862 while (clipper.Step())
9863 for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++)
9864 ImGui::Text("%i The quick brown fox jumps over the lazy dog", i);
9865 ImGui::PopStyleVar();
9866 break;
9867 }
9868 case 2:
9869 // Multiple calls to Text(), not clipped (slow)
9870 ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0));
9871 for (int i = 0; i < lines; i++)
9872 ImGui::Text("%i The quick brown fox jumps over the lazy dog", i);
9873 ImGui::PopStyleVar();
9874 break;
9875 }
9876 ImGui::EndChild();
9877 ImGui::End();
9878}
9879

Callers 1

ShowDemoWindowMethod · 0.85

Calls 10

BeginFunction · 0.85
EndFunction · 0.85
appendfMethod · 0.80
ImVec2Function · 0.50
sizeMethod · 0.45
clearMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
BeginMethod · 0.45
StepMethod · 0.45

Tested by

no test coverage detected