|
@@ -1007,28 +1007,23 @@ bool ImGui::ScrollbarEx(const ImRect& bb_frame, ImGuiID id, ImGuiAxis axis, ImS6
|
|
|
return held;
|
|
|
}
|
|
|
|
|
|
-void ImGui::Image(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0, const ImVec2& uv1, const ImVec4& tint_col, const ImVec4& border_col)
|
|
|
+void ImGui::Image(ImTextureID user_texture_id, const ImVec2& image_size, const ImVec2& uv0, const ImVec2& uv1, const ImVec4& tint_col, const ImVec4& border_col)
|
|
|
{
|
|
|
ImGuiWindow* window = GetCurrentWindow();
|
|
|
if (window->SkipItems)
|
|
|
return;
|
|
|
|
|
|
- ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size);
|
|
|
- if (border_col.w > 0.0f)
|
|
|
- bb.Max += ImVec2(2, 2);
|
|
|
+ const float border_size = (border_col.w > 0.0f) ? 1.0f : 0.0f;
|
|
|
+ const ImVec2 padding(border_size, border_size);
|
|
|
+ const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + image_size + padding * 2.0f);
|
|
|
ItemSize(bb);
|
|
|
if (!ItemAdd(bb, 0))
|
|
|
return;
|
|
|
|
|
|
- if (border_col.w > 0.0f)
|
|
|
- {
|
|
|
- window->DrawList->AddRect(bb.Min, bb.Max, GetColorU32(border_col), 0.0f);
|
|
|
- window->DrawList->AddImage(user_texture_id, bb.Min + ImVec2(1, 1), bb.Max - ImVec2(1, 1), uv0, uv1, GetColorU32(tint_col));
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- window->DrawList->AddImage(user_texture_id, bb.Min, bb.Max, uv0, uv1, GetColorU32(tint_col));
|
|
|
- }
|
|
|
+ // Render
|
|
|
+ if (border_size > 0.0f)
|
|
|
+ window->DrawList->AddRect(bb.Min, bb.Max, GetColorU32(border_col), 0.0f, ImDrawFlags_None, border_size);
|
|
|
+ window->DrawList->AddImage(user_texture_id, bb.Min + padding, bb.Max - padding, uv0, uv1, GetColorU32(tint_col));
|
|
|
}
|
|
|
|
|
|
// ImageButton() is flawed as 'id' is always derived from 'texture_id' (see #2464 #1390)
|