MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/SPlisHSPlasH / SeparatorEx

Method SeparatorEx

extern/imgui/imgui_widgets.cpp:1399–1466  ·  view source on GitHub ↗

Horizontal/vertical separating line

Source from the content-addressed store, hash-verified

1397
1398// Horizontal/vertical separating line
1399void ImGui::SeparatorEx(ImGuiSeparatorFlags flags)
1400{
1401 ImGuiWindow* window = GetCurrentWindow();
1402 if (window->SkipItems)
1403 return;
1404
1405 ImGuiContext& g = *GImGui;
1406 IM_ASSERT(ImIsPowerOfTwo(flags & (ImGuiSeparatorFlags_Horizontal | ImGuiSeparatorFlags_Vertical))); // Check that only 1 option is selected
1407
1408 float thickness_draw = 1.0f;
1409 float thickness_layout = 0.0f;
1410 if (flags & ImGuiSeparatorFlags_Vertical)
1411 {
1412 // Vertical separator, for menu bars (use current line height). Not exposed because it is misleading and it doesn't have an effect on regular layout.
1413 float y1 = window->DC.CursorPos.y;
1414 float y2 = window->DC.CursorPos.y + window->DC.CurrLineSize.y;
1415 const ImRect bb(ImVec2(window->DC.CursorPos.x, y1), ImVec2(window->DC.CursorPos.x + thickness_draw, y2));
1416 ItemSize(ImVec2(thickness_layout, 0.0f));
1417 if (!ItemAdd(bb, 0))
1418 return;
1419
1420 // Draw
1421 window->DrawList->AddLine(ImVec2(bb.Min.x, bb.Min.y), ImVec2(bb.Min.x, bb.Max.y), GetColorU32(ImGuiCol_Separator));
1422 if (g.LogEnabled)
1423 LogText(" |");
1424 }
1425 else if (flags & ImGuiSeparatorFlags_Horizontal)
1426 {
1427 // Horizontal Separator
1428 float x1 = window->Pos.x;
1429 float x2 = window->Pos.x + window->Size.x;
1430
1431 // FIXME-WORKRECT: old hack (#205) until we decide of consistent behavior with WorkRect/Indent and Separator
1432 if (g.GroupStack.Size > 0 && g.GroupStack.back().WindowID == window->ID)
1433 x1 += window->DC.Indent.x;
1434
1435 // FIXME-WORKRECT: In theory we should simply be using WorkRect.Min.x/Max.x everywhere but it isn't aesthetically what we want,
1436 // need to introduce a variant of WorkRect for that purpose. (#4787)
1437 if (ImGuiTable* table = g.CurrentTable)
1438 {
1439 x1 = table->Columns[table->CurrentColumn].MinX;
1440 x2 = table->Columns[table->CurrentColumn].MaxX;
1441 }
1442
1443 ImGuiOldColumns* columns = (flags & ImGuiSeparatorFlags_SpanAllColumns) ? window->DC.CurrentColumns : NULL;
1444 if (columns)
1445 PushColumnsBackground();
1446
1447 // We don't provide our width to the layout so that it doesn't get feed back into AutoFit
1448 // FIXME: This prevents ->CursorMaxPos based bounding box evaluation from working (e.g. TableEndCell)
1449 const ImRect bb(ImVec2(x1, window->DC.CursorPos.y), ImVec2(x2, window->DC.CursorPos.y + thickness_draw));
1450 ItemSize(ImVec2(0.0f, thickness_layout));
1451 const bool item_visible = ItemAdd(bb, 0);
1452 if (item_visible)
1453 {
1454 // Draw
1455 window->DrawList->AddLine(bb.Min, ImVec2(bb.Max.x, bb.Min.y), GetColorU32(ImGuiCol_Separator));
1456 if (g.LogEnabled)

Callers

nothing calls this directly

Calls 5

GetCurrentWindowFunction · 0.85
ImIsPowerOfTwoFunction · 0.85
ImVec2Function · 0.85
ItemSizeFunction · 0.85
AddLineMethod · 0.80

Tested by

no test coverage detected