MCPcopy Create free account
hub / github.com/AlexandreRouma/SDRPlusPlus / TableSetupColumnFlags

Function TableSetupColumnFlags

core/src/imgui/imgui_tables.cpp:660–713  ·  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

658
659// Adjust flags: default width mode + stretch columns are not allowed when auto extending
660static void TableSetupColumnFlags(ImGuiTable* table, ImGuiTableColumn* column, ImGuiTableColumnFlags flags_in)
661{
662 ImGuiTableColumnFlags flags = flags_in;
663
664 // Sizing Policy
665 if ((flags & ImGuiTableColumnFlags_WidthMask_) == 0)
666 {
667 const ImGuiTableFlags table_sizing_policy = (table->Flags & ImGuiTableFlags_SizingMask_);
668 if (table_sizing_policy == ImGuiTableFlags_SizingFixedFit || table_sizing_policy == ImGuiTableFlags_SizingFixedSame)
669 flags |= ImGuiTableColumnFlags_WidthFixed;
670 else
671 flags |= ImGuiTableColumnFlags_WidthStretch;
672 }
673 else
674 {
675 IM_ASSERT(ImIsPowerOfTwo(flags & ImGuiTableColumnFlags_WidthMask_)); // Check that only 1 of each set is used.
676 }
677
678 // Resize
679 if ((table->Flags & ImGuiTableFlags_Resizable) == 0)
680 flags |= ImGuiTableColumnFlags_NoResize;
681
682 // Sorting
683 if ((flags & ImGuiTableColumnFlags_NoSortAscending) && (flags & ImGuiTableColumnFlags_NoSortDescending))
684 flags |= ImGuiTableColumnFlags_NoSort;
685
686 // Indentation
687 if ((flags & ImGuiTableColumnFlags_IndentMask_) == 0)
688 flags |= (table->Columns.index_from_ptr(column) == 0) ? ImGuiTableColumnFlags_IndentEnable : ImGuiTableColumnFlags_IndentDisable;
689
690 // Alignment
691 //if ((flags & ImGuiTableColumnFlags_AlignMask_) == 0)
692 // flags |= ImGuiTableColumnFlags_AlignCenter;
693 //IM_ASSERT(ImIsPowerOfTwo(flags & ImGuiTableColumnFlags_AlignMask_)); // Check that only 1 of each set is used.
694
695 // Preserve status flags
696 column->Flags = flags | (column->Flags & ImGuiTableColumnFlags_StatusMask_);
697
698 // Build an ordered list of available sort directions
699 column->SortDirectionsAvailCount = column->SortDirectionsAvailMask = column->SortDirectionsAvailList = 0;
700 if (table->Flags & ImGuiTableFlags_Sortable)
701 {
702 int count = 0, mask = 0, list = 0;
703 if ((flags & ImGuiTableColumnFlags_PreferSortAscending) != 0 && (flags & ImGuiTableColumnFlags_NoSortAscending) == 0) { mask |= 1 << ImGuiSortDirection_Ascending; list |= ImGuiSortDirection_Ascending << (count << 1); count++; }
704 if ((flags & ImGuiTableColumnFlags_PreferSortDescending) != 0 && (flags & ImGuiTableColumnFlags_NoSortDescending) == 0) { mask |= 1 << ImGuiSortDirection_Descending; list |= ImGuiSortDirection_Descending << (count << 1); count++; }
705 if ((flags & ImGuiTableColumnFlags_PreferSortAscending) == 0 && (flags & ImGuiTableColumnFlags_NoSortAscending) == 0) { mask |= 1 << ImGuiSortDirection_Ascending; list |= ImGuiSortDirection_Ascending << (count << 1); count++; }
706 if ((flags & ImGuiTableColumnFlags_PreferSortDescending) == 0 && (flags & ImGuiTableColumnFlags_NoSortDescending) == 0) { mask |= 1 << ImGuiSortDirection_Descending; list |= ImGuiSortDirection_Descending << (count << 1); count++; }
707 if ((table->Flags & ImGuiTableFlags_SortTristate) || count == 0) { mask |= 1 << ImGuiSortDirection_None; count++; }
708 column->SortDirectionsAvailList = (ImU8)list;
709 column->SortDirectionsAvailMask = (ImU8)mask;
710 column->SortDirectionsAvailCount = (ImU8)count;
711 ImGui::TableFixColumnSortDirection(table, column);
712 }
713}
714
715// Layout columns for the frame. This is in essence the followup to BeginTable().
716// Runs on the first call to TableNextRow(), to give a chance for TableSetupColumn() to be called first.

Callers 2

TableUpdateLayoutMethod · 0.85
TableSetupColumnMethod · 0.85

Calls 2

ImIsPowerOfTwoFunction · 0.85
index_from_ptrMethod · 0.80

Tested by

no test coverage detected