Commit 25998f83 authored by Abdo Roig-Maranges's avatar Abdo Roig-Maranges
Browse files

make the document object aware of page layout

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.
parent f617ee61
......@@ -52,6 +52,9 @@ struct zathura_document_s {
int page_offset; /**< Page offset */
double cell_width; /**< width of a page cell in the document (not ransformed by scale and rotation) */
double cell_height; /**< height of a page cell in the document (not ransformed by scale and rotation) */
unsigned int pages_per_row; /**< number of pages in a row */
unsigned int first_page_column; /**< column of the first page */
unsigned int page_padding; /**< padding between pages */
/**
* Document pages
......@@ -424,6 +427,43 @@ zathura_document_get_cell_size(zathura_document_t* document,
}
void
zathura_document_set_page_layout(zathura_document_t* document, unsigned int page_padding,
unsigned int pages_per_row, unsigned int first_page_column)
{
g_return_if_fail(document != NULL);
document->page_padding = page_padding;
document->pages_per_row = pages_per_row;
document->first_page_column = first_page_column;
}
unsigned int
zathura_document_get_page_padding(zathura_document_t* document)
{
if (document == NULL) {
return 0;
}
return document->page_padding;
}
unsigned int
zathura_document_get_pages_per_row(zathura_document_t* document)
{
if (document == NULL) {
return 0;
}
return document->pages_per_row;
}
unsigned int
zathura_document_get_first_page_column(zathura_document_t* document)
{
if (document == NULL) {
return 0;
}
return document->first_page_column;
}
zathura_error_t
zathura_document_save_as(zathura_document_t* document, const char* path)
{
......
......@@ -188,6 +188,41 @@ void zathura_document_set_data(zathura_document_t* document, void* data);
void zathura_document_get_cell_size(zathura_document_t* document,
unsigned int* height, unsigned int* width);
/**
* Sets the layout of the pages in the document
*
* @param[in] document The document instance
* @param[in] page_padding pixels of padding between pages
* @param[in] pages_per_row number of pages per row
* @param[in] first_page_column column of the first page (first column is 1)
*/
void zathura_document_set_page_layout(zathura_document_t* document, unsigned int page_padding,
unsigned int pages_per_row, unsigned int first_page_column);
/**
* Returns the padding in pixels betwen pages
*
* @param document The document
* @return The padding in pixels between pages
*/
unsigned int zathura_document_get_page_padding(zathura_document_t* document);
/**
* Returns the number of pages per row
*
* @param document The document
* @return The number of pages per row
*/
unsigned int zathura_document_get_pages_per_row(zathura_document_t* document);
/**
* Returns the column for the first page (first column = 1)
*
* @param document The document
* @return The column for the first page
*/
unsigned int zathura_document_get_first_page_column(zathura_document_t* document);
/**
* Save the document
*
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment