Commit Graph

4 Commits

Author SHA1 Message Date
Sebastian Ramacher
403d867ca4 Some CS
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
2013-11-05 02:23:52 +01:00
Abdo Roig-Maranges
030a8c65c1 add functions to compute page positions
The plan is to put in adjustment.c every piece of code that has to do
with document positioning, either computing it from data on the document
side, or talking to GTK.

We want to have at our disposal functions to compute sizes and positions
without having to ask for it to a GTK widget. The new functions are:

 - move page_calc_height_width to adjustment.c

 - add page_calc_position that rotates a position relative to a page
   according to the rotation settings.

 - add position_to_page_number that computes the number of a page
   sitting at a given position (given in document-relative coordinates)

 - add page_number_to_position that computes the position (in document
   relative coordinates) that will be placed at the center of the viewport.

 - add page_is_visible that checks whether the given page intersects the
   viewport.
2013-10-26 17:13:55 +02:00
Sebastian Ramacher
9c1503809a CS
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
2013-03-23 16:12:38 +01:00
Benoît Knecht
c9eef95492 Use signals to readjust_view_after_zooming()
Instead of guesstimating the values of the scrollbars adjustments after
a change in zoom level, connect callbacks to the "changed" GtkAdjustment
event (which is emitted when the bounds or page_size of the adjustment
change, e.g. when the zoom level changes), and compute the new values
from there.

The previous adjustment values are tracked in zathura->ui.hadjustment
and zathura->ui.vadjustment (and updated by signal handlers as well), so
that the view's position can be maintained while zooming.

cb_view_hadjustment_changed() centers the page horizontally if a
"best-fit" or "width" zoom is being performed, or if "zoom-center" is
true; otherwise, it keeps the view horizontally centered around the same
area of the page.

cb_view_vadjustment_changed() always keeps the view vertically centered
around the same area of the page.

Many thanks to Marwan Tanager for thoroughly reviewing the various
stages of this patch, and actually coming up with a working solution.

Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
2013-03-23 16:02:56 +01:00