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.
now accepts a document object and explicit width and height. This will
make it easier to reuse this function for computing the document page
cell width and height.
This patch adds a new configuration setting, selection-clipboard, which allows
us to choose between the PRIMARY selection, and the CLIPBOARD selection, for
determining which X clipboard to use for storing mouse-selected data. It has
only two valid values: "primary" and "clipboard", with "clipboard" being set as
the it's default value.
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
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>
zathura_get_document_size computes the size of the document to be
displayed (in pixels), given the size of the individual cells. It takes
padding between the cells into account.
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
1) zoom-center :: bool
zoom-center = false
If zoom-center = false nothing changes.
If zoom-center = true zooming respects the horizontal center of the
pageview. That is, the vertical line dividing the displayed part of
the document doesn't move within the document.
Reasoning: When viewing a pdf with a margin we usually want to hide the
margin at both sides by zooming in.
2) scroll-hstep :: float
scroll-hstep = -1
If scroll-hstep < 0 nothing changes.
If scroll-hstep >= 0 then scroll-hstep defines the scroll step in the
horizontal direction.
Reasoning: This allows us to make finer adjustments in the horizontal
direction without the mouse and without loosing the ablility to
navigate quickly through the document.
3) search-hadjust :: bool
search-hadjust = true
If search-hadjust = true nothing changes.
If search-hadjust = false searching does not adjust the horizontal
center of the document when showing search results.
Reasoning: When viewing a pdf with a margin we usually want to hide
the margin at both sides by zooming in. The horizontal adjustment
sometimes hides parts of the document by moving the horizontal
center.
Add a widget derived from GtkDrawingArea that handles the drawing. It
automaticaly requests rerendering of the page if necessary (i.e on a scroll and
rotate).
This should solve all the rendering issues.
This function should be used to recalculate the coordinates of
a rectangle to its new coordinates on the rendered page
(depending on the current scale and rotation value)