MCPcopy Create free account
hub / github.com/clementgallet/libTAS / ButtonEx

Method ButtonEx

src/external/imgui/imgui_widgets.cpp:682–721  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 3

GetCurrentWindowFunction · 0.85
ItemSizeFunction · 0.85
GetIDMethod · 0.80

Tested by

no test coverage detected