MCPcopy Create free account
hub / github.com/Wemino/MarkerPatch / TableSetColumnSortDirection

Method TableSetColumnSortDirection

include/imgui/imgui_tables.cpp:2963–2994  ·  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

2961// Note that the NoSortAscending/NoSortDescending flags are processed in TableSortSpecsSanitize(), and they may change/revert
2962// the value of SortDirection. We could technically also do it here but it would be unnecessary and duplicate code.
2963void ImGui::TableSetColumnSortDirection(int column_n, ImGuiSortDirection sort_direction, bool append_to_sort_specs)
2964{
2965 ImGuiContext& g = *GImGui;
2966 ImGuiTable* table = g.CurrentTable;
2967
2968 if (!(table->Flags & ImGuiTableFlags_SortMulti))
2969 append_to_sort_specs = false;
2970 if (!(table->Flags & ImGuiTableFlags_SortTristate))
2971 IM_ASSERT(sort_direction != ImGuiSortDirection_None);
2972
2973 ImGuiTableColumnIdx sort_order_max = 0;
2974 if (append_to_sort_specs)
2975 for (int other_column_n = 0; other_column_n < table->ColumnsCount; other_column_n++)
2976 sort_order_max = ImMax(sort_order_max, table->Columns[other_column_n].SortOrder);
2977
2978 ImGuiTableColumn* column = &table->Columns[column_n];
2979 column->SortDirection = (ImU8)sort_direction;
2980 if (column->SortDirection == ImGuiSortDirection_None)
2981 column->SortOrder = -1;
2982 else if (column->SortOrder == -1 || !append_to_sort_specs)
2983 column->SortOrder = append_to_sort_specs ? sort_order_max + 1 : 0;
2984
2985 for (int other_column_n = 0; other_column_n < table->ColumnsCount; other_column_n++)
2986 {
2987 ImGuiTableColumn* other_column = &table->Columns[other_column_n];
2988 if (other_column != column && !append_to_sort_specs)
2989 other_column->SortOrder = -1;
2990 TableFixColumnSortDirection(table, other_column);
2991 }
2992 table->IsSettingsDirty = true;
2993 table->IsSortSpecsDirty = true;
2994}
2995
2996void ImGui::TableSortSpecsSanitize(ImGuiTable* table)
2997{

Callers

nothing calls this directly

Calls 1

ImMaxFunction · 0.85

Tested by

no test coverage detected