mirror of
https://github.com/xemu-project/imgui.git
synced 2024-11-27 12:10:23 +00:00
ColorButton: Fixed rendering color button with a checkerboard if the transparency comes from the global style.Alpha and not from the actual source color.
This commit is contained in:
parent
de72e9cc87
commit
e9ff7162bc
@ -9433,7 +9433,7 @@ bool ImGui::ColorButton(const char* desc_id, const ImVec4& col, ImGuiColorEditFl
|
|||||||
float grid_step = ImMin(size.x, size.y) / 2.99f;
|
float grid_step = ImMin(size.x, size.y) / 2.99f;
|
||||||
float rounding = ImMin(g.Style.FrameRounding, grid_step * 0.5f);
|
float rounding = ImMin(g.Style.FrameRounding, grid_step * 0.5f);
|
||||||
ImRect bb_inner = bb;
|
ImRect bb_inner = bb;
|
||||||
float off = -0.75f; // The border (using Col_FrameBg) tends to look off when color is near-opaque and rounding is enabled. This offset seemed like a good middleground to reduce those artefacts.
|
float off = -0.75f; // The border (using Col_FrameBg) tends to look off when color is near-opaque and rounding is enabled. This offset seemed like a good middle ground to reduce those artifacts.
|
||||||
bb_inner.Expand(off);
|
bb_inner.Expand(off);
|
||||||
if ((flags & ImGuiColorEditFlags_AlphaPreviewHalf) && col.w < 1.0f)
|
if ((flags & ImGuiColorEditFlags_AlphaPreviewHalf) && col.w < 1.0f)
|
||||||
{
|
{
|
||||||
@ -9443,7 +9443,12 @@ bool ImGui::ColorButton(const char* desc_id, const ImVec4& col, ImGuiColorEditFl
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
RenderColorRectWithAlphaCheckerboard(bb_inner.Min, bb_inner.Max, GetColorU32((flags & ImGuiColorEditFlags_AlphaPreview) ? col : col_without_alpha), grid_step, ImVec2(off, off), rounding);
|
// Because GetColorU32() multiplies by the global style Alpha and we don't want to display a checkerboard if the source code had no alpha
|
||||||
|
ImVec4 col_source = (flags & ImGuiColorEditFlags_AlphaPreview) ? col : col_without_alpha;
|
||||||
|
if (col_source.w < 1.0f)
|
||||||
|
RenderColorRectWithAlphaCheckerboard(bb_inner.Min, bb_inner.Max, GetColorU32(col_source), grid_step, ImVec2(off, off), rounding);
|
||||||
|
else
|
||||||
|
window->DrawList->AddRectFilled(bb_inner.Min, bb_inner.Max, GetColorU32(col_source), rounding, ~0);
|
||||||
}
|
}
|
||||||
if (window->Flags & ImGuiWindowFlags_ShowBorders)
|
if (window->Flags & ImGuiWindowFlags_ShowBorders)
|
||||||
RenderFrameBorder(bb.Min, bb.Max, rounding);
|
RenderFrameBorder(bb.Min, bb.Max, rounding);
|
||||||
|
Loading…
Reference in New Issue
Block a user