Bug 249364 - PATCH: Fit best (best-fit) zoom
Summary: PATCH: Fit best (best-fit) zoom
Status: RESOLVED FIXED
Alias: None
Product: okular
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR wishlist
Target Milestone: ---
Assignee: Okular developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-29 00:14 UTC by Thomas Fischer
Modified: 2013-08-30 00:56 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 4.12.0


Attachments
Best-fit zoom option, mostly diff against kdegraphics/okular/ui/pageview.cpp (8.25 KB, patch)
2010-08-29 00:14 UTC, Thomas Fischer
Details
Screenshot of the problem (109.63 KB, image/png)
2010-09-04 17:47 UTC, Albert Astals Cid
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Fischer 2010-08-29 00:14:10 UTC
Created attachment 51069 [details]
Best-fit zoom option, mostly diff against kdegraphics/okular/ui/pageview.cpp

Version:           unspecified (using Devel) 
OS:                Linux

I have written a small patch for Okular's ui/pageview.cpp which adds "Fit Best" as one of the zooming options. This new zoom option compares the current page's aspect ratio with the window's aspect ratio and switches effectively between fit-width, fit-height, and fit-page.
The code reuses partially the (no longer) not used "Fit Text" code, adds some new lines, and enhances the infinite resizing loop patch to cover the new zoom option, too.

Reproducible: Always
Comment 1 Albert Astals Cid 2010-09-03 23:52:30 UTC
Thanks for the patch.

Is that 1.25 supposed to be the aspectRatio of the users screen?
Comment 2 Thomas Fischer 2010-09-04 11:22:14 UTC
> Is that 1.25 supposed to be the aspectRatio of the users screen?
No, not directly. The patch first computes the aspect ratios of the page and the aspect ratio of the space available to display the page (as determined by rowHeight and colWidth). Then both aspect ratios are compared by dividing one with another, the result is stored in variable rel. If both aspect ratios are very similar, such as when viewing presentations in a full-screen okular on a 3:4 or 16:9 monitor, rel is somewhere around 1 and the best zoom option would be "fit page" (third case in the following if block). Now, this "very similar" has to be put in a numeric value and this is aspectRatioRelation. Having a value of 1.25, it states that if 0.8<rel<1.25 holds, best "fit page" is the best zoom option. If rel is below 0.8, the page to view is relatively higher than the available space and "fit width" is most appropriate to utilize the space best. "Fit page" would render any text on the page unreadable (assuming I would open an A4 page/portrait with normal 10-12pt text). The same principle holds for rel >1.25 resulting in a "fit height" zoom. Another advantage with best fit is, that in the "page fit" case no scrolling is necessary and the mouse wheel allows to jump between pages (very useful for slide sets), and in the other two cases, only one scroll bar is used making browsing through the document much easier.
I hope this explains the patch...
Comment 3 Albert Astals Cid 2010-09-04 17:47:21 UTC
Ok, so 1.25, 1/1.25 is the aspect ratio boundary where it decides to either go for zoom width/page/page i see, the name of the variable got me a bit lost.

There is a problem with the scrollbar code and i can make it quite easily remove the vertical scrollbar when it should be there. Screenshot attached.
Comment 4 Albert Astals Cid 2010-09-04 17:47:53 UTC
Created attachment 51310 [details]
Screenshot of the problem
Comment 5 Thomas Fischer 2010-09-19 09:39:31 UTC
> There is a problem with the scrollbar code and i can make it quite easily
> remove the vertical scrollbar when it should be there. Screenshot attached.
Haven't found a good solution yet. Could be necessary to rewrite/improve the current code for zooming and scrollbar visibility.
I will continue to look into a simple solution, though...
Comment 6 Albert Astals Cid 2013-03-10 21:37:52 UTC
Any luck?
Comment 7 Thomas Fischer 2013-04-03 18:22:18 UTC
(In reply to comment #6)
> Any luck?
It looks like the problem you observed is related to mixing best-fit and continuous view. Both features mess with the vertical scroll bar. The problem does not appear if you use single-page view.
Comment 8 Thomas Fischer 2013-04-13 17:35:06 UTC
Please try this clone here, it should work better now: git@git.kde.org:clones/okular/thomasfischer/bestfit.git
Comment 9 Albert Astals Cid 2013-04-13 17:37:45 UTC
Can you please use reviewboard to submit patches? It's much easier to comment in there and also to keep track what is waiting, etc.
Comment 10 Thomas Fischer 2013-04-13 19:03:16 UTC
Submitted as review 110003:
https://git.reviewboard.kde.org/r/110003/
Comment 11 Albert Astals Cid 2013-08-18 15:20:43 UTC
Git commit e4aa8317b5d49ad1129e23bda52415ff7dc0a290 by Albert Astals Cid, on behalf of Thomas Fischer.
Committed on 18/08/2013 at 15:19.
Pushed by aacid into branch 'master'.

Auto-fit zoom
REVIEW: 110003

M  +5    -0    conf/dlggeneralbase.ui
M  +1    -1    conf/okular.kcfg
M  +12   -0    doc/index.docbook
M  +2    -1    part.rc
M  +72   -8    ui/pageview.cpp
M  +2    -1    ui/pageview.h

http://commits.kde.org/okular/e4aa8317b5d49ad1129e23bda52415ff7dc0a290
Comment 12 Christoph Feck 2013-08-29 21:07:37 UTC
Albert, Version-Fixed-In == 4.12, or do you want to use the Okular version now?
Comment 13 Albert Astals Cid 2013-08-29 21:21:54 UTC
4.12 or 4.12.0 is both fine