View Single Post
Old 05-16-2010, 09:31 AM   #1
pollito pito
i warned you ...
pollito pito doesn't litterpollito pito doesn't litterpollito pito doesn't litter
 
pollito pito's Avatar
 
Posts: 54
Karma: 222
Join Date: Apr 2010
Device: none
Two facing pages in the viewer …solved!!

Ok guys, here is a solution for those of you that use the calibre viewer as reader
and want to use the whole landscape screen for displaying two pages:

1-Make a backup copy of the read-only “images.js” file on your folder
\Calibre2\resources\viewer\
2-Extract into that folder the attached “images.js”.
3-Start the wiewer.
3-To move left / right use the arrow keys on the keyboard.

There are two limitations:
1-It will not “remember” the last viewed pages, just the last viewed chapter. I did not
find a way of updating the “calibre_current_page_bookmark”. If someone could tell
me what function I have to call or provide some idea, I could try to implement it.
2-All the calculations are in px, so it may not scale well. If there is interest I could try to
convert them to em.


For the not initiated ones some background:

Modern PC screens are not tall; they are wide, therefore scrolling to the side
is much more natural that scrolling down: an small fact that seems to be
ignored by most web developers. Have you seen Google fast flip? They
almost got it right; you are supposed to key left or right, but the page they serve
is taller that the viewing area .
Now, calibre viewer is supposed to be just a simple reader, however it is such
a good piece of software that it is simply a pity not to use it as a Reader.
Unfortunately if you used it in full screen you end up with impossibly long rows,
very uncomfortable for reading. Of course, one can set the viewer size in such a
way that it would produce pages of reasonable width, but then you have all sort
of disturbing elements from desktop and what not. (There was even a request some
days ago for a way of dimming everything but the viewer reading area.) Besides,
the waste of horizontal space.
A compromise could be to show two facing pages and use the viewer in full screen
mode. But how to make it happen? You see, to request “officially” such a feature would
mean to potentially divert valuable developer’s time to something that, I am sure,
not very many are going to use. So I decided to give it a try myself.
The starting point of my quest was an article (and script) by Cédric Savarese:

http://www.alistapart.com/articles/css3multicolumn/

From there I came to Peter Craddock site. He has a tutorial on building
a book look-alike page, that was extremely useful. But he is also a writer,
and after seeing some of his writings here:

http://www.arpia.be/2010/04/an-opening-scene/#

I thought: wow! that is what I want to have in the calibre viewer.
Yet, after a lot of experimenting I had to drop both approaches. They are (at least for me )
very difficult to implement.
So, I went on and found a jQuery Plugin called ‘js-columns’ by Kenneth Kufluk.
After some minor changes and the addition of a couple of lines of code, I managed
to have it working in the viewer. There are two problems, though: The response to the
paging (page changing) is very slow because of the workings of the script, but more
important, it would not work in several of my books.
Then I decided to restart with the very first idea: To use the build in multi column module.
That’s how I came to this solution. The logic is the following:
1-Apply a temporary single-column style to the document, forcing the width to the one
each of the facing pages is going to have in the final layout.
2-Calculate the doc length and the number of pages it will have and the amount to
jump-scroll left or right.
3-Apply a two column style.
4-Trap the left or right arrow keys and jump-scroll the doc to the next/previous two pages.

Here is also the user style sheet I’m using:

body {
color:rgb(0,0,0) !important;
background-color:rgb(235,235,235);
text-align:justify;
//set the font-size to 24px in the GUI General tab
//font-size:24px !important;
text-indent: 2em;
}


Sorry for the long post.
Attached Files
File Type: zip images_v02.zip (1.5 KB, 1023 views)
pollito pito is offline   Reply With Quote