MCPcopy Create free account
hub / github.com/Aegel5/SimpleSwitcher / TableSetupColumnFlags

Function TableSetupColumnFlags

imgui_tiny_app/imgui/imgui_tables.cpp:789–842  ·  view source on GitHub ↗

Adjust flags: default width mode + stretch columns are not allowed when auto extending

Source from the content-addressed store, hash-verified

787
788// Adjust flags: default width mode + stretch columns are not allowed when auto extending
789static void TableSetupColumnFlags(ImGuiTable* table, ImGuiTableColumn* column, ImGuiTableColumnFlags flags_in)
790{
791 ImGuiTableColumnFlags flags = flags_in;
792
793 // Sizing Policy
794 if ((flags & ImGuiTableColumnFlags_WidthMask_) == 0)
795 {
796 const ImGuiTableFlags table_sizing_policy = (table->Flags & ImGuiTableFlags_SizingMask_);
797 if (table_sizing_policy == ImGuiTableFlags_SizingFixedFit || table_sizing_policy == ImGuiTableFlags_SizingFixedSame)
798 flags |= ImGuiTableColumnFlags_WidthFixed;
799 else
800 flags |= ImGuiTableColumnFlags_WidthStretch;
801 }
802 else
803 {
804 IM_ASSERT(ImIsPowerOfTwo(flags & ImGuiTableColumnFlags_WidthMask_)); // Check that only 1 of each set is used.
805 }
806
807 // Resize
808 if ((table->Flags & ImGuiTableFlags_Resizable) == 0)
809 flags |= ImGuiTableColumnFlags_NoResize;
810
811 // Sorting
812 if ((flags & ImGuiTableColumnFlags_NoSortAscending) && (flags & ImGuiTableColumnFlags_NoSortDescending))
813 flags |= ImGuiTableColumnFlags_NoSort;
814
815 // Indentation
816 if ((flags & ImGuiTableColumnFlags_IndentMask_) == 0)
817 flags |= (table->Columns.index_from_ptr(column) == 0) ? ImGuiTableColumnFlags_IndentEnable : ImGuiTableColumnFlags_IndentDisable;
818
819 // Alignment
820 //if ((flags & ImGuiTableColumnFlags_AlignMask_) == 0)
821 // flags |= ImGuiTableColumnFlags_AlignCenter;
822 //IM_ASSERT(ImIsPowerOfTwo(flags & ImGuiTableColumnFlags_AlignMask_)); // Check that only 1 of each set is used.
823
824 // Preserve status flags
825 column->Flags = flags | (column->Flags & ImGuiTableColumnFlags_StatusMask_);
826
827 // Build an ordered list of available sort directions
828 column->SortDirectionsAvailCount = column->SortDirectionsAvailMask = column->SortDirectionsAvailList = 0;
829 if (table->Flags & ImGuiTableFlags_Sortable)
830 {
831 int count = 0, mask = 0, list = 0;
832 if ((flags & ImGuiTableColumnFlags_PreferSortAscending) != 0 && (flags & ImGuiTableColumnFlags_NoSortAscending) == 0) { mask |= 1 << ImGuiSortDirection_Ascending; list |= ImGuiSortDirection_Ascending << (count << 1); count++; }
833 if ((flags & ImGuiTableColumnFlags_PreferSortDescending) != 0 && (flags & ImGuiTableColumnFlags_NoSortDescending) == 0) { mask |= 1 << ImGuiSortDirection_Descending; list |= ImGuiSortDirection_Descending << (count << 1); count++; }
834 if ((flags & ImGuiTableColumnFlags_PreferSortAscending) == 0 && (flags & ImGuiTableColumnFlags_NoSortAscending) == 0) { mask |= 1 << ImGuiSortDirection_Ascending; list |= ImGuiSortDirection_Ascending << (count << 1); count++; }
835 if ((flags & ImGuiTableColumnFlags_PreferSortDescending) == 0 && (flags & ImGuiTableColumnFlags_NoSortDescending) == 0) { mask |= 1 << ImGuiSortDirection_Descending; list |= ImGuiSortDirection_Descending << (count << 1); count++; }
836 if ((table->Flags & ImGuiTableFlags_SortTristate) || count == 0) { mask |= 1 << ImGuiSortDirection_None; count++; }
837 column->SortDirectionsAvailList = (ImU8)list;
838 column->SortDirectionsAvailMask = (ImU8)mask;
839 column->SortDirectionsAvailCount = (ImU8)count;
840 ImGui::TableFixColumnSortDirection(table, column);
841 }
842}
843
844// Layout columns for the frame. This is in essence the followup to BeginTable() and this is our largest function.
845// Runs on the first call to TableNextRow(), to give a chance for TableSetupColumn() and other TableSetupXXXXX() functions to be called first.

Callers 2

TableUpdateLayoutMethod · 0.85
TableSetupColumnMethod · 0.85

Calls 1

ImIsPowerOfTwoFunction · 0.85

Tested by

no test coverage detected