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