MCPcopy Create free account
hub / github.com/GPUOpen-LibrariesAndSDKs/Cauldron / ShowExampleAppLongText

Function ShowExampleAppLongText

libs/imgui/imgui_demo.cpp:3007–3058  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

3005
3006// Demonstrate/test rendering huge amount of text, and the incidence of clipping.
3007static void ShowExampleAppLongText(bool* p_open)
3008{
3009 ImGui::SetNextWindowSize(ImVec2(520,600), ImGuiCond_FirstUseEver);
3010 if (!ImGui::Begin("Example: Long text display", p_open))
3011 {
3012 ImGui::End();
3013 return;
3014 }
3015
3016 static int test_type = 0;
3017 static ImGuiTextBuffer log;
3018 static int lines = 0;
3019 ImGui::Text("Printing unusually long amount of text.");
3020 ImGui::Combo("Test type", &test_type, "Single call to TextUnformatted()\0Multiple calls to Text(), clipped manually\0Multiple calls to Text(), not clipped (slow)\0");
3021 ImGui::Text("Buffer contents: %d lines, %d bytes", lines, log.size());
3022 if (ImGui::Button("Clear")) { log.clear(); lines = 0; }
3023 ImGui::SameLine();
3024 if (ImGui::Button("Add 1000 lines"))
3025 {
3026 for (int i = 0; i < 1000; i++)
3027 log.appendf("%i The quick brown fox jumps over the lazy dog\n", lines+i);
3028 lines += 1000;
3029 }
3030 ImGui::BeginChild("Log");
3031 switch (test_type)
3032 {
3033 case 0:
3034 // Single call to TextUnformatted() with a big buffer
3035 ImGui::TextUnformatted(log.begin(), log.end());
3036 break;
3037 case 1:
3038 {
3039 // Multiple calls to Text(), manually coarsely clipped - demonstrate how to use the ImGuiListClipper helper.
3040 ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0,0));
3041 ImGuiListClipper clipper(lines);
3042 while (clipper.Step())
3043 for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++)
3044 ImGui::Text("%i The quick brown fox jumps over the lazy dog", i);
3045 ImGui::PopStyleVar();
3046 break;
3047 }
3048 case 2:
3049 // Multiple calls to Text(), not clipped (slow)
3050 ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0,0));
3051 for (int i = 0; i < lines; i++)
3052 ImGui::Text("%i The quick brown fox jumps over the lazy dog", i);
3053 ImGui::PopStyleVar();
3054 break;
3055 }
3056 ImGui::EndChild();
3057 ImGui::End();
3058}
3059
3060// End of Demo code
3061#else

Callers 1

ShowDemoWindowMethod · 0.85

Calls 7

ImVec2Class · 0.85
appendfMethod · 0.80
sizeMethod · 0.45
clearMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
StepMethod · 0.45

Tested by

no test coverage detected