Fix glitches around TextInput & ComboBox controls after scrolling on scaled displays (#13805)

Update StaticBox.cpp

Co-authored-by: SoftFever <softfeverever@gmail.com>
This commit is contained in:
yw4z
2026-05-23 06:24:12 +03:00
committed by GitHub
parent f717b46435
commit 8eb82703ac

View File

@@ -193,20 +193,18 @@ void StaticBox::doRender(wxDC& dc)
if ((border_width && border_color.count() > 0) || background_color.count() > 0) { if ((border_width && border_color.count() > 0) || background_color.count() > 0) {
wxRect rc(0, 0, size.x, size.y); wxRect rc(0, 0, size.x, size.y);
if (border_width && border_color.count() > 0) { if (border_width && border_color.count() > 0) {
if (dc.GetContentScaleFactor() == 1.0) { const double scale = dc.GetContentScaleFactor();
int d = floor(border_width / 2.0);
int d2 = floor(border_width - 1); // Snap rect edges to physical pixel boundaries so the 1px pen doesn't straddle a pixel boundary
rc.x += d; auto snap = [&](int logical) -> int {
rc.width -= d2; return (int)(ceil(logical * scale) / scale);
rc.y += d; };
rc.height -= d2;
} else { int deflate = snap(border_width / 2.0); // at 175%: snap(0.5) = snap→1/1.75 ≈ 1
int d = 1; rc.x += deflate;
rc.x += d; rc.y += deflate;
rc.width -= d; rc.width -= deflate * 2;
rc.y += d; rc.height -= deflate * 2;
rc.height -= d;
}
dc.SetPen(wxPen(border_color.colorForStates(states), border_width, border_style)); dc.SetPen(wxPen(border_color.colorForStates(states), border_width, border_style));
} else { } else {
dc.SetPen(wxPen(background_color.colorForStates(states))); dc.SetPen(wxPen(background_color.colorForStates(states)));