Bug 177778

Summary: make it possible to resize resizable annotations
Product: [Applications] okular Reporter: albert <alberthilbert>
Component: generalAssignee: Okular developers <okular-devel>
Status: RESOLVED FIXED    
Severity: wishlist CC: aacid, alessanderbotti, bastianholst, claude.xavier, codestruct, diego.ml, fraph24, g11072813, giecrilj, haxtibal, kan.nokt, matpen, naitreey, navid.htb, nono31393, oliver.sander, rhunger, rikudou__sennin, simonandric5, thebigming, will
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Unspecified   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Patch to add annotation resize feature (intermediate result)

Description albert 2008-12-14 14:59:32 UTC
Version:            (using Devel)
Installed from:    Compiled sources

It's impossible to change the size of inserted stamps.
If you select the stamp tool and click on the document, an Okular stamp, with the right size, is inserted. Now if you change the stamp type (to "departimental", for example) the old size is kept and the new stamp appears ugly and difficult to be read.
Comment 1 Pino Toscano 2008-12-14 15:05:20 UTC
Actually, not an issue of stamps, but of annotations in general.
Comment 2 Pino Toscano 2009-02-07 12:19:56 UTC
*** Bug 183543 has been marked as a duplicate of this bug. ***
Comment 3 Pino Toscano 2010-10-14 21:46:23 UTC
*** Bug 253843 has been marked as a duplicate of this bug. ***
Comment 4 Albert Astals Cid 2012-01-17 22:51:41 UTC
*** Bug 291281 has been marked as a duplicate of this bug. ***
Comment 5 Fabio D'Urso 2013-11-16 18:47:40 UTC
*** Bug 327679 has been marked as a duplicate of this bug. ***
Comment 6 Naitree Zhu 2015-02-11 05:16:33 UTC
Really??? I don't believe after *6 years* it's still unable to resize inline note.
Comment 7 Pinyaka 2015-07-27 18:15:48 UTC
The text boxes don't resize themselves when you modify text either. This is annoying when going from longer text to shorter text, but makes the box useless when going from a shorter to longer annotation as the text is obscured.
Comment 8 sebastian 2015-08-04 14:10:57 UTC
the pop-up notes are big, they hide words, i can't put them between words
Comment 9 sebastian 2015-08-06 14:40:28 UTC
i am working on Kubuntu 14.04LTS with okular version 0.19.3
Comment 10 noric 2015-10-01 09:56:38 UTC
Still not possible to resize/move annotations in Okular 0.20.2.
Comment 11 duncan_mk 2016-03-04 20:48:26 UTC
(In reply to Naitree Zhu from comment #6)
> Really??? I don't believe after *6 years* it's still unable to resize inline
> note.

I'm with you - & it's 7 years now

thebigming
Comment 12 Gregor Mi 2016-03-04 21:51:21 UTC
Time goes by really fast sometimes. :)   What about starting to crowd-fund this issue? See for example http://cffsw.modernthings.org/ which was about translating a Debian handbook.

I wonder if there are examples from the KDE world where specific bugs were resolved by funding a programmer.
Comment 13 Oliver Sander 2016-03-04 22:22:37 UTC
The Berlin office of KDAB got hired several times to implement support for embedded movies in okular.  That worked out very nicely.
Comment 14 Tobias Deiminger 2016-03-04 22:55:29 UTC
Created attachment 97686 [details]
Patch to add annotation resize feature (intermediate result)

As posted to okular-devel on 2016-02-28, I'm currently working on that bug. It's my first work on okular and the changes are not finished for sure. But I'll just add the current diff to show you an intermediate result. Maybe someone can tell me if I'm on the right track. Btw., I'll be back at my computer not before Sunday evening:)

To perform the resize:
-move mouse over a annotation, press ctrl => and a boundary rectangle with resize-handles will show
-left click on one of the handles, keep ctrl pressed, and move mouse to resize the annotation

I've only tested this with inline notes so far.
Comment 15 Albert Astals Cid 2016-03-08 00:02:02 UTC
Please use reviewboard.kde.org for patches
Comment 16 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 314843, 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