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

Method SeparatorTextEx

3rdparty/imgui/src/imgui_widgets.cpp:1736–1784  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1734}
1735
1736void ImGui::SeparatorTextEx(ImGuiID id, const char* label, const char* label_end, float extra_w)
1737{
1738 ImGuiContext& g = *GImGui;
1739 ImGuiWindow* window = g.CurrentWindow;
1740 ImGuiStyle& style = g.Style;
1741
1742 const ImVec2 label_size = CalcTextSize(label, label_end, false);
1743 const ImVec2 pos = window->DC.CursorPos;
1744 const ImVec2 padding = style.SeparatorTextPadding;
1745
1746 const float separator_thickness = style.SeparatorTextBorderSize;
1747 const ImVec2 min_size(label_size.x + extra_w + padding.x * 2.0f, ImMax(label_size.y + padding.y * 2.0f, separator_thickness));
1748 const ImRect bb(pos, ImVec2(window->WorkRect.Max.x, pos.y + min_size.y));
1749 const float text_baseline_y = ImTrunc((bb.GetHeight() - label_size.y) * style.SeparatorTextAlign.y + 0.99999f); //ImMax(padding.y, ImTrunc((style.SeparatorTextSize - label_size.y) * 0.5f));
1750 ItemSize(min_size, text_baseline_y);
1751 if (!ItemAdd(bb, id))
1752 return;
1753
1754 const float sep1_x1 = pos.x;
1755 const float sep2_x2 = bb.Max.x;
1756 const float seps_y = ImTrunc((bb.Min.y + bb.Max.y) * 0.5f + 0.99999f);
1757
1758 const float label_avail_w = ImMax(0.0f, sep2_x2 - sep1_x1 - padding.x * 2.0f);
1759 const ImVec2 label_pos(pos.x + padding.x + ImMax(0.0f, (label_avail_w - label_size.x - extra_w) * style.SeparatorTextAlign.x), pos.y + text_baseline_y); // FIXME-ALIGN
1760
1761 // This allows using SameLine() to position something in the 'extra_w'
1762 window->DC.CursorPosPrevLine.x = label_pos.x + label_size.x;
1763
1764 const ImU32 separator_col = GetColorU32(ImGuiCol_Separator);
1765 if (label_size.x > 0.0f)
1766 {
1767 const float sep1_x2 = label_pos.x - style.ItemSpacing.x;
1768 const float sep2_x1 = label_pos.x + label_size.x + extra_w + style.ItemSpacing.x;
1769 if (sep1_x2 > sep1_x1 && separator_thickness > 0.0f)
1770 window->DrawList->AddLineH(sep1_x1, sep1_x2, seps_y, separator_col, separator_thickness);
1771 if (sep2_x2 > sep2_x1 && separator_thickness > 0.0f)
1772 window->DrawList->AddLineH(sep2_x1, sep2_x2, seps_y, separator_col, separator_thickness);
1773 if (g.LogEnabled)
1774 LogSetNextTextDecoration("---", NULL);
1775 RenderTextEllipsis(window->DrawList, label_pos, ImVec2(bb.Max.x, bb.Max.y + style.ItemSpacing.y), bb.Max.x, label, label_end, &label_size);
1776 }
1777 else
1778 {
1779 if (g.LogEnabled)
1780 LogText("---");
1781 if (separator_thickness > 0.0f)
1782 window->DrawList->AddLineH(sep1_x1, sep2_x2, seps_y, separator_col, separator_thickness);
1783 }
1784}
1785
1786void ImGui::SeparatorText(const char* label)
1787{

Callers

nothing calls this directly

Calls 6

ImMaxFunction · 0.85
ImTruncFunction · 0.85
ItemSizeFunction · 0.85
AddLineHMethod · 0.80
ImVec2Function · 0.50
GetHeightMethod · 0.45

Tested by

no test coverage detected