Commit 19d36801 authored by Moritz Lipp's avatar Moritz Lipp

Just save a single border for a polygon/poly line

parent 7c99fa90
......@@ -91,31 +91,31 @@ zathura_annotation_polygon_get_vertices(zathura_annotation_t* annotation,
}
zathura_error_t
zathura_annotation_polygon_set_borders(zathura_annotation_t* annotation,
zathura_list_t* borders)
zathura_annotation_polygon_set_border(zathura_annotation_t* annotation,
zathura_annotation_border_t border)
{
if (annotation == NULL || borders == NULL) {
if (annotation == NULL) {
return ZATHURA_ERROR_INVALID_ARGUMENTS;
}
ANNOTATION_POLYGON_CHECK_TYPE_AND_DATA()
annotation->data.polygon->borders = borders;
annotation->data.polygon->border = border;
return ZATHURA_ERROR_OK;
}
zathura_error_t
zathura_annotation_polygon_get_borders(zathura_annotation_t* annotation,
zathura_list_t** borders)
zathura_annotation_polygon_get_border(zathura_annotation_t* annotation,
zathura_annotation_border_t* border)
{
if (annotation == NULL || borders == NULL) {
if (annotation == NULL || border == NULL) {
return ZATHURA_ERROR_INVALID_ARGUMENTS;
}
ANNOTATION_POLYGON_CHECK_TYPE_AND_DATA()
*borders = annotation->data.polygon->borders;
*border = annotation->data.polygon->border;
return ZATHURA_ERROR_OK;
}
......
......@@ -40,32 +40,32 @@ zathura_error_t zathura_annotation_polygon_set_vertices(zathura_annotation_t* an
zathura_error_t zathura_annotation_polygon_get_vertices(zathura_annotation_t* annotation, zathura_list_t** vertices);
/**
* Sets a list of zathura_border_t borders specifying the width and dash pattern
* to be used in drawing the line.
* Sets a zathura_border_t borders specifying the width and dash pattern to be
* used in drawing the line.
*
* @param[in] annotation The annotation
* @param[in] borders The list of borders
* @param[in] border The border
*
* @return ZATHURA_ERROR_OK No error occurred
* @return ZATHURA_ERROR_INVALID_ARGUMENTS Invalid arguments have been passed
* @return ZATHURA_ERROR_ANNOTATION_INVALID_TYPE Mismatching type of annotation passed
* @return ZATHURA_ERROR_UNKNOWN An unspecified error occurred
*/
zathura_error_t zathura_annotation_polygon_set_borders(zathura_annotation_t* annotation, zathura_list_t* borders);
zathura_error_t zathura_annotation_polygon_set_border(zathura_annotation_t* annotation, zathura_annotation_border_t border);
/**
* Returns a list of zathura_border_t borders specifying the width and dash pattern
* to be used in drawing the line.
* Returns the zathura_border_t border specifying the width and dash pattern to
* be used in drawing the line.
*
* @param[in] annotation The annotation
* @param[out] borders The list of borders
* @param[out] border The border
*
* @return ZATHURA_ERROR_OK No error occurred
* @return ZATHURA_ERROR_INVALID_ARGUMENTS Invalid arguments have been passed
* @return ZATHURA_ERROR_ANNOTATION_INVALID_TYPE Mismatching type of annotation passed
* @return ZATHURA_ERROR_UNKNOWN An unspecified error occurred
*/
zathura_error_t zathura_annotation_polygon_get_borders(zathura_annotation_t* annotation, zathura_list_t** borders);
zathura_error_t zathura_annotation_polygon_get_border(zathura_annotation_t* annotation, zathura_annotation_border_t* border);
/**
* Sets the interior color of the polygon annotation with which to fill the
......
......@@ -123,31 +123,31 @@ zathura_annotation_poly_line_get_line_ending(zathura_annotation_t*
}
zathura_error_t
zathura_annotation_poly_line_set_borders(zathura_annotation_t* annotation,
zathura_list_t* borders)
zathura_annotation_poly_line_set_border(zathura_annotation_t* annotation,
zathura_annotation_border_t border)
{
if (annotation == NULL || borders == NULL) {
if (annotation == NULL) {
return ZATHURA_ERROR_INVALID_ARGUMENTS;
}
ANNOTATION_POLY_LINE_CHECK_TYPE_AND_DATA()
annotation->data.poly_line->borders = borders;
annotation->data.poly_line->border = border;
return ZATHURA_ERROR_OK;
}
zathura_error_t
zathura_annotation_poly_line_get_borders(zathura_annotation_t* annotation,
zathura_list_t** borders)
zathura_annotation_poly_line_get_border(zathura_annotation_t* annotation,
zathura_annotation_border_t* border)
{
if (annotation == NULL || borders == NULL) {
if (annotation == NULL || border == NULL) {
return ZATHURA_ERROR_INVALID_ARGUMENTS;
}
ANNOTATION_POLY_LINE_CHECK_TYPE_AND_DATA()
*borders = annotation->data.poly_line->borders;
*border = annotation->data.poly_line->border;
return ZATHURA_ERROR_OK;
}
......
......@@ -68,32 +68,32 @@ zathura_error_t zathura_annotation_poly_line_get_line_ending(zathura_annotation_
annotation, zathura_annotation_line_ending_t line_ending[2]);
/**
* Sets a list of zathura_border_t borders specifying the width and dash pattern
* to be used in drawing the line.
* Sets a zathura_border_t borders specifying the width and dash pattern to be
* used in drawing the line.
*
* @param[in] annotation The annotation
* @param[in] borders The list of borders
* @param[in] border The border
*
* @return ZATHURA_ERROR_OK No error occurred
* @return ZATHURA_ERROR_INVALID_ARGUMENTS Invalid arguments have been passed
* @return ZATHURA_ERROR_ANNOTATION_INVALID_TYPE Mismatching type of annotation passed
* @return ZATHURA_ERROR_UNKNOWN An unspecified error occurred
*/
zathura_error_t zathura_annotation_poly_line_set_borders(zathura_annotation_t* annotation, zathura_list_t* borders);
zathura_error_t zathura_annotation_poly_line_set_border(zathura_annotation_t* annotation, zathura_annotation_border_t border);
/**
* Returns a list of zathura_border_t borders specifying the width and dash pattern
* to be used in drawing the line.
* Returns the zathura_border_t border specifying the width and dash pattern to
* be used in drawing the line.
*
* @param[in] annotation The annotation
* @param[out] borders The list of borders
* @param[out] border The border
*
* @return ZATHURA_ERROR_OK No error occurred
* @return ZATHURA_ERROR_INVALID_ARGUMENTS Invalid arguments have been passed
* @return ZATHURA_ERROR_ANNOTATION_INVALID_TYPE Mismatching type of annotation passed
* @return ZATHURA_ERROR_UNKNOWN An unspecified error occurred
*/
zathura_error_t zathura_annotation_poly_line_get_borders(zathura_annotation_t* annotation, zathura_list_t** borders);
zathura_error_t zathura_annotation_poly_line_get_border(zathura_annotation_t* annotation, zathura_annotation_border_t* border);
/**
* Sets the interior color of the poly-line annotation with which to fill the
......
......@@ -194,4 +194,3 @@ zathura_annotation_square_get_border(zathura_annotation_t*
{
return zathura_annotation_circle_get_border(annotation, border);
}
......@@ -22,7 +22,7 @@ typedef struct zathura_annotation_polygon_s {
* A border style dictionary specifying the width and dash pattern to be used
* in drawing the line.
*/
zathura_list_t* borders;
zathura_annotation_border_t border;
/**
* An array of numbers in the range 0.0 to 1.0 specifying the interior color
......
......@@ -34,7 +34,7 @@ typedef struct zathura_annotation_poly_line_s {
* A border style dictionary specifying the width and dash pattern to be used
* in drawing the line.
*/
zathura_list_t* borders;
zathura_annotation_border_t border;
/**
* An array of numbers in the range 0.0 to 1.0 specifying the interior color
......
......@@ -585,8 +585,8 @@ suite_annotations(void)
tcase_add_test(tcase, test_annotation_polygon_clear);
tcase_add_test(tcase, test_annotation_polygon_set_vertices);
tcase_add_test(tcase, test_annotation_polygon_get_vertices);
tcase_add_test(tcase, test_annotation_polygon_set_borders);
tcase_add_test(tcase, test_annotation_polygon_get_borders);
tcase_add_test(tcase, test_annotation_polygon_set_border);
tcase_add_test(tcase, test_annotation_polygon_get_border);
tcase_add_test(tcase, test_annotation_polygon_set_interior_color);
tcase_add_test(tcase, test_annotation_polygon_get_interior_color);
tcase_add_test(tcase, test_annotation_polygon_set_intent);
......@@ -605,8 +605,8 @@ suite_annotations(void)
tcase_add_test(tcase, test_annotation_poly_line_get_vertices);
tcase_add_test(tcase, test_annotation_poly_line_set_line_ending);
tcase_add_test(tcase, test_annotation_poly_line_get_line_ending);
tcase_add_test(tcase, test_annotation_poly_line_set_borders);
tcase_add_test(tcase, test_annotation_poly_line_get_borders);
tcase_add_test(tcase, test_annotation_poly_line_set_border);
tcase_add_test(tcase, test_annotation_poly_line_get_border);
tcase_add_test(tcase, test_annotation_poly_line_set_interior_color);
tcase_add_test(tcase, test_annotation_poly_line_get_interior_color);
tcase_add_test(tcase, test_annotation_poly_line_set_intent);
......
......@@ -71,30 +71,26 @@ START_TEST(test_annotation_polygon_get_vertices) {
fail_unless(zathura_annotation_polygon_get_vertices(annotation, &vertices) == ZATHURA_ERROR_OK);
} END_TEST
START_TEST(test_annotation_polygon_set_borders) {
zathura_list_t* borders = zathura_list_alloc();
fail_unless(borders != NULL);
START_TEST(test_annotation_polygon_set_border) {
zathura_annotation_border_t border;
/* invalid arguments */
fail_unless(zathura_annotation_polygon_set_borders(NULL, NULL) == ZATHURA_ERROR_INVALID_ARGUMENTS);
fail_unless(zathura_annotation_polygon_set_borders(annotation, NULL) == ZATHURA_ERROR_INVALID_ARGUMENTS);
fail_unless(zathura_annotation_polygon_set_borders(NULL, borders) == ZATHURA_ERROR_INVALID_ARGUMENTS);
fail_unless(zathura_annotation_polygon_set_border(NULL, border) == ZATHURA_ERROR_INVALID_ARGUMENTS);
/* valid arguments */
fail_unless(zathura_annotation_polygon_set_borders(annotation, borders) == ZATHURA_ERROR_OK);
zathura_list_free(borders);
fail_unless(zathura_annotation_polygon_set_border(annotation, border) == ZATHURA_ERROR_OK);
} END_TEST
START_TEST(test_annotation_polygon_get_borders) {
zathura_list_t* borders;
START_TEST(test_annotation_polygon_get_border) {
zathura_annotation_border_t border;
/* invalid arguments */
fail_unless(zathura_annotation_polygon_get_borders(NULL, NULL) == ZATHURA_ERROR_INVALID_ARGUMENTS);
fail_unless(zathura_annotation_polygon_get_borders(annotation, NULL) == ZATHURA_ERROR_INVALID_ARGUMENTS);
fail_unless(zathura_annotation_polygon_get_borders(NULL, &borders) == ZATHURA_ERROR_INVALID_ARGUMENTS);
fail_unless(zathura_annotation_polygon_get_border(NULL, NULL) == ZATHURA_ERROR_INVALID_ARGUMENTS);
fail_unless(zathura_annotation_polygon_get_border(annotation, NULL) == ZATHURA_ERROR_INVALID_ARGUMENTS);
fail_unless(zathura_annotation_polygon_get_border(NULL, &border) == ZATHURA_ERROR_INVALID_ARGUMENTS);
/* valid arguments */
fail_unless(zathura_annotation_polygon_get_borders(annotation, &borders) == ZATHURA_ERROR_OK);
fail_unless(zathura_annotation_polygon_get_border(annotation, &border) == ZATHURA_ERROR_OK);
} END_TEST
START_TEST(test_annotation_polygon_set_interior_color) {
......
......@@ -95,30 +95,26 @@ START_TEST(test_annotation_poly_line_get_line_ending) {
fail_unless(line_ending[1] == ZATHURA_ANNOTATION_LINE_ENDING_CIRCLE);
} END_TEST
START_TEST(test_annotation_poly_line_set_borders) {
zathura_list_t* borders = zathura_list_alloc();
fail_unless(borders != NULL);
START_TEST(test_annotation_poly_line_set_border) {
zathura_annotation_border_t border;
/* invalid arguments */
fail_unless(zathura_annotation_poly_line_set_borders(NULL, NULL) == ZATHURA_ERROR_INVALID_ARGUMENTS);
fail_unless(zathura_annotation_poly_line_set_borders(annotation, NULL) == ZATHURA_ERROR_INVALID_ARGUMENTS);
fail_unless(zathura_annotation_poly_line_set_borders(NULL, borders) == ZATHURA_ERROR_INVALID_ARGUMENTS);
fail_unless(zathura_annotation_poly_line_set_border(NULL, border) == ZATHURA_ERROR_INVALID_ARGUMENTS);
/* valid arguments */
fail_unless(zathura_annotation_poly_line_set_borders(annotation, borders) == ZATHURA_ERROR_OK);
zathura_list_free(borders);
fail_unless(zathura_annotation_poly_line_set_border(annotation, border) == ZATHURA_ERROR_OK);
} END_TEST
START_TEST(test_annotation_poly_line_get_borders) {
zathura_list_t* borders;
START_TEST(test_annotation_poly_line_get_border) {
zathura_annotation_border_t border;
/* invalid arguments */
fail_unless(zathura_annotation_poly_line_get_borders(NULL, NULL) == ZATHURA_ERROR_INVALID_ARGUMENTS);
fail_unless(zathura_annotation_poly_line_get_borders(annotation, NULL) == ZATHURA_ERROR_INVALID_ARGUMENTS);
fail_unless(zathura_annotation_poly_line_get_borders(NULL, &borders) == ZATHURA_ERROR_INVALID_ARGUMENTS);
fail_unless(zathura_annotation_poly_line_get_border(NULL, NULL) == ZATHURA_ERROR_INVALID_ARGUMENTS);
fail_unless(zathura_annotation_poly_line_get_border(annotation, NULL) == ZATHURA_ERROR_INVALID_ARGUMENTS);
fail_unless(zathura_annotation_poly_line_get_border(NULL, &border) == ZATHURA_ERROR_INVALID_ARGUMENTS);
/* valid arguments */
fail_unless(zathura_annotation_poly_line_get_borders(annotation, &borders) == ZATHURA_ERROR_OK);
fail_unless(zathura_annotation_poly_line_get_border(annotation, &border) == ZATHURA_ERROR_OK);
} END_TEST
START_TEST(test_annotation_poly_line_set_interior_color) {
......
Markdown is supported
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