Skip to content
Commit c2e679a7 authored by Huon Imberger's avatar Huon Imberger
Browse files

Fix size/alignment of compare view selection rectangle

Summary:
There was inconsistency between the rects of:
  - Raster images in Zoom to Fit
  - Raster images in arbitrary zoom
  - SVG images
  - The selection rectangle drawn in DocumentView

This inconsistency was only apparent when drawing the selection rect
in {nav View} compare mode, resulting in it being drawn 1 pixel off at
some zoom levels/modes but not all.

The cause of this inconsistency was due to how the original QRectF of
the image was rounded to a QRect. Calling `QRectF::toRect` takes both
the point and the size into account, meaning the size will be rounded up
or down based on how the point was rounded.
The solution was to keep consistent rounding in `RasterImageView`,
`SvgImageView`, and `DocumentView`. using `QRectF::toRect` in all places
was impossible because `RasterImageView` resizes `mCurrentBuffer`
independently to drawing it at the image offset (point and size rounded
independently). Therefore I've changed everything to match.

In effect, this patch:
  - Makes the selection rect cleaner by drawing it at an integer rect
  - Removes the gap between image and selection rect
  - Fixes any inconsistency in the drawing of the selection rect

BEFORE
{F5801099, size=full}

{F5801100, size=full}

{F5801101, size=full}

{F5801102, size=full}

AFTER
{F5801103, size=full}

{F5801104, size=full}

{F5801105, size=full}

Test Plan:
Open an SVG and raster image in compare mode, and enable solid colour background.
Inspect the selection rect for both types of image, at lots of different zoom levels,
including Zoom to Fit mode, and manually zoomed all the way out.

Reviewers: #gwenview, rkflx

Reviewed By: #gwenview, rkflx

Subscribers: muhlenpfordt

Tags: #gwenview

Differential Revision: https://phabricator.kde.org/D12059
parent ae88b1c8
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