Open nem0 opened 3 years ago
Thanks for the report.
The problem is that the ideal offsets for a fully opaque border isn't the same as the ideal offset for zero-alpha/no-border, and in-between those two alpha values we have a tricky continuum.
Here's offsetting the filled shape inward by 0.250
I don't have a magic solution but I suppose we should experiment with this a little more and see if interpolating that offset for the filled shape, based on the border alpha would work well enough.
If you add border size into the equation it may or not make that more tricky.
ImGuiStyle& style = ImGui::GetStyle();
style.FrameRounding = 5.0f;
style.FrameBorderSize = 1.0f;
style.Colors[ImGuiCol_Border] = ImVec4(1.0f, 0.0f, 0.0f, 1.0f);
style.Colors[ImGuiCol_Button] = ImVec4(0.0f, 0.0f, 1.0f, 1.0f);
[...]
style.AntiAliasedFill = style.AntiAliasedLines = io.KeyShift;
ImGui::SliderFloat("FrameRounding", &style.FrameRounding, 0.0f, 7.0f, "%.1f");
ImGui::SliderFloat("FrameBorderSize", &style.FrameBorderSize, 0.0f, 3.0f, "%.1f");
ImGui::ColorEdit4("ImGuiCol_Border", &style.Colors[ImGuiCol_Border].x);
ImGui::ColorEdit4("ImGuiCol_Button", &style.Colors[ImGuiCol_Button].x);
ImGui::Button("this is a button!");
In imgui.cpp:
static ImVec2 OFFSET(0.0f, 0.0f);
// Render a rectangle shaped with optional rounding and borders
void ImGui::RenderFrame(ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, bool border, float rounding)
{
ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
if (g.IO.KeyCtrl)
window->DrawList->AddRectFilled(p_min, p_max, fill_col, rounding);
else
window->DrawList->AddRectFilled(p_min - OFFSET, p_max + OFFSET, fill_col, rounding);
[...]
}
There would be some more things to changes but that gives a basic thing to toy with.
docking branch Compiler: VS2019 Operating System: win10
My Issue/Question:
Steps to reproduce:
Notes:
ImDrawList::AddRect
, removing it fixes leaks, but makes borders uglyScreenshots/Video