Summary: | Border one pixel off when drawing 'QStyle::PE_Frame' primitive using Breeze style | ||
---|---|---|---|
Product: | [Plasma] Breeze | Reporter: | Michael Weghorn <m.weghorn> |
Component: | QStyle | Assignee: | Unassigned bugs mailing-list <unassigned-bugs> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | m.weghorn, nate |
Priority: | NOR | ||
Version: | 5.17.5 | ||
Target Milestone: | --- | ||
Platform: | Other | ||
OS: | Linux | ||
Latest Commit: | https://invent.kde.org/plasma/breeze/commit/7e678c344b3d931acafe495a1e19d23199aacca7 | Version Fixed In: | 5.21 |
Sentry Crash Report: | |||
Attachments: |
Small sample program
Image created by running the sample program Screenshot of enlarged image (where exact pixels can be seen more easily) |
Description
Michael Weghorn
2020-11-11 13:07:51 UTC
Created attachment 133231 [details]
Image created by running the sample program
Created attachment 133232 [details]
Screenshot of enlarged image (where exact pixels can be seen more easily)
(In reply to Michael Weghorn from comment #0) > From my analysis, > it's a bug in the Breeze theme, I plan to submit a merge request to fix this > soon. -> https://invent.kde.org/plasma/breeze/-/merge_requests/51 Git commit 7e678c344b3d931acafe495a1e19d23199aacca7 by Michael Weghorn. Committed on 11/11/2020 at 13:09. Pushed by ngraham into branch 'master'. Draw frame outline at the outer edge, not a pixel further inside The documentation for 'QPainter::drawRoundedRect' [1] says: "A filled rectangle has a size of rect.size(). A stroked rectangle has a size of rect.size() plus the pen width." Therefore, the frame rect passed to that method needs to be adjusted according to the pen width for the case where the rect is stroked (i.e. an outline exists), and no adjustement is needed when the rect is not stroked so that [size of rect] + [outline width] = [wanted total size] The default pen size is 1 (which is also the value of 'PenWidth::Frame' used to calculate the radius for the outline a few lines further down). For the case that an outline exists, the adjustment of the rect already happens in the call to 'Helper::strokedRect', so there is no need for reducing the rect by one additional pixel on each side, which resulted in the frame border unnecessarily not being right at the inner edge of the rect, but one additional pixel "further inside". It looks like the additional adjustment was originally added by commit 3dbcea7e59cba2ae3afa1a66234502afa7d476d1 ("Changed frame width to 2, to cope with focus rect.", 2014-07-30), later adapted by commit f288c34c3e0f16217538453620f94fb637a20d6c ("Render 2px focused outline *inside* frames rather than outside", 2014-08-11) and commit 2985b4cb6b036a3fcbea6ba6c9fc79eb90f528dc ("use one pixel for focus frame instead of 2", 2014-09-22). While 'Metrics::Frame_FrameWidth' still has the value 2, it is not used here at all, so the default pen width of 1 applies. Therefore, drop the extra adjustment in order for the stroke to be drawn right at the edge of the rect. [1] https://doc.qt.io/qt-5/qpainter.html#drawRoundedRect M +1 -1 kstyle/breezehelper.cpp https://invent.kde.org/plasma/breeze/commit/7e678c344b3d931acafe495a1e19d23199aacca7 |