MCPcopy Create free account
hub / github.com/KebsCS/KBotExt / SeparatorTextEx

Method SeparatorTextEx

KBotExt/imgui/imgui_widgets.cpp:1470–1518  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1468}
1469
1470void ImGui::SeparatorTextEx(ImGuiID id, const char* label, const char* label_end, float extra_w)
1471{
1472 ImGuiContext& g = *GImGui;
1473 ImGuiWindow* window = g.CurrentWindow;
1474 ImGuiStyle& style = g.Style;
1475
1476 const ImVec2 label_size = CalcTextSize(label, label_end, false);
1477 const ImVec2 pos = window->DC.CursorPos;
1478 const ImVec2 padding = style.SeparatorTextPadding;
1479
1480 const float separator_thickness = style.SeparatorTextBorderSize;
1481 const ImVec2 min_size(label_size.x + extra_w + padding.x * 2.0f, ImMax(label_size.y + padding.y * 2.0f, separator_thickness));
1482 const ImRect bb(pos, ImVec2(window->WorkRect.Max.x, pos.y + min_size.y));
1483 const float text_baseline_y = ImFloor((bb.GetHeight() - label_size.y) * style.SeparatorTextAlign.y + 0.99999f); //ImMax(padding.y, ImFloor((style.SeparatorTextSize - label_size.y) * 0.5f));
1484 ItemSize(min_size, text_baseline_y);
1485 if (!ItemAdd(bb, id))
1486 return;
1487
1488 const float sep1_x1 = pos.x;
1489 const float sep2_x2 = bb.Max.x;
1490 const float seps_y = ImFloor((bb.Min.y + bb.Max.y) * 0.5f + 0.99999f);
1491
1492 const float label_avail_w = ImMax(0.0f, sep2_x2 - sep1_x1 - padding.x * 2.0f);
1493 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
1494
1495 // This allows using SameLine() to position something in the 'extra_w'
1496 window->DC.CursorPosPrevLine.x = label_pos.x + label_size.x;
1497
1498 const ImU32 separator_col = GetColorU32(ImGuiCol_Separator);
1499 if (label_size.x > 0.0f)
1500 {
1501 const float sep1_x2 = label_pos.x - style.ItemSpacing.x;
1502 const float sep2_x1 = label_pos.x + label_size.x + extra_w + style.ItemSpacing.x;
1503 if (sep1_x2 > sep1_x1 && separator_thickness > 0.0f)
1504 window->DrawList->AddLine(ImVec2(sep1_x1, seps_y), ImVec2(sep1_x2, seps_y), separator_col, separator_thickness);
1505 if (sep2_x2 > sep2_x1 && separator_thickness > 0.0f)
1506 window->DrawList->AddLine(ImVec2(sep2_x1, seps_y), ImVec2(sep2_x2, seps_y), separator_col, separator_thickness);
1507 if (g.LogEnabled)
1508 LogSetNextTextDecoration("---", NULL);
1509 RenderTextEllipsis(window->DrawList, label_pos, ImVec2(bb.Max.x, bb.Max.y + style.ItemSpacing.y), bb.Max.x, bb.Max.x, label, label_end, &label_size);
1510 }
1511 else
1512 {
1513 if (g.LogEnabled)
1514 LogText("---");
1515 if (separator_thickness > 0.0f)
1516 window->DrawList->AddLine(ImVec2(sep1_x1, seps_y), ImVec2(sep2_x2, seps_y), separator_col, separator_thickness);
1517 }
1518}
1519
1520void ImGui::SeparatorText(const char* label)
1521{

Callers

nothing calls this directly

Calls 5

ImMaxFunction · 0.85
ImVec2Function · 0.85
ImFloorFunction · 0.85
ItemSizeFunction · 0.85
AddLineMethod · 0.80

Tested by

no test coverage detected