From a1dfaf4869347b8f639f63cfc2636f2d9d8b20db Mon Sep 17 00:00:00 2001 From: ocornut Date: Wed, 14 Jan 2026 15:54:55 +0100 Subject: [PATCH] ImageButton() doesn't use a clamped style.FrameRounding value but instead adjust inner image rounding when FramePadding > FrameRounding. (#2942, #845) --- docs/CHANGELOG.txt | 2 ++ imgui_widgets.cpp | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 1a732a04d..2cc2d9152 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -170,6 +170,8 @@ Other Changes: - Images: - Added style.ImageRounding, ImGuiStyleVar_ImageRounding to configure rounding of Image() widgets. (#2942, #845) + - ImageButton() doesn't use a clamped style.FrameRounding value but instead + adjust inner image rounding when FramePadding > FrameRounding. (#2942, #845) - Shortcuts: - IsItemHovered() without ImGuiHoveredFlags_AllowWhenBlockedByActiveItem doesn't filter out the signal when activated item is a shortcut remote activation; diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index 1071d3d8c..0a044a97b 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -1178,10 +1178,14 @@ bool ImGui::ImageButtonEx(ImGuiID id, ImTextureRef tex_ref, const ImVec2& image_ // Render const ImU32 col = GetColorU32((held && hovered) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button); RenderNavCursor(bb, id); - RenderFrame(bb.Min, bb.Max, col, true, ImClamp((float)ImMin(padding.x, padding.y), 0.0f, g.Style.FrameRounding)); + RenderFrame(bb.Min, bb.Max, col, true, g.Style.FrameRounding); if (bg_col.w > 0.0f) window->DrawList->AddRectFilled(bb.Min + padding, bb.Max - padding, GetColorU32(bg_col)); - window->DrawList->AddImage(tex_ref, bb.Min + padding, bb.Max - padding, uv0, uv1, GetColorU32(tint_col)); + float image_rounding = ImMax(g.Style.FrameRounding - ImMax(padding.x, padding.y), g.Style.ImageRounding); + if (image_rounding > 0.0f) + window->DrawList->AddImageRounded(tex_ref, bb.Min + padding, bb.Max - padding, uv0, uv1, GetColorU32(tint_col), image_rounding); + else + window->DrawList->AddImage(tex_ref, bb.Min + padding, bb.Max - padding, uv0, uv1, GetColorU32(tint_col)); return pressed; }