Bug 314843 - Allow resizing of "stamp" annotations
Summary: Allow resizing of "stamp" annotations
Status: RESOLVED FIXED
Alias: None
Product: okular
Classification: Applications
Component: general (show other bugs)
Version: 0.19.60
Platform: openSUSE Linux
: NOR wishlist
Target Milestone: ---
Assignee: Okular developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-02-10 18:55 UTC by madworm_de.kde
Modified: 2017-03-19 22:18 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
image showing bad scaling ratio (29.83 KB, image/jpeg)
2013-02-10 18:57 UTC, madworm_de.kde
Details

Note You need to log in before you can comment on or make changes to this bug.
Description madworm_de.kde 2013-02-10 18:55:11 UTC
When selecting an image for a stamp (approved, rejected...), there is a drastic difference between the image preview and what ends up in the document. The image in the document is pretty ruined, as the original H/W ratio is not preserved.

Reproducible: Always

Actual Results:  
H/W ratio of stamp images altered significantly.

Expected Results:  
Keep H/W ratio of stamp images.
Comment 1 madworm_de.kde 2013-02-10 18:57:06 UTC
Created attachment 77099 [details]
image showing bad scaling ratio
Comment 2 Albert Astals Cid 2013-02-10 21:18:38 UTC
Click and drag to set the size of the stamp when creating it.

Yes we miss a resizing facility after it has been created, if you want you can rename your bug to say that, otherwise there's not much to be fixed here.
Comment 3 madworm_de.kde 2013-02-10 21:27:52 UTC
Hmmm...

So here's what I see.

When applying a stamp somewhere I can indeed draw a frame which determines the size and shape of the stamp. Every time I do this I get a preview of the stamp tied to the mouse cursor - nice. However this is always the same image (okular icon). I can later change the stamp image, but the shape (H/W ratio) is fixed. And as I only see the okular icon preview, there's no way to guess what the H/W ratio of the stamp is that I would like. If I could see the preview of the stamp that I really like, I could adjust for the H/W ratio while drawing the box.

Long story short, there should be a way to select the stamp image before drawing the box. That way the user could take care of the image shape himself, as he knows beforehand what it should look like. No pressing need to resize it later.
Comment 4 Luigi Toscano 2014-05-08 13:44:40 UTC
If you frequently use the same stamp you can define a custom annotation in the bar for it; otherwise the easiest way, as Albert suggested, would be to allow the resizing of the stamp after creation. Moving as wishlist, changing the title.
Comment 5 Gregor Mi 2014-12-18 11:12:54 UTC
see also https://bugs.kde.org/show_bug.cgi?id=177778
Comment 6 Albert Astals Cid 2017-03-19 22:18:35 UTC
Git commit 0957abc39ad0597140b068b6f083371df84acf16 by Albert Astals Cid, on behalf of Tobias Deiminger.
Committed on 19/03/2017 at 22:18.
Pushed by aacid into branch 'master'.

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
Related: bug 177778, bug 358060

M  +1    -0    CMakeLists.txt
M  +58   -2    core/annotations.cpp
M  +16   -1    core/annotations.h
M  +2    -0    core/annotations_p.h
M  +13   -6    core/document.cpp
M  +14   -1    core/document.h
M  +2    -2    core/document_p.h
M  +65   -0    core/documentcommands.cpp
M  +26   -0    core/documentcommands_p.h
M  +1    -1    generators/poppler/annots.cpp
M  +5    -2    ui/pagepainter.cpp
M  +76   -189  ui/pageview.cpp
A  +714  -0    ui/pageviewmouseannotation.cpp     [License: GPL (v2+)]
A  +164  -0    ui/pageviewmouseannotation.h     [License: GPL (v2+)]

https://commits.kde.org/okular/0957abc39ad0597140b068b6f083371df84acf16