MCPcopy Create free account
hub / github.com/cinder/Cinder / TableSetupColumnFlags

Function TableSetupColumnFlags

src/imgui/imgui_tables.cpp:744–797  ·  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

742
743// Adjust flags: default width mode + stretch columns are not allowed when auto extending
744static void TableSetupColumnFlags(ImGuiTable* table, ImGuiTableColumn* column, ImGuiTableColumnFlags flags_in)
745{
746 ImGuiTableColumnFlags flags = flags_in;
747
748 // Sizing Policy
749 if ((flags & ImGuiTableColumnFlags_WidthMask_) == 0)
750 {
751 const ImGuiTableFlags table_sizing_policy = (table->Flags & ImGuiTableFlags_SizingMask_);
752 if (table_sizing_policy == ImGuiTableFlags_SizingFixedFit || table_sizing_policy == ImGuiTableFlags_SizingFixedSame)
753 flags |= ImGuiTableColumnFlags_WidthFixed;
754 else
755 flags |= ImGuiTableColumnFlags_WidthStretch;
756 }
757 else
758 {
759 IM_ASSERT(ImIsPowerOfTwo(flags & ImGuiTableColumnFlags_WidthMask_)); // Check that only 1 of each set is used.
760 }
761
762 // Resize
763 if ((table->Flags & ImGuiTableFlags_Resizable) == 0)
764 flags |= ImGuiTableColumnFlags_NoResize;
765
766 // Sorting
767 if ((flags & ImGuiTableColumnFlags_NoSortAscending) && (flags & ImGuiTableColumnFlags_NoSortDescending))
768 flags |= ImGuiTableColumnFlags_NoSort;
769
770 // Indentation
771 if ((flags & ImGuiTableColumnFlags_IndentMask_) == 0)
772 flags |= (table->Columns.index_from_ptr(column) == 0) ? ImGuiTableColumnFlags_IndentEnable : ImGuiTableColumnFlags_IndentDisable;
773
774 // Alignment
775 //if ((flags & ImGuiTableColumnFlags_AlignMask_) == 0)
776 // flags |= ImGuiTableColumnFlags_AlignCenter;
777 //IM_ASSERT(ImIsPowerOfTwo(flags & ImGuiTableColumnFlags_AlignMask_)); // Check that only 1 of each set is used.
778
779 // Preserve status flags
780 column->Flags = flags | (column->Flags & ImGuiTableColumnFlags_StatusMask_);
781
782 // Build an ordered list of available sort directions
783 column->SortDirectionsAvailCount = column->SortDirectionsAvailMask = column->SortDirectionsAvailList = 0;
784 if (table->Flags & ImGuiTableFlags_Sortable)
785 {
786 int count = 0, mask = 0, list = 0;
787 if ((flags & ImGuiTableColumnFlags_PreferSortAscending) != 0 && (flags & ImGuiTableColumnFlags_NoSortAscending) == 0) { mask |= 1 << ImGuiSortDirection_Ascending; list |= ImGuiSortDirection_Ascending << (count << 1); count++; }
788 if ((flags & ImGuiTableColumnFlags_PreferSortDescending) != 0 && (flags & ImGuiTableColumnFlags_NoSortDescending) == 0) { mask |= 1 << ImGuiSortDirection_Descending; list |= ImGuiSortDirection_Descending << (count << 1); count++; }
789 if ((flags & ImGuiTableColumnFlags_PreferSortAscending) == 0 && (flags & ImGuiTableColumnFlags_NoSortAscending) == 0) { mask |= 1 << ImGuiSortDirection_Ascending; list |= ImGuiSortDirection_Ascending << (count << 1); count++; }
790 if ((flags & ImGuiTableColumnFlags_PreferSortDescending) == 0 && (flags & ImGuiTableColumnFlags_NoSortDescending) == 0) { mask |= 1 << ImGuiSortDirection_Descending; list |= ImGuiSortDirection_Descending << (count << 1); count++; }
791 if ((table->Flags & ImGuiTableFlags_SortTristate) || count == 0) { mask |= 1 << ImGuiSortDirection_None; count++; }
792 column->SortDirectionsAvailList = (ImU8)list;
793 column->SortDirectionsAvailMask = (ImU8)mask;
794 column->SortDirectionsAvailCount = (ImU8)count;
795 ImGui::TableFixColumnSortDirection(table, column);
796 }
797}
798
799// Layout columns for the frame. This is in essence the followup to BeginTable() and this is our largest function.
800// 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