0
0
mirror of https://github.com/ocornut/imgui.git synced 2026-01-18 17:11:23 +01:00

ImageButton() doesn't use a clamped style.FrameRounding value but instead adjust inner image rounding when FramePadding > FrameRounding. (#2942, #845)

This commit is contained in:
ocornut
2026-01-14 15:54:55 +01:00
parent 7143d711bf
commit a1dfaf4869
2 changed files with 8 additions and 2 deletions

View File

@@ -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;

View File

@@ -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;
}