2007-05-04 20:24:12 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* Copyright (C) 2007 by Pino Toscano <pino@kde.org> *
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
***************************************************************************/
|
|
|
|
|
2007-07-15 13:53:26 +00:00
|
|
|
#ifndef OKULAR_ANNOTATIONS_P_H
|
|
|
|
#define OKULAR_ANNOTATIONS_P_H
|
2007-05-04 20:24:12 +00:00
|
|
|
|
|
|
|
#include "area.h"
|
|
|
|
#include "annotations.h"
|
|
|
|
|
|
|
|
// qt/kde includes
|
2018-08-31 09:23:45 +00:00
|
|
|
#include <QDateTime>
|
|
|
|
#include <QString>
|
|
|
|
#include <QVariant>
|
|
|
|
#include <QColor>
|
2007-05-04 20:24:12 +00:00
|
|
|
|
2012-09-08 15:06:02 +00:00
|
|
|
class QTransform;
|
2007-05-04 20:45:45 +00:00
|
|
|
|
2007-05-04 20:24:12 +00:00
|
|
|
namespace Okular {
|
|
|
|
|
2007-07-17 18:10:25 +00:00
|
|
|
class PagePrivate;
|
|
|
|
|
2007-05-04 20:24:12 +00:00
|
|
|
class AnnotationPrivate
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
AnnotationPrivate();
|
|
|
|
|
|
|
|
virtual ~AnnotationPrivate();
|
|
|
|
|
2007-05-04 20:45:45 +00:00
|
|
|
/**
|
|
|
|
* Transforms the annotation coordinates with the transformation
|
|
|
|
* defined by @p matrix.
|
|
|
|
*/
|
2012-09-08 15:06:02 +00:00
|
|
|
void annotationTransform( const QTransform &matrix );
|
2007-07-22 20:49:27 +00:00
|
|
|
|
2012-09-08 15:06:02 +00:00
|
|
|
virtual void transform( const QTransform &matrix );
|
|
|
|
virtual void baseTransform( const QTransform &matrix );
|
2007-07-22 20:49:27 +00:00
|
|
|
virtual void resetTransformation();
|
2007-07-17 18:10:25 +00:00
|
|
|
virtual void translate( const NormalizedPoint &coord );
|
Add annotation resize functionality
Usage:
If you left-click an annotation, it gets selected. Resize handles appear on the selection rectangle. When cursor is moved over one of the 8 resize handles on the corners/edges, the cursor shape changes to indicate resize mode. Everywhere else on the annotation means "move", just as it was before resize feature was added. Pressing ESC or clicking an area outside the annotation cancels a selection. Pressing Del deletes a selected annotation.
Feature is only applicable for annotation types AText, AStamp and AGeom.
Implementation:
It works by eventually changing AnnotationPrivate::m_boundary and notifying generator (i.e. poppler) about that change. Annotation state handling is shifted out of PageView into a new class MouseAnnotation (ui/pageviewmouseannotation.cpp). Some functionality not related to resizing but to annotation interaction in general is also shifted to class MouseAnnotation, to build a single place of responsiblity.
Other changes:
Add method Document::adjustPageAnnotation, backed by a QUndoCommand.
class Okular::AdjustAnnotationCommand.
Add Annotation::adjust and Annotation::canBeResized methods.
Draw resize handles in PagePainter::paintCroppedPageOnPainter.
Resize and move work
-for types AText, AStamp and AGeom
-on all pages of document
-when viewport position changes
-when zoom level changes
-for all page rotations (0°, 90°, 180°, 270°)
Selection is canceled
-when currently selected annotation is deleted
-on mouse click outside of currently selected annotation
-ESC is pressed
Viewport is shifted when mouse cursor during move/resize comes close to viewport border.
Resize to negative is prevented.
Tiny annotations are still selectable.
If mouse is moved over an annotation type that we can focus, and the annotation is not yet focused, mouse cursor shape changes to arrow.
If mouse cursor rests over an annotation A, while annotation B is focused, a tooltip for annotation A is shown.
Selected Annotation is deleted when Del is pressed.
Test for regressions:
-Annotation interaction (focus, move, resize, start playback, ...) are only done in mode EnumMouseMode::Browse.
-If mouse is moved over an annotation type where we can start an action, mouse cursor shape changes to pointing hand.
-If mouse is moved over an annotation type that we can't interact with, mouse cursor shape stays a open hand.
-If mouse cursor rests over an annotation of any type, a tooltip for that annotation is shown.
-Grab/move scroll area (on left click + mouse move) is prevented, if mouse is over focused annotation, or over AMovie/AScreen/AFileAttachment annotation.
-A double click on a annotation starts the "annotator".
REVIEW: 127366
BUG: 177778
BUG: 314843
BUG: 358060
2017-03-19 22:16:06 +00:00
|
|
|
virtual void adjust( const NormalizedPoint & deltaCoord1, const NormalizedPoint & deltaCoord2 );
|
2010-12-27 22:16:11 +00:00
|
|
|
virtual bool openDialogAfterCreation() const;
|
2013-04-05 22:22:48 +00:00
|
|
|
virtual void setAnnotationProperties( const QDomNode& node );
|
Add annotation resize functionality
Usage:
If you left-click an annotation, it gets selected. Resize handles appear on the selection rectangle. When cursor is moved over one of the 8 resize handles on the corners/edges, the cursor shape changes to indicate resize mode. Everywhere else on the annotation means "move", just as it was before resize feature was added. Pressing ESC or clicking an area outside the annotation cancels a selection. Pressing Del deletes a selected annotation.
Feature is only applicable for annotation types AText, AStamp and AGeom.
Implementation:
It works by eventually changing AnnotationPrivate::m_boundary and notifying generator (i.e. poppler) about that change. Annotation state handling is shifted out of PageView into a new class MouseAnnotation (ui/pageviewmouseannotation.cpp). Some functionality not related to resizing but to annotation interaction in general is also shifted to class MouseAnnotation, to build a single place of responsiblity.
Other changes:
Add method Document::adjustPageAnnotation, backed by a QUndoCommand.
class Okular::AdjustAnnotationCommand.
Add Annotation::adjust and Annotation::canBeResized methods.
Draw resize handles in PagePainter::paintCroppedPageOnPainter.
Resize and move work
-for types AText, AStamp and AGeom
-on all pages of document
-when viewport position changes
-when zoom level changes
-for all page rotations (0°, 90°, 180°, 270°)
Selection is canceled
-when currently selected annotation is deleted
-on mouse click outside of currently selected annotation
-ESC is pressed
Viewport is shifted when mouse cursor during move/resize comes close to viewport border.
Resize to negative is prevented.
Tiny annotations are still selectable.
If mouse is moved over an annotation type that we can focus, and the annotation is not yet focused, mouse cursor shape changes to arrow.
If mouse cursor rests over an annotation A, while annotation B is focused, a tooltip for annotation A is shown.
Selected Annotation is deleted when Del is pressed.
Test for regressions:
-Annotation interaction (focus, move, resize, start playback, ...) are only done in mode EnumMouseMode::Browse.
-If mouse is moved over an annotation type where we can start an action, mouse cursor shape changes to pointing hand.
-If mouse is moved over an annotation type that we can't interact with, mouse cursor shape stays a open hand.
-If mouse cursor rests over an annotation of any type, a tooltip for that annotation is shown.
-Grab/move scroll area (on left click + mouse move) is prevented, if mouse is over focused annotation, or over AMovie/AScreen/AFileAttachment annotation.
-A double click on a annotation starts the "annotator".
REVIEW: 127366
BUG: 177778
BUG: 314843
BUG: 358060
2017-03-19 22:16:06 +00:00
|
|
|
virtual bool canBeResized() const;
|
2013-04-05 22:22:48 +00:00
|
|
|
virtual AnnotationPrivate* getNewAnnotationPrivate() = 0;
|
2007-07-17 18:10:25 +00:00
|
|
|
|
2013-06-23 17:19:25 +00:00
|
|
|
/**
|
|
|
|
* Determines the distance of the closest point of the annotation to the
|
|
|
|
* given point @p x @p y @p xScale @p yScale
|
|
|
|
* @since 0.17
|
|
|
|
*/
|
|
|
|
virtual double distanceSqr( double x, double y, double xScale, double yScale );
|
|
|
|
|
2007-07-17 18:10:25 +00:00
|
|
|
PagePrivate * m_page;
|
2007-05-04 20:45:45 +00:00
|
|
|
|
2007-05-04 20:24:12 +00:00
|
|
|
QString m_author;
|
|
|
|
QString m_contents;
|
|
|
|
QString m_uniqueName;
|
|
|
|
QDateTime m_modifyDate;
|
|
|
|
QDateTime m_creationDate;
|
|
|
|
|
|
|
|
int m_flags;
|
|
|
|
NormalizedRect m_boundary;
|
|
|
|
NormalizedRect m_transformedBoundary;
|
|
|
|
|
|
|
|
Okular::Annotation::Style m_style;
|
|
|
|
Okular::Annotation::Window m_window;
|
|
|
|
QLinkedList< Okular::Annotation::Revision > m_revisions;
|
2008-04-13 13:45:32 +00:00
|
|
|
|
|
|
|
Annotation::DisposeDataFunction m_disposeFunc;
|
|
|
|
QVariant m_nativeId;
|
2007-05-04 20:24:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|