mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-12-29 12:26:01 +01:00
Add document method to compute the size of a cell
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>
This commit is contained in:
parent
ff305e6972
commit
27d7973586
2 changed files with 37 additions and 0 deletions
28
document.c
28
document.c
|
@ -389,6 +389,34 @@ zathura_document_set_page_offset(zathura_document_t* document, unsigned int page
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
zathura_document_get_cell_size(zathura_document_t* document,
|
||||
unsigned int* height, unsigned int* width)
|
||||
{
|
||||
g_return_if_fail(document != NULL && height != NULL && width != NULL);
|
||||
|
||||
unsigned int number_of_pages =
|
||||
zathura_document_get_number_of_pages(document);
|
||||
*width = 0;
|
||||
*height = 0;
|
||||
|
||||
/* Get the size of each cell of the table/grid, assuming it is homogeneous
|
||||
* (i.e. each cell has the same dimensions. */
|
||||
for (unsigned int page_id = 0; page_id < number_of_pages; page_id++) {
|
||||
zathura_page_t* page = zathura_document_get_page(document, page_id);
|
||||
if (page == NULL)
|
||||
continue;
|
||||
|
||||
unsigned int page_width = 0, page_height = 0;
|
||||
page_calc_height_width(page, &page_height, &page_width, true);
|
||||
|
||||
if (*width < page_width)
|
||||
*width = page_width;
|
||||
if (*height < page_height)
|
||||
*height = page_height;
|
||||
}
|
||||
}
|
||||
|
||||
zathura_error_t
|
||||
zathura_document_save_as(zathura_document_t* document, const char* path)
|
||||
{
|
||||
|
|
|
@ -169,6 +169,15 @@ void* zathura_document_get_data(zathura_document_t* document);
|
|||
*/
|
||||
void zathura_document_set_data(zathura_document_t* document, void* data);
|
||||
|
||||
/**
|
||||
* Computes the size of a cell in the document's layout table, assuming that the table is homogeneous (i.e. every cell has the same dimensions). It takes the current scale into account.
|
||||
*
|
||||
* @param[in] document The document instance
|
||||
* @param[out] height,width The computed height and width of the cell
|
||||
*/
|
||||
void zathura_document_get_cell_size(zathura_document_t* document,
|
||||
unsigned int* height, unsigned int* width);
|
||||
|
||||
/**
|
||||
* Save the document
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue