Show a combo box with a choice of sizing policies
| 3454 | |
| 3455 | // Show a combo box with a choice of sizing policies |
| 3456 | static void EditTableSizingFlags(ImGuiTableFlags* p_flags) |
| 3457 | { |
| 3458 | struct EnumDesc { ImGuiTableFlags Value; const char* Name; const char* Tooltip; }; |
| 3459 | static const EnumDesc policies[] = |
| 3460 | { |
| 3461 | { ImGuiTableFlags_None, "Default", "Use default sizing policy:\n- ImGuiTableFlags_SizingFixedFit if ScrollX is on or if host window has ImGuiWindowFlags_AlwaysAutoResize.\n- ImGuiTableFlags_SizingStretchSame otherwise." }, |
| 3462 | { ImGuiTableFlags_SizingFixedFit, "ImGuiTableFlags_SizingFixedFit", "Columns default to _WidthFixed (if resizable) or _WidthAuto (if not resizable), matching contents width." }, |
| 3463 | { ImGuiTableFlags_SizingFixedSame, "ImGuiTableFlags_SizingFixedSame", "Columns are all the same width, matching the maximum contents width.\nImplicitly disable ImGuiTableFlags_Resizable and enable ImGuiTableFlags_NoKeepColumnsVisible." }, |
| 3464 | { ImGuiTableFlags_SizingStretchProp, "ImGuiTableFlags_SizingStretchProp", "Columns default to _WidthStretch with weights proportional to their widths." }, |
| 3465 | { ImGuiTableFlags_SizingStretchSame, "ImGuiTableFlags_SizingStretchSame", "Columns default to _WidthStretch with same weights." } |
| 3466 | }; |
| 3467 | int idx; |
| 3468 | for (idx = 0; idx < IM_ARRAYSIZE(policies); idx++) |
| 3469 | if (policies[idx].Value == (*p_flags & ImGuiTableFlags_SizingMask_)) |
| 3470 | break; |
| 3471 | const char* preview_text = (idx < IM_ARRAYSIZE(policies)) ? policies[idx].Name + (idx > 0 ? strlen("ImGuiTableFlags") : 0) : ""; |
| 3472 | if (ImGui::BeginCombo("Sizing Policy", preview_text)) |
| 3473 | { |
| 3474 | for (int n = 0; n < IM_ARRAYSIZE(policies); n++) |
| 3475 | if (ImGui::Selectable(policies[n].Name, idx == n)) |
| 3476 | *p_flags = (*p_flags & ~ImGuiTableFlags_SizingMask_) | policies[n].Value; |
| 3477 | ImGui::EndCombo(); |
| 3478 | } |
| 3479 | ImGui::SameLine(); |
| 3480 | ImGui::TextDisabled("(?)"); |
| 3481 | if (ImGui::IsItemHovered()) |
| 3482 | { |
| 3483 | ImGui::BeginTooltip(); |
| 3484 | ImGui::PushTextWrapPos(ImGui::GetFontSize() * 50.0f); |
| 3485 | for (int m = 0; m < IM_ARRAYSIZE(policies); m++) |
| 3486 | { |
| 3487 | ImGui::Separator(); |
| 3488 | ImGui::Text("%s:", policies[m].Name); |
| 3489 | ImGui::Separator(); |
| 3490 | ImGui::SetCursorPosX(ImGui::GetCursorPosX() + ImGui::GetStyle().IndentSpacing * 0.5f); |
| 3491 | ImGui::TextUnformatted(policies[m].Tooltip); |
| 3492 | } |
| 3493 | ImGui::PopTextWrapPos(); |
| 3494 | ImGui::EndTooltip(); |
| 3495 | } |
| 3496 | } |
| 3497 | |
| 3498 | static void EditTableColumnsFlags(ImGuiTableColumnFlags* p_flags) |
| 3499 | { |
no outgoing calls
no test coverage detected