MCPcopy Create free account
hub / github.com/RenderKit/embree / SeparatorEx

Method SeparatorEx

tutorials/common/imgui/imgui_widgets.cpp:1394–1461  ·  view source on GitHub ↗

Horizontal/vertical separating line

Source from the content-addressed store, hash-verified

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