From 922a15328e84cb34aad694b36adfa5d1c9d2d67d Mon Sep 17 00:00:00 2001 From: Alex Shvartzkop Date: Fri, 16 Feb 2024 00:58:56 +0300 Subject: [PATCH 1/2] Limit rounded rectangle radius in graphics path. --- src/common/graphcmn.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/common/graphcmn.cpp b/src/common/graphcmn.cpp index 8c74fa3727..0d3d777601 100644 --- a/src/common/graphcmn.cpp +++ b/src/common/graphcmn.cpp @@ -436,6 +436,9 @@ void wxGraphicsPathData::AddRoundedRectangle( wxDouble x, wxDouble y, wxDouble w AddRectangle(x,y,w,h); else { + wxDouble maxR = std::min(w, h) / 2.0; + if ( radius > maxR ) radius = maxR; + MoveToPoint(x+w, y+h/2); AddArc(x+w-radius, y+h-radius, radius, 0.0, M_PI/2.0, true); AddArc(x+radius, y+h-radius, radius, M_PI/2.0, M_PI, true); From 1b7727d05823532d5324d857a65434c5ffbfc377 Mon Sep 17 00:00:00 2001 From: Alex Shvartzkop Date: Fri, 16 Feb 2024 01:18:15 +0300 Subject: [PATCH 2/2] Limit rounded rectangle radius in GTK wxWindowDCImpl. --- src/gtk/dcclient.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gtk/dcclient.cpp b/src/gtk/dcclient.cpp index f02997977d..d0ff97cd49 100644 --- a/src/gtk/dcclient.cpp +++ b/src/gtk/dcclient.cpp @@ -864,6 +864,9 @@ void wxWindowDCImpl::DoDrawRoundedRectangle( wxCoord x, wxCoord y, wxCoord width if (radius < 0.0) radius = - radius * ((width < height) ? width : height); + wxDouble maxR = std::min(width, height) / 2.0; + if ( radius > maxR ) radius = maxR; + wxCoord xx = XLOG2DEV(x); wxCoord yy = YLOG2DEV(y); wxCoord ww = m_signX * XLOG2DEVREL(width);