MCPcopy Create free account
hub / github.com/KebsCS/KBotExt / ButtonEx

Method ButtonEx

KBotExt/imgui/imgui_widgets.cpp:680–719  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 3

GetCurrentWindowFunction · 0.85
ItemSizeFunction · 0.85
GetIDMethod · 0.80

Tested by

no test coverage detected