mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-22 20:07:01 +00:00
Demo: long text example uses ImGuiListClipper
This commit is contained in:
parent
2d565d4bfb
commit
aa35547f94
@ -2110,16 +2110,16 @@ static void ShowExampleAppLongText(bool* opened)
|
|||||||
ImGui::TextUnformatted(log.begin(), log.end());
|
ImGui::TextUnformatted(log.begin(), log.end());
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
// Multiple calls to Text(), manually coarsely clipped - demonstrate how to use the CalcListClipping() helper.
|
{
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0,0));
|
// Multiple calls to Text(), manually coarsely clipped - demonstrate how to use the ImGuiListClipper helper.
|
||||||
int display_start, display_end;
|
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0,0));
|
||||||
ImGui::CalcListClipping(lines, ImGui::GetTextLineHeight(), &display_start, &display_end);
|
ImGuiListClipper clipper(lines, ImGui::GetTextLineHeight());
|
||||||
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + (display_start) * ImGui::GetTextLineHeight());
|
for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++)
|
||||||
for (int i = display_start; i < display_end; i++)
|
ImGui::Text("%i The quick brown fox jumps over the lazy dog\n", i);
|
||||||
ImGui::Text("%i The quick brown fox jumps over the lazy dog\n", i);
|
clipper.End();
|
||||||
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + (lines - display_end) * ImGui::GetTextLineHeight());
|
ImGui::PopStyleVar();
|
||||||
ImGui::PopStyleVar();
|
break;
|
||||||
break;
|
}
|
||||||
case 2:
|
case 2:
|
||||||
// Multiple calls to Text(), not clipped (slow)
|
// Multiple calls to Text(), not clipped (slow)
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0,0));
|
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0,0));
|
||||||
|
Loading…
Reference in New Issue
Block a user