MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / EditTableSizingFlags

Function EditTableSizingFlags

3rdparty/imgui/src/imgui_demo.cpp:5708–5747  ·  view source on GitHub ↗

Show a combo box with a choice of sizing policies

Source from the content-addressed store, hash-verified

5706
5707// Show a combo box with a choice of sizing policies
5708static void EditTableSizingFlags(ImGuiTableFlags* p_flags)
5709{
5710 struct EnumDesc { ImGuiTableFlags Value; const char* Name; const char* Tooltip; };
5711 static const EnumDesc policies[] =
5712 {
5713 { 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." },
5714 { ImGuiTableFlags_SizingFixedFit, "ImGuiTableFlags_SizingFixedFit", "Columns default to _WidthFixed (if resizable) or _WidthAuto (if not resizable), matching contents width." },
5715 { ImGuiTableFlags_SizingFixedSame, "ImGuiTableFlags_SizingFixedSame", "Columns are all the same width, matching the maximum contents width.\nImplicitly disable ImGuiTableFlags_Resizable and enable ImGuiTableFlags_NoKeepColumnsVisible." },
5716 { ImGuiTableFlags_SizingStretchProp, "ImGuiTableFlags_SizingStretchProp", "Columns default to _WidthStretch with weights proportional to their widths." },
5717 { ImGuiTableFlags_SizingStretchSame, "ImGuiTableFlags_SizingStretchSame", "Columns default to _WidthStretch with same weights." }
5718 };
5719 int idx;
5720 for (idx = 0; idx < IM_COUNTOF(policies); idx++)
5721 if (policies[idx].Value == (*p_flags & ImGuiTableFlags_SizingMask_))
5722 break;
5723 const char* preview_text = (idx < IM_COUNTOF(policies)) ? policies[idx].Name + (idx > 0 ? strlen("ImGuiTableFlags") : 0) : "";
5724 if (ImGui::BeginCombo("Sizing Policy", preview_text))
5725 {
5726 for (int n = 0; n < IM_COUNTOF(policies); n++)
5727 if (ImGui::Selectable(policies[n].Name, idx == n))
5728 *p_flags = (*p_flags & ~ImGuiTableFlags_SizingMask_) | policies[n].Value;
5729 ImGui::EndCombo();
5730 }
5731 ImGui::SameLine();
5732 ImGui::TextDisabled("(?)");
5733 if (ImGui::BeginItemTooltip())
5734 {
5735 ImGui::PushTextWrapPos(ImGui::GetFontSize() * 50.0f);
5736 for (int m = 0; m < IM_COUNTOF(policies); m++)
5737 {
5738 ImGui::Separator();
5739 ImGui::Text("%s:", policies[m].Name);
5740 ImGui::Separator();
5741 ImGui::SetCursorPosX(ImGui::GetCursorPosX() + ImGui::GetStyle().IndentSpacing * 0.5f);
5742 ImGui::TextUnformatted(policies[m].Tooltip);
5743 }
5744 ImGui::PopTextWrapPos();
5745 ImGui::EndTooltip();
5746 }
5747}
5748
5749static void EditTableColumnsFlags(ImGuiTableColumnFlags* p_flags)
5750{

Callers 1

DemoWindowTablesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected