| 681 | } |
| 682 | |
| 683 | bool ImGui::ButtonEx(const char* label, const ImVec2& size_arg, ImGuiButtonFlags flags) |
| 684 | { |
| 685 | ImGuiWindow* window = GetCurrentWindow(); |
| 686 | if (window->SkipItems) |
| 687 | return false; |
| 688 | |
| 689 | ImGuiContext& g = *GImGui; |
| 690 | const ImGuiStyle& style = g.Style; |
| 691 | const ImGuiID id = window->GetID(label); |
| 692 | const ImVec2 label_size = CalcTextSize(label, NULL, true); |
| 693 | |
| 694 | ImVec2 pos = window->DC.CursorPos; |
| 695 | if ((flags & ImGuiButtonFlags_AlignTextBaseLine) && style.FramePadding.y < window->DC.CurrLineTextBaseOffset) // 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) |
| 696 | pos.y += window->DC.CurrLineTextBaseOffset - style.FramePadding.y; |
| 697 | ImVec2 size = CalcItemSize(size_arg, label_size.x + style.FramePadding.x * 2.0f, label_size.y + style.FramePadding.y * 2.0f); |
| 698 | |
| 699 | const ImRect bb(pos, pos + size); |
| 700 | ItemSize(size, style.FramePadding.y); |
| 701 | if (!ItemAdd(bb, id)) |
| 702 | return false; |
| 703 | |
| 704 | if (g.LastItemData.InFlags & ImGuiItemFlags_ButtonRepeat) |
| 705 | flags |= ImGuiButtonFlags_Repeat; |
| 706 | |
| 707 | bool hovered, held; |
| 708 | bool pressed = ButtonBehavior(bb, id, &hovered, &held, flags); |
| 709 | |
| 710 | // Render |
| 711 | const ImU32 col = GetColorU32((held && hovered) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button); |
| 712 | RenderNavHighlight(bb, id); |
| 713 | RenderFrame(bb.Min, bb.Max, col, true, style.FrameRounding); |
| 714 | |
| 715 | if (g.LogEnabled) |
| 716 | LogSetNextTextDecoration("[", "]"); |
| 717 | RenderTextClipped(bb.Min + style.FramePadding, bb.Max - style.FramePadding, label, NULL, &label_size, style.ButtonTextAlign, &bb); |
| 718 | |
| 719 | // Automatically close popups |
| 720 | //if (pressed && !(flags & ImGuiButtonFlags_DontClosePopups) && (window->Flags & ImGuiWindowFlags_Popup)) |
| 721 | // CloseCurrentPopup(); |
| 722 | |
| 723 | IMGUI_TEST_ENGINE_ITEM_INFO(id, label, g.LastItemData.StatusFlags); |
| 724 | return pressed; |
| 725 | } |
| 726 | |
| 727 | bool ImGui::Button(const char* label, const ImVec2& size_arg) |
| 728 | { |
nothing calls this directly
no test coverage detected