MCPcopy Create free account
hub / github.com/Joe1sn/S-inject / TableSetColumnSortDirection

Method TableSetColumnSortDirection

extern/ImGui/imgui_tables.cpp:2929–2960  ·  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

2927// Note that the NoSortAscending/NoSortDescending flags are processed in TableSortSpecsSanitize(), and they may change/revert
2928// the value of SortDirection. We could technically also do it here but it would be unnecessary and duplicate code.
2929void ImGui::TableSetColumnSortDirection(int column_n, ImGuiSortDirection sort_direction, bool append_to_sort_specs)
2930{
2931 ImGuiContext& g = *GImGui;
2932 ImGuiTable* table = g.CurrentTable;
2933
2934 if (!(table->Flags & ImGuiTableFlags_SortMulti))
2935 append_to_sort_specs = false;
2936 if (!(table->Flags & ImGuiTableFlags_SortTristate))
2937 IM_ASSERT(sort_direction != ImGuiSortDirection_None);
2938
2939 ImGuiTableColumnIdx sort_order_max = 0;
2940 if (append_to_sort_specs)
2941 for (int other_column_n = 0; other_column_n < table->ColumnsCount; other_column_n++)
2942 sort_order_max = ImMax(sort_order_max, table->Columns[other_column_n].SortOrder);
2943
2944 ImGuiTableColumn* column = &table->Columns[column_n];
2945 column->SortDirection = (ImU8)sort_direction;
2946 if (column->SortDirection == ImGuiSortDirection_None)
2947 column->SortOrder = -1;
2948 else if (column->SortOrder == -1 || !append_to_sort_specs)
2949 column->SortOrder = append_to_sort_specs ? sort_order_max + 1 : 0;
2950
2951 for (int other_column_n = 0; other_column_n < table->ColumnsCount; other_column_n++)
2952 {
2953 ImGuiTableColumn* other_column = &table->Columns[other_column_n];
2954 if (other_column != column && !append_to_sort_specs)
2955 other_column->SortOrder = -1;
2956 TableFixColumnSortDirection(table, other_column);
2957 }
2958 table->IsSettingsDirty = true;
2959 table->IsSortSpecsDirty = true;
2960}
2961
2962void ImGui::TableSortSpecsSanitize(ImGuiTable* table)
2963{

Callers

nothing calls this directly

Calls 1

ImMaxFunction · 0.85

Tested by

no test coverage detected