[Okular-devel] Patch for "best fit" zoom

Thomas Fischer fischer at unix-ag.uni-kl.de
Mon Jan 18 13:18:28 CET 2010


Hello,

as a regular Okular user, I have an itch that I was scratching: I was 
looking for a zoom setting that is appropriate both for viewing 
presentations (in non-fullscreen mode) and text documents (portrait 
format).
I came up with a "best fit" zoom level which corresponds to the existing 
"fit width" and "fit page" zoom levels.
The best-fit setting compares the aspect ratios of the document and the 
viewing area it is shown in. If the aspect ratios nearly match, a page 
will be shown in "fit page" mode. This is useful e.g. for presentations, 
where a slide has a similar aspect ratio like the screen. If the aspect 
ratio is very different, such as in cases with portrait text documents, 
the document is scaled to "fit width" and you only have to scroll 
vertically. If the document is much wider, it is scaled to fit the 
height and you scroll horizontally only.

The attached patch introduces this feature while being just below 7k in 
size. Additionally, I removed/replaced some "fit text" zoom which seemed 
to be dead code. The patch is for KDE 4.3.4, but it should be no problem 
apply it to the upcoming 4.4 or trunk.

However, there is one major bug in my patch. If the ratio between aspect 
ratios is very close to switching between either of the three zooming 
modes, Okular may continuously switch between two modes. This seems to 
happen as Okular shows scrollbars if necessary, which change the view 
area's size (and this aspect), which in turn triggers the change in 
mode. As this new mode does not need scrollbars, they get disabled again 
and the circle closes. I have not yet found a nice and clean solution 
here.

Comments are welcome.

Bye,
Thomas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kdegraphics-4.3.4-okular-fitbest.patch
Type: text/x-patch
Size: 6947 bytes
Desc: not available
Url : http://mail.kde.org/pipermail/okular-devel/attachments/20100118/c45afe7d/attachment-0001.patch 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
Url : http://mail.kde.org/pipermail/okular-devel/attachments/20100118/c45afe7d/attachment-0001.sig 


More information about the Okular-devel mailing list