[Breeze] [Bug 428973] Border one pixel off when drawing 'QStyle::PE_Frame' primitive using Breeze style

Michael Weghorn bugzilla_noreply at kde.org
Wed Nov 11 19:50:42 GMT 2020


https://bugs.kde.org/show_bug.cgi?id=428973

Michael Weghorn <m.weghorn at posteo.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Latest Commit|                            |https://invent.kde.org/plas
                   |                            |ma/breeze/commit/7e678c344b
                   |                            |3d931acafe495a1e19d23199aac
                   |                            |ca7
             Status|REPORTED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #4 from Michael Weghorn <m.weghorn at posteo.de> ---
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

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the Unassigned-bugs mailing list