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.
The document object now has functions to set and get the position and
the viewport size.
The position is a relative position with respect to the size of the
entire document, i.e. position_y=0 means top of the document and
position_y=1 bottom.
The viewport size is stored in screen coordinates, in pixels.
Now the document object knows about pages_per_row, first_page_column and
page_padding, so we will be able to compute sizes and positions of the
document view without querying the GTK widgets.
We precompute the maximum width and maximum height when opening the
document. Then, when someone calls zathura_document_get_cell_size we use
page_calc_width_height to apply the rotation and scale the precomputed
values.
Add a new adjust mode that is set when focusing the inputbar and
disables adjusting the vertical scrollbar. As a result, focusing the
inputbar doesn't scroll the document, leading to better results when
changing pages from the inputbar (e.g. using bookmarks).
Reported-by: Marwan Tanager <marwan.tngr@gmail.com>
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
A document is laid out on a homogeneous gtk table/grid. This new method,
zathura_document_get_cell_size, computes the size of the cells in that
table/grid, at the current scale.
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>