MCPcopy Create free account
hub / github.com/KebsCS/KBotExt / TableSetupColumnFlags

Function TableSetupColumnFlags

KBotExt/imgui/imgui_tables.cpp:680–733  ·  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

678
679// Adjust flags: default width mode + stretch columns are not allowed when auto extending
680static void TableSetupColumnFlags(ImGuiTable* table, ImGuiTableColumn* column, ImGuiTableColumnFlags flags_in)
681{
682 ImGuiTableColumnFlags flags = flags_in;
683
684 // Sizing Policy
685 if ((flags & ImGuiTableColumnFlags_WidthMask_) == 0)
686 {
687 const ImGuiTableFlags table_sizing_policy = (table->Flags & ImGuiTableFlags_SizingMask_);
688 if (table_sizing_policy == ImGuiTableFlags_SizingFixedFit || table_sizing_policy == ImGuiTableFlags_SizingFixedSame)
689 flags |= ImGuiTableColumnFlags_WidthFixed;
690 else
691 flags |= ImGuiTableColumnFlags_WidthStretch;
692 }
693 else
694 {
695 IM_ASSERT(ImIsPowerOfTwo(flags & ImGuiTableColumnFlags_WidthMask_)); // Check that only 1 of each set is used.
696 }
697
698 // Resize
699 if ((table->Flags & ImGuiTableFlags_Resizable) == 0)
700 flags |= ImGuiTableColumnFlags_NoResize;
701
702 // Sorting
703 if ((flags & ImGuiTableColumnFlags_NoSortAscending) && (flags & ImGuiTableColumnFlags_NoSortDescending))
704 flags |= ImGuiTableColumnFlags_NoSort;
705
706 // Indentation
707 if ((flags & ImGuiTableColumnFlags_IndentMask_) == 0)
708 flags |= (table->Columns.index_from_ptr(column) == 0) ? ImGuiTableColumnFlags_IndentEnable : ImGuiTableColumnFlags_IndentDisable;
709
710 // Alignment
711 //if ((flags & ImGuiTableColumnFlags_AlignMask_) == 0)
712 // flags |= ImGuiTableColumnFlags_AlignCenter;
713 //IM_ASSERT(ImIsPowerOfTwo(flags & ImGuiTableColumnFlags_AlignMask_)); // Check that only 1 of each set is used.
714
715 // Preserve status flags
716 column->Flags = flags | (column->Flags & ImGuiTableColumnFlags_StatusMask_);
717
718 // Build an ordered list of available sort directions
719 column->SortDirectionsAvailCount = column->SortDirectionsAvailMask = column->SortDirectionsAvailList = 0;
720 if (table->Flags & ImGuiTableFlags_Sortable)
721 {
722 int count = 0, mask = 0, list = 0;
723 if ((flags & ImGuiTableColumnFlags_PreferSortAscending) != 0 && (flags & ImGuiTableColumnFlags_NoSortAscending) == 0) { mask |= 1 << ImGuiSortDirection_Ascending; list |= ImGuiSortDirection_Ascending << (count << 1); count++; }
724 if ((flags & ImGuiTableColumnFlags_PreferSortDescending) != 0 && (flags & ImGuiTableColumnFlags_NoSortDescending) == 0) { mask |= 1 << ImGuiSortDirection_Descending; list |= ImGuiSortDirection_Descending << (count << 1); count++; }
725 if ((flags & ImGuiTableColumnFlags_PreferSortAscending) == 0 && (flags & ImGuiTableColumnFlags_NoSortAscending) == 0) { mask |= 1 << ImGuiSortDirection_Ascending; list |= ImGuiSortDirection_Ascending << (count << 1); count++; }
726 if ((flags & ImGuiTableColumnFlags_PreferSortDescending) == 0 && (flags & ImGuiTableColumnFlags_NoSortDescending) == 0) { mask |= 1 << ImGuiSortDirection_Descending; list |= ImGuiSortDirection_Descending << (count << 1); count++; }
727 if ((table->Flags & ImGuiTableFlags_SortTristate) || count == 0) { mask |= 1 << ImGuiSortDirection_None; count++; }
728 column->SortDirectionsAvailList = (ImU8)list;
729 column->SortDirectionsAvailMask = (ImU8)mask;
730 column->SortDirectionsAvailCount = (ImU8)count;
731 ImGui::TableFixColumnSortDirection(table, column);
732 }
733}
734
735// Layout columns for the frame. This is in essence the followup to BeginTable() and this is our largest function.
736// 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