Skip to content
Commit 7e678c34 authored by Michael Weghorn's avatar Michael Weghorn
Browse files

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 3dbcea7e
("Changed frame width to 2, to cope with focus rect.",
2014-07-30), later adapted by  commit
f288c34c
("Render 2px focused outline *inside* frames rather than outside",
2014-08-11) and commit 2985b4cb
("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

BUG: 428973
parent c06b43dc
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment