mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-22 15:46:35 +00:00
Tables: demo synced tables + fix resizing indented synced tables.
This commit is contained in:
parent
0c9ab0acdd
commit
a70c6aae9f
@ -4456,14 +4456,42 @@ static void ShowDemoWindowTables()
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
// Demonstrate creating multiple tables with the same ID
|
||||
if (open_action != -1)
|
||||
ImGui::SetNextItemOpen(open_action != 0);
|
||||
if (ImGui::TreeNode("Synced instances"))
|
||||
{
|
||||
HelpMarker("Multiple tables with the same identifier will share their settings, width, visibility, order etc.");
|
||||
for (int n = 0; n < 3; n++)
|
||||
{
|
||||
char buf[32];
|
||||
sprintf(buf, "Synced Table %d", n);
|
||||
bool open = ImGui::CollapsingHeader(buf, ImGuiTreeNodeFlags_DefaultOpen);
|
||||
if (open && ImGui::BeginTable("Table", 3, ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable | ImGuiTableFlags_Borders | ImGuiTableFlags_ColumnsWidthFixed | ImGuiTableFlags_NoSavedSettings))
|
||||
{
|
||||
ImGui::TableSetupColumn("One");
|
||||
ImGui::TableSetupColumn("Two");
|
||||
ImGui::TableSetupColumn("Three");
|
||||
ImGui::TableHeadersRow();
|
||||
for (int cell = 0; cell < 9; cell++)
|
||||
{
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("this cell %d", cell);
|
||||
}
|
||||
ImGui::EndTable();
|
||||
}
|
||||
}
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
// Demonstrate using Sorting facilities
|
||||
// This is a simplified version of the "Advanced" example, where we mostly focus on the code necessary to handle sorting.
|
||||
// Note that the "Advanced" example also showcase manually triggering a sort (e.g. if item quantities have been modified)
|
||||
static const char* template_items_names[] =
|
||||
{
|
||||
"Banana", "Apple", "Cherry", "Watermelon", "Grapefruit", "Strawberry", "Mango",
|
||||
"Kiwi", "Orange", "Pineapple", "Blueberry", "Plum", "Coconut", "Pear", "Apricot"
|
||||
};
|
||||
|
||||
// This is a simplified version of the "Advanced" example, where we mostly focus on the code necessary to handle sorting.
|
||||
// Note that the "Advanced" example also showcase manually triggering a sort (e.g. if item quantities have been modified)
|
||||
if (open_action != -1)
|
||||
ImGui::SetNextItemOpen(open_action != 0);
|
||||
if (ImGui::TreeNode("Sorting"))
|
||||
|
@ -1122,7 +1122,7 @@ void ImGui::EndTable()
|
||||
}
|
||||
|
||||
// Apply resizing/dragging at the end of the frame
|
||||
if (table->ResizedColumn != -1)
|
||||
if (table->ResizedColumn != -1 && table->InstanceCurrent == table->InstanceInteracted)
|
||||
{
|
||||
ImGuiTableColumn* column = &table->Columns[table->ResizedColumn];
|
||||
const float new_x2 = (g.IO.MousePos.x - g.ActiveIdClickOffset.x + TABLE_RESIZE_SEPARATOR_HALF_THICKNESS);
|
||||
|
Loading…
Reference in New Issue
Block a user