[evince] libview: Take border into account when converting view points to doc points
- From: Carlos Garcia Campos <carlosgc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evince] libview: Take border into account when converting view points to doc points
- Date: Sun, 2 Mar 2014 13:09:57 +0000 (UTC)
commit 576dd5b3e44483462fbd4e72caa83cd1826a3e06
Author: Carlos Garcia Campos <carlosgc gnome org>
Date: Sun Mar 2 13:56:07 2014 +0100
libview: Take border into account when converting view points to doc points
libview/ev-view-accessible.c | 2 +-
libview/ev-view-private.h | 2 ++
libview/ev-view.c | 35 +++++++++++++++++------------------
3 files changed, 20 insertions(+), 19 deletions(-)
---
diff --git a/libview/ev-view-accessible.c b/libview/ev-view-accessible.c
index 8645f37..60155c3 100644
--- a/libview/ev-view-accessible.c
+++ b/libview/ev-view-accessible.c
@@ -566,7 +566,7 @@ ev_view_accessible_get_offset_at_point (AtkText *text,
}
ev_view_get_page_extents (view, get_relevant_page (view), &page_area, &border);
- _ev_view_transform_view_point_to_doc_point (view, &view_point, &page_area, &doc_x, &doc_y);
+ _ev_view_transform_view_point_to_doc_point (view, &view_point, &page_area, &border, &doc_x, &doc_y);
for (i = 0; i < n_areas; i++) {
rect = areas + i;
diff --git a/libview/ev-view-private.h b/libview/ev-view-private.h
index 7633c3a..23fde54 100644
--- a/libview/ev-view-private.h
+++ b/libview/ev-view-private.h
@@ -257,11 +257,13 @@ void _get_page_size_for_scale_and_rotation (EvDocument *document,
void _ev_view_transform_view_point_to_doc_point (EvView *view,
GdkPoint *view_point,
GdkRectangle *page_area,
+ GtkBorder *border,
double *doc_point_x,
double *doc_point_y);
void _ev_view_transform_view_rect_to_doc_rect (EvView *view,
GdkRectangle *view_rect,
GdkRectangle *page_area,
+ GtkBorder *border,
EvRectangle *doc_rect);
void _ev_view_transform_doc_point_to_view_point (EvView *view,
int page,
diff --git a/libview/ev-view.c b/libview/ev-view.c
index d8101c9..be6d17b 100644
--- a/libview/ev-view.c
+++ b/libview/ev-view.c
@@ -874,7 +874,7 @@ compute_scroll_increment (EvView *view,
rect.y = view->scroll_y + (scroll == GTK_SCROLL_PAGE_BACKWARD ? 5 : allocation.height - 5);
rect.width = page_area.width;
rect.height = 1;
- _ev_view_transform_view_rect_to_doc_rect (view, &rect, &page_area, &doc_rect);
+ _ev_view_transform_view_rect_to_doc_rect (view, &rect, &page_area, &border, &doc_rect);
/* Convert the doc rectangle into a GdkRectangle */
rect.x = doc_rect.x1;
@@ -1285,21 +1285,23 @@ void
_ev_view_transform_view_point_to_doc_point (EvView *view,
GdkPoint *view_point,
GdkRectangle *page_area,
+ GtkBorder *border,
double *doc_point_x,
double *doc_point_y)
{
- *doc_point_x = (double) (view_point->x - page_area->x) / view->scale;
- *doc_point_y = (double) (view_point->y - page_area->y) / view->scale;
+ *doc_point_x = (double) (view_point->x - page_area->x - border->left) / view->scale;
+ *doc_point_y = (double) (view_point->y - page_area->y - border->right) / view->scale;
}
void
_ev_view_transform_view_rect_to_doc_rect (EvView *view,
GdkRectangle *view_rect,
GdkRectangle *page_area,
+ GtkBorder *border,
EvRectangle *doc_rect)
{
- doc_rect->x1 = (double) (view_rect->x - page_area->x) / view->scale;
- doc_rect->y1 = (double) (view_rect->y - page_area->y) / view->scale;
+ doc_rect->x1 = (double) (view_rect->x - page_area->x - border->left) / view->scale;
+ doc_rect->y1 = (double) (view_rect->y - page_area->y - border->right) / view->scale;
doc_rect->x2 = doc_rect->x1 + (double) view_rect->width / view->scale;
doc_rect->y2 = doc_rect->y1 + (double) view_rect->height / view->scale;
}
@@ -2862,7 +2864,7 @@ annotation_window_moved (EvAnnotationWindow *window,
view_rect.height = height;
ev_view_get_page_extents (view, child->page, &page_area, &border);
- _ev_view_transform_view_rect_to_doc_rect (view, &view_rect, &page_area, &doc_rect);
+ _ev_view_transform_view_rect_to_doc_rect (view, &view_rect, &page_area, &border, &doc_rect);
child->orig_x = doc_rect.x1;
child->orig_y = doc_rect.y1;
}
@@ -3093,7 +3095,7 @@ ev_view_create_annotation (EvView *view,
point.x = x;
point.y = y;
ev_view_get_page_extents (view, view->current_page, &page_area, &border);
- _ev_view_transform_view_point_to_doc_point (view, &point, &page_area,
+ _ev_view_transform_view_point_to_doc_point (view, &point, &page_area, &border,
&doc_rect.x1, &doc_rect.y1);
doc_rect.x2 = doc_rect.x1 + 24;
doc_rect.y2 = doc_rect.y1 + 24;
@@ -7945,22 +7947,18 @@ compute_new_selection (EvView *view,
selection->rect.y2 = height;
ev_view_get_page_extents (view, i, &page_area, &border);
- page_area.x -= border.left;
- page_area.y -= border.top;
- page_area.width += border.left + border.right;
- page_area.height += border.top + border.bottom;
-
if (gdk_rectangle_point_in (&page_area, start))
point = start;
else
point = stop;
if (i == first) {
- _ev_view_transform_view_point_to_doc_point (view, point, &page_area,
+ _ev_view_transform_view_point_to_doc_point (view, point,
+ &page_area, &border,
&selection->rect.x1,
&selection->rect.y1);
- selection->rect.x1 = MAX (selection->rect.x1 - border.left, 0);
- selection->rect.y1 = MAX (selection->rect.y1 - border.top, 0);
+ selection->rect.x1 = MAX (selection->rect.x1, 0);
+ selection->rect.y1 = MAX (selection->rect.y1, 0);
}
/* If the selection is contained within just one page,
@@ -7970,11 +7968,12 @@ compute_new_selection (EvView *view,
point = stop;
if (i == last) {
- _ev_view_transform_view_point_to_doc_point (view, point, &page_area,
+ _ev_view_transform_view_point_to_doc_point (view, point,
+ &page_area, &border,
&selection->rect.x2,
&selection->rect.y2);
- selection->rect.x2 = MAX (selection->rect.x2 - border.right, 0);
- selection->rect.y2 = MAX (selection->rect.y2 - border.bottom, 0);
+ selection->rect.x2 = MAX (selection->rect.x2, 0);
+ selection->rect.y2 = MAX (selection->rect.y2, 0);
}
list = g_list_prepend (list, selection);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]