Horizontal/vertical separating line
| 1249 | |
| 1250 | // Horizontal/vertical separating line |
| 1251 | void ImGui::SeparatorEx(ImGuiSeparatorFlags flags) |
| 1252 | { |
| 1253 | ImGuiWindow* window = GetCurrentWindow(); |
| 1254 | if (window->SkipItems) |
| 1255 | return; |
| 1256 | |
| 1257 | ImGuiContext& g = *GImGui; |
| 1258 | IM_ASSERT(ImIsPowerOfTwo(flags & (ImGuiSeparatorFlags_Horizontal | ImGuiSeparatorFlags_Vertical))); // Check that only 1 option is selected |
| 1259 | |
| 1260 | float thickness_draw = 1.0f; |
| 1261 | float thickness_layout = 0.0f; |
| 1262 | if (flags & ImGuiSeparatorFlags_Vertical) |
| 1263 | { |
| 1264 | // 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. |
| 1265 | float y1 = window->DC.CursorPos.y; |
| 1266 | float y2 = window->DC.CursorPos.y + window->DC.CurrLineSize.y; |
| 1267 | const ImRect bb(ImVec2(window->DC.CursorPos.x, y1), ImVec2(window->DC.CursorPos.x + thickness_draw, y2)); |
| 1268 | ItemSize(ImVec2(thickness_layout, 0.0f)); |
| 1269 | if (!ItemAdd(bb, 0)) |
| 1270 | return; |
| 1271 | |
| 1272 | // Draw |
| 1273 | window->DrawList->AddLine(ImVec2(bb.Min.x, bb.Min.y), ImVec2(bb.Min.x, bb.Max.y), GetColorU32(ImGuiCol_Separator)); |
| 1274 | if (g.LogEnabled) |
| 1275 | LogText(" |"); |
| 1276 | } |
| 1277 | else if (flags & ImGuiSeparatorFlags_Horizontal) |
| 1278 | { |
| 1279 | // Horizontal Separator |
| 1280 | float x1 = window->Pos.x; |
| 1281 | float x2 = window->Pos.x + window->Size.x; |
| 1282 | if (!window->DC.GroupStack.empty()) |
| 1283 | x1 += window->DC.Indent.x; |
| 1284 | |
| 1285 | ImGuiColumns* columns = (flags & ImGuiSeparatorFlags_SpanAllColumns) ? window->DC.CurrentColumns : NULL; |
| 1286 | if (columns) |
| 1287 | PushColumnsBackground(); |
| 1288 | |
| 1289 | // We don't provide our width to the layout so that it doesn't get feed back into AutoFit |
| 1290 | const ImRect bb(ImVec2(x1, window->DC.CursorPos.y), ImVec2(x2, window->DC.CursorPos.y + thickness_draw)); |
| 1291 | ItemSize(ImVec2(0.0f, thickness_layout)); |
| 1292 | const bool item_visible = ItemAdd(bb, 0); |
| 1293 | if (item_visible) |
| 1294 | { |
| 1295 | // Draw |
| 1296 | window->DrawList->AddLine(bb.Min, ImVec2(bb.Max.x, bb.Min.y), GetColorU32(ImGuiCol_Separator)); |
| 1297 | if (g.LogEnabled) |
| 1298 | LogRenderedText(&bb.Min, "--------------------------------"); |
| 1299 | } |
| 1300 | if (columns) |
| 1301 | { |
| 1302 | PopColumnsBackground(); |
| 1303 | columns->LineMinY = window->DC.CursorPos.y; |
| 1304 | } |
| 1305 | } |
| 1306 | } |
| 1307 | |
| 1308 | void ImGui::Separator() |
nothing calls this directly
no test coverage detected