Document nrow computation

Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
This commit is contained in:
Sebastian Ramacher 2014-06-23 21:13:54 +02:00
parent d07dfe4876
commit aaa5467305

View file

@ -63,9 +63,17 @@ position_to_page_number(zathura_document_t* document, double pos_x,
unsigned int c0 = zathura_document_get_first_page_column(document);
unsigned int npag = zathura_document_get_number_of_pages(document);
unsigned int ncol = zathura_document_get_pages_per_row(document);
unsigned int nrow = (npag + c0 - 1 + ncol - 1) / ncol; /* number of rows */
unsigned int nrow = 0;
unsigned int pad = zathura_document_get_page_padding(document);
if (c0 == 1) {
/* There is no offset, so this is easy. */
nrow = (npag + ncol - 1) / ncol;
} else {
/* If there is a offset, we handle the first row extra. */
nrow = 1 + (npag - (ncol - c0 - 1) + (ncol - 1)) / ncol;
}
unsigned int col = floor(pos_x * (double)doc_width / (double)(cell_width + pad));
unsigned int row = floor(pos_y * (double)doc_height / (double)(cell_height + pad));