mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-11-11 01:13:48 +01:00
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.
This commit is contained in:
parent
f617ee61e5
commit
25998f8320
40
document.c
40
document.c
@ -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)
|
||||
{
|
||||
|
35
document.h
35
document.h
@ -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
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user