Fix annotation positioning when using tiles

Most of the positioning calculations were taking into account the 'crop'
argument (which is a NormalizedRect) to execute some translations.

If not using tiles the value of crop were always the normalized bounding
box of the page, relative to the page itself. So translating by it is
essentially a noop.

When using tiles this argument represents the normalized viewport,
relative to the page. Although useful for the tiles manager, translating
by 'crop' is not necessary for any of those operations.
remotes/origin/KDE/4.10
Mailson Menezes 14 years ago
parent 62d85380af
commit 3f1a186d0a
  1. 18
      ui/pagepainter.cpp

@ -128,10 +128,11 @@ void PagePainter::paintCroppedPageOnPainter( QPainter * destPainter, const Okula
if ( canDrawHighlights || canDrawTextSelection || canDrawAnnotations )
{
// precalc normalized 'limits rect' for intersection
double nXMin = ( (double)limits.left() / (double)scaledWidth ) + crop.left,
nXMax = ( (double)limits.right() / (double)scaledWidth ) + crop.left,
nYMin = ( (double)limits.top() / (double)scaledHeight ) + crop.top,
nYMax = ( (double)limits.bottom() / (double)scaledHeight ) + crop.top;
double nXMin = ( (double)limits.left() / (double)scaledWidth ),
nXMax = ( (double)limits.right() / (double)scaledWidth ),
nYMin = ( (double)limits.top() / (double)scaledHeight ),
nYMax = ( (double)limits.bottom() / (double)scaledHeight );
// append all highlights inside limits to their list
if ( canDrawHighlights )
{
@ -380,7 +381,7 @@ void PagePainter::paintCroppedPageOnPainter( QPainter * destPainter, const Okula
{
const Okular::NormalizedRect & r = (*hIt).second;
// find out the rect to highlight on pixmap
QRect highlightRect = r.geometry( scaledWidth, scaledHeight ).translated( -scaledCrop.topLeft() ).intersect( limits );
QRect highlightRect = r.geometry( scaledWidth, scaledHeight ).intersect( limits );
highlightRect.translate( -limits.left(), -limits.top() );
// highlight composition (product: highlight color * destcolor)
@ -667,7 +668,7 @@ void PagePainter::paintCroppedPageOnPainter( QPainter * destPainter, const Okula
acolor.setAlpha( opacity );
// get annotation boundary and drawn rect
QRect annotBoundary = a->transformedBoundingRectangle().geometry( scaledWidth, scaledHeight ).translated( -scaledCrop.topLeft() );
QRect annotBoundary = a->transformedBoundingRectangle().geometry( scaledWidth, scaledHeight );
QRect annotRect = annotBoundary.intersect( limits );
QRect innerRect( annotRect.left() - annotBoundary.left(), annotRect.top() -
annotBoundary.top(), annotRect.width(), annotRect.height() );
@ -791,7 +792,7 @@ void PagePainter::paintCroppedPageOnPainter( QPainter * destPainter, const Okula
if ( boundingRectOnlyAnn )
{
QRect annotBoundary = boundingRectOnlyAnn->transformedBoundingRectangle().geometry( scaledWidth, scaledHeight ).translated( -scaledCrop.topLeft() );
QRect annotBoundary = boundingRectOnlyAnn->transformedBoundingRectangle().geometry( scaledWidth, scaledHeight );
mixedPainter->setPen( Qt::DashLine );
mixedPainter->drawRect( annotBoundary );
}
@ -801,7 +802,6 @@ void PagePainter::paintCroppedPageOnPainter( QPainter * destPainter, const Okula
{
mixedPainter->save();
mixedPainter->scale( scaledWidth, scaledHeight );
mixedPainter->translate( -crop.left, -crop.top );
QColor normalColor = QApplication::palette().color( QPalette::Active, QPalette::Highlight );
// enlarging limits for intersection is like growing the 'rectGeometry' below
@ -815,7 +815,7 @@ void PagePainter::paintCroppedPageOnPainter( QPainter * destPainter, const Okula
if ( (enhanceLinks && rect->objectType() == Okular::ObjectRect::Action) ||
(enhanceImages && rect->objectType() == Okular::ObjectRect::Image) )
{
if ( limitsEnlarged.intersects( rect->boundingRect( scaledWidth, scaledHeight ).translated( -scaledCrop.topLeft() ) ) )
if ( limitsEnlarged.intersects( rect->boundingRect( scaledWidth, scaledHeight ) ) )
{
mixedPainter->strokePath( rect->region(), QPen( normalColor ) );
}

Loading…
Cancel
Save