MCPcopy Create free account
hub / github.com/Raais/ImStudio / TableSetColumnSortDirection

Method TableSetColumnSortDirection

src/third-party/imgui/imgui_tables.cpp:2655–2686  ·  view source on GitHub ↗

Note that the NoSortAscending/NoSortDescending flags are processed in TableSortSpecsSanitize(), and they may change/revert the value of SortDirection. We could technically also do it here but it would be unnecessary and duplicate code.

Source from the content-addressed store, hash-verified

2653// Note that the NoSortAscending/NoSortDescending flags are processed in TableSortSpecsSanitize(), and they may change/revert
2654// the value of SortDirection. We could technically also do it here but it would be unnecessary and duplicate code.
2655void ImGui::TableSetColumnSortDirection(int column_n, ImGuiSortDirection sort_direction, bool append_to_sort_specs)
2656{
2657 ImGuiContext& g = *GImGui;
2658 ImGuiTable* table = g.CurrentTable;
2659
2660 if (!(table->Flags & ImGuiTableFlags_SortMulti))
2661 append_to_sort_specs = false;
2662 if (!(table->Flags & ImGuiTableFlags_SortTristate))
2663 IM_ASSERT(sort_direction != ImGuiSortDirection_None);
2664
2665 ImGuiTableColumnIdx sort_order_max = 0;
2666 if (append_to_sort_specs)
2667 for (int other_column_n = 0; other_column_n < table->ColumnsCount; other_column_n++)
2668 sort_order_max = ImMax(sort_order_max, table->Columns[other_column_n].SortOrder);
2669
2670 ImGuiTableColumn* column = &table->Columns[column_n];
2671 column->SortDirection = (ImU8)sort_direction;
2672 if (column->SortDirection == ImGuiSortDirection_None)
2673 column->SortOrder = -1;
2674 else if (column->SortOrder == -1 || !append_to_sort_specs)
2675 column->SortOrder = append_to_sort_specs ? sort_order_max + 1 : 0;
2676
2677 for (int other_column_n = 0; other_column_n < table->ColumnsCount; other_column_n++)
2678 {
2679 ImGuiTableColumn* other_column = &table->Columns[other_column_n];
2680 if (other_column != column && !append_to_sort_specs)
2681 other_column->SortOrder = -1;
2682 TableFixColumnSortDirection(table, other_column);
2683 }
2684 table->IsSettingsDirty = true;
2685 table->IsSortSpecsDirty = true;
2686}
2687
2688void ImGui::TableSortSpecsSanitize(ImGuiTable* table)
2689{

Callers

nothing calls this directly

Calls 1

ImMaxFunction · 0.85

Tested by

no test coverage detected