Fix size/alignment of compare view selection rectangle

Authored by huoni on Apr 9 2018, 2:49 AM.

Description

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 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

AFTER

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

Details

Committed
huoniApr 12 2018, 11:22 PM
Reviewer
Gwenview
Differential Revision
D12059: Fix size/alignment of compare view selection rectangle
Parents
R260:ae88b1c87a0c: Merge remote-tracking branch 'origin/Applications/18.04'
Branches
Unknown
Tags
Unknown