mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-06 04:58:47 +02:00
Tables: Additionally commentary about clipper in the demo + minor padding tweak.
This commit is contained in:
@ -1098,7 +1098,7 @@ static void ShowDemoWindowWidgets()
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Selectable(label, &selected[i]); // FIXME-TABLE: Selection overlap
|
||||
}
|
||||
ImGui::EndTable();
|
||||
ImGui::EndTable();
|
||||
}
|
||||
ImGui::Separator();
|
||||
if (ImGui::BeginTable("split2", 3, ImGuiTableFlags_Resizable | ImGuiTableFlags_NoSavedSettings))
|
||||
@ -3755,7 +3755,7 @@ static void ShowDemoWindowTables()
|
||||
|
||||
if (open_action != -1)
|
||||
ImGui::SetNextItemOpen(open_action != 0);
|
||||
if (ImGui::TreeNode("Vertical scrolling"))
|
||||
if (ImGui::TreeNode("Vertical scrolling, with clipping"))
|
||||
{
|
||||
HelpMarker("Here we activate ScrollY, which will create a child window container to allow hosting scrollable contents.\n\nWe also demonstrate using ImGuiListClipper to virtualize the submission of many items.");
|
||||
static ImGuiTableFlags flags = ImGuiTableFlags_ScrollY | ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV | ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable;
|
||||
@ -3774,6 +3774,8 @@ static void ShowDemoWindowTables()
|
||||
ImGui::TableSetupColumn("Two", ImGuiTableColumnFlags_None);
|
||||
ImGui::TableSetupColumn("Three", ImGuiTableColumnFlags_None);
|
||||
ImGui::TableHeadersRow();
|
||||
|
||||
// Demonstrate using clipper for large vertical lists
|
||||
ImGuiListClipper clipper;
|
||||
clipper.Begin(1000);
|
||||
while (clipper.Step())
|
||||
@ -4393,6 +4395,7 @@ static void ShowDemoWindowTables()
|
||||
ImGui::TableSetupColumn("Action", ImGuiTableColumnFlags_NoSort | ImGuiTableColumnFlags_WidthFixed, -1.0f, MyItemColumnID_Action);
|
||||
ImGui::TableSetupColumn("Quantity", ImGuiTableColumnFlags_PreferSortDescending | ImGuiTableColumnFlags_WidthStretch, -1.0f, MyItemColumnID_Quantity);
|
||||
ImGui::TableSetupScrollFreeze(0, 1); // Make row always visible
|
||||
ImGui::TableHeadersRow();
|
||||
|
||||
// Sort our data if sort specs have been changed!
|
||||
if (ImGuiTableSortSpecs* sorts_specs = ImGui::TableGetSortSpecs())
|
||||
@ -4405,13 +4408,13 @@ static void ShowDemoWindowTables()
|
||||
sorts_specs->SpecsDirty = false;
|
||||
}
|
||||
|
||||
// Display data
|
||||
ImGui::TableHeadersRow();
|
||||
// Demonstrate using clipper for large vertical lists
|
||||
ImGuiListClipper clipper;
|
||||
clipper.Begin(items.Size);
|
||||
while (clipper.Step())
|
||||
for (int row_n = clipper.DisplayStart; row_n < clipper.DisplayEnd; row_n++)
|
||||
{
|
||||
// Display a data item
|
||||
MyItem* item = &items[row_n];
|
||||
ImGui::PushID(item->ID);
|
||||
ImGui::TableNextRow();
|
||||
@ -4448,7 +4451,7 @@ static void ShowDemoWindowTables()
|
||||
static int freeze_cols = 1;
|
||||
static int freeze_rows = 1;
|
||||
static int items_count = IM_ARRAYSIZE(template_items_names);
|
||||
static ImVec2 outer_size_value = ImVec2(0, TEXT_BASE_HEIGHT * 15);
|
||||
static ImVec2 outer_size_value = ImVec2(0, TEXT_BASE_HEIGHT * 12);
|
||||
static float row_min_height = 0.0f; // Auto
|
||||
static float inner_width_with_scroll = 0.0f; // Auto-extend
|
||||
static bool outer_size_enabled = true;
|
||||
@ -4609,14 +4612,16 @@ static void ShowDemoWindowTables()
|
||||
// FIXME-TABLE FIXME-NAV: How we can get decent up/down even though we have the buttons here?
|
||||
ImGui::PushButtonRepeat(true);
|
||||
#if 1
|
||||
// Demonstrate using clipper for large vertical lists
|
||||
ImGuiListClipper clipper;
|
||||
clipper.Begin(items.Size);
|
||||
while (clipper.Step())
|
||||
{
|
||||
for (int row_n = clipper.DisplayStart; row_n < clipper.DisplayEnd; row_n++)
|
||||
#else
|
||||
// Without clipper
|
||||
{
|
||||
for (int row_n = 0; row_n < items_count; row_n++)
|
||||
for (int row_n = 0; row_n < items.Size; row_n++)
|
||||
#endif
|
||||
{
|
||||
MyItem* item = &items[row_n];
|
||||
@ -4691,6 +4696,7 @@ static void ShowDemoWindowTables()
|
||||
}
|
||||
ImGui::PopButtonRepeat();
|
||||
|
||||
// Store some info to display debug details below
|
||||
table_scroll_cur = ImVec2(ImGui::GetScrollX(), ImGui::GetScrollY());
|
||||
table_scroll_max = ImVec2(ImGui::GetScrollMaxX(), ImGui::GetScrollMaxY());
|
||||
table_draw_list = ImGui::GetWindowDrawList();
|
||||
@ -4703,7 +4709,8 @@ static void ShowDemoWindowTables()
|
||||
ImGui::SameLine(0.0f, 0.0f);
|
||||
const int table_draw_list_draw_cmd_count = table_draw_list->CmdBuffer.Size;
|
||||
if (table_draw_list == parent_draw_list)
|
||||
ImGui::Text(": DrawCmd: +%d (in same window)", table_draw_list_draw_cmd_count - parent_draw_list_draw_cmd_count);
|
||||
ImGui::Text(": DrawCmd: +%d (in same window)",
|
||||
table_draw_list_draw_cmd_count - parent_draw_list_draw_cmd_count);
|
||||
else
|
||||
ImGui::Text(": DrawCmd: +%d (in child window), Scroll: (%.f/%.f) (%.f/%.f)",
|
||||
table_draw_list_draw_cmd_count - 1, table_scroll_cur.x, table_scroll_max.x, table_scroll_cur.y, table_scroll_max.y);
|
||||
@ -4860,8 +4867,10 @@ static void ShowDemoWindowColumns()
|
||||
ImVec2 child_size = ImVec2(0, ImGui::GetFontSize() * 20.0f);
|
||||
ImGui::BeginChild("##ScrollingRegion", child_size, false, ImGuiWindowFlags_HorizontalScrollbar);
|
||||
ImGui::Columns(10);
|
||||
|
||||
// Also demonstrate using clipper for large vertical lists
|
||||
int ITEMS_COUNT = 2000;
|
||||
ImGuiListClipper clipper; // Also demonstrate using the clipper for large list
|
||||
ImGuiListClipper clipper;
|
||||
clipper.Begin(ITEMS_COUNT);
|
||||
while (clipper.Step())
|
||||
{
|
||||
|
Reference in New Issue
Block a user