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