mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2025-02-06 08:04:57 +01:00
Implement get/set position functions
This commit is contained in:
parent
12b1fa1f00
commit
8f4eac4f9d
2 changed files with 53 additions and 0 deletions
|
@ -12,6 +12,7 @@ struct zathura_annotation_s {
|
|||
char* content; /**< Content of the annotation */
|
||||
time_t modification_date; /**< Modification date */
|
||||
zathura_page_t* page; /**< Zathura page */
|
||||
zathura_rectangle_t position; /**< Position of the annotation */
|
||||
void* data; /**< Custom data */
|
||||
};
|
||||
|
||||
|
@ -194,6 +195,39 @@ zathura_annotation_set_page(zathura_annotation_t* annotation, zathura_page_t* pa
|
|||
annotation->page = page;
|
||||
}
|
||||
|
||||
bool
|
||||
zathura_annotation_get_position(zathura_annotation_t* annotation,
|
||||
zathura_rectangle_t* rectangle)
|
||||
{
|
||||
if (annotation == NULL || rectangle == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (annotation->type == ZATHURA_ANNOTATION_MARKUP) { // TODO: Position of other annotation types
|
||||
rectangle->x1 = annotation->position.x1;
|
||||
rectangle->x2 = annotation->position.x2;
|
||||
rectangle->y1 = annotation->position.y1;
|
||||
rectangle->y2 = annotation->position.y2;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
zathura_annotation_set_position(zathura_annotation_t* annotation,
|
||||
zathura_rectangle_t rectangle)
|
||||
{
|
||||
if (annotation == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
annotation->position.x1 = rectangle.x1;
|
||||
annotation->position.x2 = rectangle.x2;
|
||||
annotation->position.y1 = rectangle.y1;
|
||||
annotation->position.y2 = rectangle.y2;
|
||||
}
|
||||
|
||||
static char*
|
||||
__strdup(const char* string)
|
||||
{
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include <time.h>
|
||||
|
||||
#include "page.h"
|
||||
#include "types.h"
|
||||
|
||||
typedef struct zathura_annotation_s zathura_annotation_t;
|
||||
|
||||
|
@ -172,4 +173,22 @@ zathura_page_t* zathura_annotation_get_page(zathura_annotation_t* annotation);
|
|||
*/
|
||||
void zathura_annotation_set_page_index(zathura_annotation_t* annotation, zathura_page_t* page);
|
||||
|
||||
/**
|
||||
* Retrieves the position of the annotation and saves it into the given
|
||||
* rectangle
|
||||
*
|
||||
* @param annotation The annotation
|
||||
* @param rectangle The coordinates of the annotation
|
||||
* @return true if the position could be retrieved otherwise false
|
||||
*/
|
||||
bool zathura_annotation_get_position(zathura_annotation_t* annotation, zathura_rectangle_t* rectangle);
|
||||
|
||||
/**
|
||||
* Sets the new position of the annotation
|
||||
*
|
||||
* @param annotation The annotation
|
||||
* @param rectangle The rectangle containing the new position information
|
||||
*/
|
||||
void zathura_annotation_set_position(zathura_annotation_t* annotation, zathura_rectangle_t rectangle);
|
||||
|
||||
#endif // ANNOTATION_H
|
||||
|
|
Loading…
Reference in a new issue