[evince/wip/highlight: 54/59] libview: checking if point is inside annotation



commit 61565726526e641edd83e62833c5421baa6c0dac
Author: Giselle Reis <gisellemnr src gnome org>
Date:   Tue Aug 19 19:23:31 2014 +0200

    libview: checking if point is inside annotation
    
    Added a step to check if a point is inside an
    annotation. In case it is foud to be inside the
    bounding box, view asks the document if it is
    actually inside the annotations, since the
    quadrilaterals might not comprise the whole are of
    the bounding box. Only then it become selectable.

 libview/ev-view.c |   21 +++++++++++++++++++--
 1 files changed, 19 insertions(+), 2 deletions(-)
---
diff --git a/libview/ev-view.c b/libview/ev-view.c
index ea2cffb..bec188c 100644
--- a/libview/ev-view.c
+++ b/libview/ev-view.c
@@ -3075,6 +3075,8 @@ get_annotation_mapping_at_location (EvView *view,
 {
        gint x_new = 0, y_new = 0;
        EvMappingList *annotations_mapping;
+       GArray        *annotation_mapping_array;
+       guint          i;
 
        if (!EV_IS_DOCUMENT_ANNOTATIONS (view->document))
                return NULL;
@@ -3084,8 +3086,23 @@ get_annotation_mapping_at_location (EvView *view,
 
        annotations_mapping = ev_page_cache_get_annot_mapping (view->page_cache, *page);
 
-       if (annotations_mapping)
-               return ev_mapping_list_get (annotations_mapping, x_new, y_new);
+       if (annotations_mapping) {
+               annotation_mapping_array = ev_mapping_list_get_all (annotations_mapping, x_new, y_new);
+
+               if (annotation_mapping_array) {
+                       for (i = 0; i < annotation_mapping_array->len; i++) {
+                               EvMapping    *mapping;
+                               EvAnnotation *annot;
+
+                               mapping = &g_array_index (annotation_mapping_array, EvMapping, i);
+                               annot = EV_ANNOTATION (mapping->data);
+
+                               if (ev_document_annotations_is_xy_in_annotation (EV_DOCUMENT_ANNOTATIONS 
(view->document), annot, x_new, y_new))
+                                       return mapping;
+                       }
+                       g_array_unref (annotation_mapping_array);
+               }
+       }
 
        return NULL;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]