| 524 | } |
| 525 | |
| 526 | bool ImGui::ButtonEx(const char* label, const ImVec2& size_arg, ImGuiButtonFlags flags) |
| 527 | { |
| 528 | ImGuiWindow* window = GetCurrentWindow(); |
| 529 | if (window->SkipItems) |
| 530 | return false; |
| 531 | |
| 532 | ImGuiContext& g = *GImGui; |
| 533 | const ImGuiStyle& style = g.Style; |
| 534 | const ImGuiID id = window->GetID(label); |
| 535 | const ImVec2 label_size = CalcTextSize(label, NULL, true); |
| 536 | |
| 537 | ImVec2 pos = window->DC.CursorPos; |
| 538 | if ((flags & ImGuiButtonFlags_AlignTextBaseLine) && style.FramePadding.y < window->DC.CurrentLineTextBaseOffset) // Try to vertically align buttons that are smaller/have no padding so that text baseline matches (bit hacky, since it shouldn't be a flag) |
| 539 | pos.y += window->DC.CurrentLineTextBaseOffset - style.FramePadding.y; |
| 540 | ImVec2 size = CalcItemSize(size_arg, label_size.x + style.FramePadding.x * 2.0f, label_size.y + style.FramePadding.y * 2.0f); |
| 541 | |
| 542 | const ImRect bb(pos, pos + size); |
| 543 | ItemSize(bb, style.FramePadding.y); |
| 544 | if (!ItemAdd(bb, id)) |
| 545 | return false; |
| 546 | |
| 547 | if (window->DC.ItemFlags & ImGuiItemFlags_ButtonRepeat) |
| 548 | flags |= ImGuiButtonFlags_Repeat; |
| 549 | bool hovered, held; |
| 550 | bool pressed = ButtonBehavior(bb, id, &hovered, &held, flags); |
| 551 | if (pressed) |
| 552 | MarkItemEdited(id); |
| 553 | |
| 554 | // Render |
| 555 | const ImU32 col = GetColorU32((held && hovered) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button); |
| 556 | RenderNavHighlight(bb, id); |
| 557 | RenderFrame(bb.Min, bb.Max, col, true, style.FrameRounding); |
| 558 | RenderTextClipped(bb.Min + style.FramePadding, bb.Max - style.FramePadding, label, NULL, &label_size, style.ButtonTextAlign, &bb); |
| 559 | |
| 560 | // Automatically close popups |
| 561 | //if (pressed && !(flags & ImGuiButtonFlags_DontClosePopups) && (window->Flags & ImGuiWindowFlags_Popup)) |
| 562 | // CloseCurrentPopup(); |
| 563 | |
| 564 | return pressed; |
| 565 | } |
| 566 | |
| 567 | bool ImGui::Button(const char* label, const ImVec2& size_arg) |
| 568 | { |
nothing calls this directly
no test coverage detected