mirror of
https://invent.kde.org/graphics/okular
synced 2024-08-27 11:40:07 +00:00
Fix viewport transition when translating/resizing annotations
Viewport isn't centered on annotations when translating/resizing. This is best seen if the page is zoomed in and annotation is translated so that several viewport transitions had happened. Using undo after translation will expose error. Function moveViewportIfBoundingRectNotFullyVisible centers viewport based on translated/resized annotation's bounding rectangle. For that reason functions translateBoundingRectangle/adjustBoundingRectangle need to return the same bounding rectangle as annotation's translate/adjust functions.
This commit is contained in:
parent
04059bae4b
commit
69a2cc144f
|
@ -233,12 +233,12 @@ Okular::NormalizedPoint TranslateAnnotationCommand::minusDelta()
|
||||||
Okular::NormalizedRect TranslateAnnotationCommand::translateBoundingRectangle(const Okular::NormalizedPoint &delta)
|
Okular::NormalizedRect TranslateAnnotationCommand::translateBoundingRectangle(const Okular::NormalizedPoint &delta)
|
||||||
{
|
{
|
||||||
Okular::NormalizedRect annotBoundingRect = m_annotation->boundingRectangle();
|
Okular::NormalizedRect annotBoundingRect = m_annotation->boundingRectangle();
|
||||||
double left = qMin<double>(annotBoundingRect.left, annotBoundingRect.left + delta.x);
|
annotBoundingRect.left = annotBoundingRect.left + delta.x;
|
||||||
double right = qMax<double>(annotBoundingRect.right, annotBoundingRect.right + delta.x);
|
annotBoundingRect.right = annotBoundingRect.right + delta.x;
|
||||||
double top = qMin<double>(annotBoundingRect.top, annotBoundingRect.top + delta.y);
|
annotBoundingRect.top = annotBoundingRect.top + delta.y;
|
||||||
double bottom = qMax<double>(annotBoundingRect.bottom, annotBoundingRect.bottom + delta.y);
|
annotBoundingRect.bottom = annotBoundingRect.bottom + delta.y;
|
||||||
Okular::NormalizedRect boundingRect(left, top, right, bottom);
|
|
||||||
return boundingRect;
|
return annotBoundingRect;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TranslateAnnotationCommand::refreshInternalPageReferences(const QVector<Page *> &newPagesVector)
|
bool TranslateAnnotationCommand::refreshInternalPageReferences(const QVector<Page *> &newPagesVector)
|
||||||
|
@ -303,12 +303,13 @@ bool AdjustAnnotationCommand::mergeWith(const QUndoCommand *uc)
|
||||||
|
|
||||||
Okular::NormalizedRect AdjustAnnotationCommand::adjustBoundingRectangle(const Okular::NormalizedPoint &delta1, const Okular::NormalizedPoint &delta2)
|
Okular::NormalizedRect AdjustAnnotationCommand::adjustBoundingRectangle(const Okular::NormalizedPoint &delta1, const Okular::NormalizedPoint &delta2)
|
||||||
{
|
{
|
||||||
const Okular::NormalizedRect annotBoundingRect = m_annotation->boundingRectangle();
|
Okular::NormalizedRect annotBoundingRect = m_annotation->boundingRectangle();
|
||||||
const double left = qMin<double>(annotBoundingRect.left, annotBoundingRect.left + delta1.x);
|
annotBoundingRect.left = annotBoundingRect.left + delta1.x;
|
||||||
const double right = qMax<double>(annotBoundingRect.right, annotBoundingRect.right + delta2.x);
|
annotBoundingRect.right = annotBoundingRect.right + delta2.x;
|
||||||
const double top = qMin<double>(annotBoundingRect.top, annotBoundingRect.top + delta1.y);
|
annotBoundingRect.top = annotBoundingRect.top + delta1.y;
|
||||||
const double bottom = qMax<double>(annotBoundingRect.bottom, annotBoundingRect.bottom + delta2.y);
|
annotBoundingRect.bottom = annotBoundingRect.bottom + delta2.y;
|
||||||
return Okular::NormalizedRect(left, top, right, bottom);
|
|
||||||
|
return annotBoundingRect;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AdjustAnnotationCommand::refreshInternalPageReferences(const QVector<Page *> &newPagesVector)
|
bool AdjustAnnotationCommand::refreshInternalPageReferences(const QVector<Page *> &newPagesVector)
|
||||||
|
|
Loading…
Reference in a new issue