[evince] libview: Rename EvView coordinate transformation functions and make them public internally



commit d4e458c3c083f5fb0099cdacd0114ce31793bb38
Author: Carlos Garcia Campos <carlosgc gnome org>
Date:   Tue Jan 15 13:50:18 2013 +0100

    libview: Rename EvView coordinate transformation functions and make them public internally
    
    So that they can be used from other files.

 libview/ev-view-private.h |   17 +++++++
 libview/ev-view.c         |  109 ++++++++++++++++++++-------------------------
 2 files changed, 66 insertions(+), 60 deletions(-)
---
diff --git a/libview/ev-view-private.h b/libview/ev-view-private.h
index 9313a0d..f075dec 100644
--- a/libview/ev-view-private.h
+++ b/libview/ev-view-private.h
@@ -233,6 +233,23 @@ void _get_page_size_for_scale_and_rotation (EvDocument *document,
 					    gint        rotation,
 					    gint       *page_width,
 					    gint       *page_height);
+void _ev_view_transform_view_point_to_doc_point (EvView       *view,
+						 GdkPoint     *view_point,
+						 GdkRectangle *page_area,
+						 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,
+					       EvRectangle  *doc_rect);
+void _ev_view_transform_doc_point_to_view_point (EvView   *view,
+						 int       page,
+						 EvPoint  *doc_point,
+						 GdkPoint *view_point);
+void _ev_view_transform_doc_rect_to_view_rect (EvView       *view,
+					       int           page,
+					       EvRectangle  *doc_rect,
+					       GdkRectangle *view_rect);
 
 #endif  /* __EV_VIEW_PRIVATE_H__ */
 
diff --git a/libview/ev-view.c b/libview/ev-view.c
index a6084a2..4756f4a 100644
--- a/libview/ev-view.c
+++ b/libview/ev-view.c
@@ -123,24 +123,12 @@ static void       compute_border                             (EvView
 static void       get_page_y_offset                          (EvView             *view,
 							      int                 page,
 							      int                *y_offset);
-static void       view_rect_to_doc_rect                      (EvView             *view,
-							      GdkRectangle       *view_rect,
-							      GdkRectangle       *page_area,
-							      EvRectangle        *doc_rect);
-static void       doc_rect_to_view_rect                      (EvView             *view,
-							      int                 page,
-							      EvRectangle        *doc_rect,
-							      GdkRectangle       *view_rect);
 static void       find_page_at_location                      (EvView             *view,
 							      gdouble             x,
 							      gdouble             y,
 							      gint               *page,
 							      gint               *x_offset,
 							      gint               *y_offset);
-static void       doc_point_to_view_point 		     (EvView             *view,
-				                              int                 page,
-							      EvPoint            *doc_point,
-					     	              GdkPoint           *view_point);
 /*** Hyperrefs ***/
 static EvLink *   ev_view_get_link_at_location 		     (EvView             *view,
 				  	         	      gdouble             x,
@@ -600,8 +588,8 @@ ev_view_scroll_to_page_position (EvView *view, GtkOrientation orientation)
 	} else {
 		GdkPoint view_point;
 
-		doc_point_to_view_point (view, view->current_page,
-					 &view->pending_point, &view_point);
+		_ev_view_transform_doc_point_to_view_point (view, view->current_page,
+							    &view->pending_point, &view_point);
 		x = view_point.x;
 		y = view_point.y;
 	}
@@ -889,7 +877,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;
-	view_rect_to_doc_rect (view, &rect, &page_area, &doc_rect);
+	_ev_view_transform_view_rect_to_doc_rect (view, &rect, &page_area, &doc_rect);
 
 	/* Convert the doc rectangle into a GdkRectangle */
 	rect.x = doc_rect.x1;
@@ -1279,22 +1267,22 @@ get_doc_page_size (EvView  *view,
 	}
 }
 
-static void
-view_point_to_doc_point (EvView *view,
-			 GdkPoint *view_point,
-			 GdkRectangle *page_area,
-			 double  *doc_point_x,
-			 double  *doc_point_y)
+void
+_ev_view_transform_view_point_to_doc_point (EvView       *view,
+					    GdkPoint     *view_point,
+					    GdkRectangle *page_area,
+					    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;
 }
 
-static void
-view_rect_to_doc_rect (EvView *view,
-		       GdkRectangle *view_rect,
-		       GdkRectangle *page_area,
-		       EvRectangle  *doc_rect)
+void
+_ev_view_transform_view_rect_to_doc_rect (EvView       *view,
+					  GdkRectangle *view_rect,
+					  GdkRectangle *page_area,
+					  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;
@@ -1302,11 +1290,11 @@ view_rect_to_doc_rect (EvView *view,
 	doc_rect->y2 = doc_rect->y1 + (double) view_rect->height / view->scale;
 }
 
-static void
-doc_point_to_view_point (EvView       *view,
-                         int           page,
-		         EvPoint      *doc_point,
-		         GdkPoint     *view_point)
+void
+_ev_view_transform_doc_point_to_view_point (EvView   *view,
+					    int       page,
+					    EvPoint  *doc_point,
+					    GdkPoint *view_point)
 {
 	GdkRectangle page_area;
 	GtkBorder border;
@@ -1339,11 +1327,11 @@ doc_point_to_view_point (EvView       *view,
 	view_point->y = view_y + page_area.y;
 }
 
-static void
-doc_rect_to_view_rect (EvView       *view,
-                       int           page,
-		       EvRectangle  *doc_rect,
-		       GdkRectangle *view_rect)
+void
+_ev_view_transform_doc_rect_to_view_rect (EvView       *view,
+					  int           page,
+					  EvRectangle  *doc_rect,
+					  GdkRectangle *view_rect)
 {
 	GdkRectangle page_area;
 	GtkBorder border;
@@ -1537,7 +1525,7 @@ ev_view_get_area_from_mapping (EvView        *view,
 	EvMapping *mapping;
 
 	mapping = ev_mapping_list_find (mapping_list, data);
-	doc_rect_to_view_rect (view, page, &mapping->area, area);
+	_ev_view_transform_doc_rect_to_view_rect (view, page, &mapping->area, area);
 	area->x -= view->scroll_x;
 	area->y -= view->scroll_y;
 }
@@ -1572,7 +1560,7 @@ ev_view_put_to_doc_rect (EvView      *view,
 {
 	GdkRectangle area;
 
-	doc_rect_to_view_rect (view, page, doc_rect, &area);
+	_ev_view_transform_doc_rect_to_view_rect (view, page, doc_rect, &area);
 	area.x -= view->scroll_x;
 	area.y -= view->scroll_y;
 	ev_view_put (view, child_widget, area.x, area.y, page, doc_rect);
@@ -2720,7 +2708,7 @@ annotation_window_moved (EvAnnotationWindow *window,
 	view_rect.height = height;
 
 	ev_view_get_page_extents (view, child->page, &page_area, &border);
-	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, &doc_rect);
 	child->orig_x = doc_rect.x1;
 	child->orig_y = doc_rect.y1;
 }
@@ -2766,7 +2754,7 @@ ev_view_create_annotation_window (EvView       *view,
 
 	page = ev_annotation_get_page_index (annot);
 	ev_annotation_window_get_rectangle (EV_ANNOTATION_WINDOW (window), &doc_rect);
-	doc_rect_to_view_rect (view, page, &doc_rect, &view_rect);
+	_ev_view_transform_doc_rect_to_view_rect (view, page, &doc_rect, &view_rect);
 	view_rect.x -= view->scroll_x;
 	view_rect.y -= view->scroll_y;
 
@@ -2938,8 +2926,8 @@ ev_view_create_annotation (EvView          *view,
 	point.x = x;
 	point.y = y;
 	ev_view_get_page_extents (view, view->current_page, &page_area, &border);
-	view_point_to_doc_point (view, &point, &page_area,
-				 &doc_rect.x1, &doc_rect.y1);
+	_ev_view_transform_view_point_to_doc_point (view, &point, &page_area,
+						    &doc_rect.x1, &doc_rect.y1);
 	doc_rect.x2 = doc_rect.x1 + 24;
 	doc_rect.y2 = doc_rect.y1 + 24;
 
@@ -2993,7 +2981,7 @@ ev_view_create_annotation (EvView          *view,
 		ev_view_annotation_show_popup_window (view, window);
 	}
 
-	doc_rect_to_view_rect (view, view->current_page, &doc_rect, &view_rect);
+	_ev_view_transform_doc_rect_to_view_rect (view, view->current_page, &doc_rect, &view_rect);
 	view_rect.x -= view->scroll_x;
 	view_rect.y -= view->scroll_y;
 	region = cairo_region_create_rectangle (&view_rect);
@@ -3023,8 +3011,9 @@ ev_view_focus_annotation (EvView    *view,
 	page = ev_annotation_get_page_index (annot);
 	ev_document_model_set_page (view->model, page);
 
-	doc_rect_to_view_rect (view, page,
-			       &annot_mapping->area, &view_rect);
+	_ev_view_transform_doc_rect_to_view_rect (view, page,
+						  &annot_mapping->area,
+						  &view_rect);
 	ensure_rectangle_is_visible (view, &view_rect);
 	gtk_widget_queue_draw (GTK_WIDGET (view));
 }
@@ -3321,7 +3310,7 @@ ev_view_size_allocate (GtkWidget      *widget,
 		if (!gtk_widget_get_visible (child->widget))
 			continue;
 
-		doc_rect_to_view_rect (view, child->page, &child->doc_rect, &view_area);
+		_ev_view_transform_doc_rect_to_view_rect (view, child->page, &child->doc_rect, &view_area);
 		view_area.x -= view->scroll_x;
 		view_area.y -= view->scroll_y;
 
@@ -3345,7 +3334,7 @@ ev_view_size_allocate (GtkWidget      *widget,
 			doc_rect.x1 = child->orig_x;
 			doc_rect.y1 = child->orig_y;
 		}
-		doc_rect_to_view_rect (view, child->page, &doc_rect, &view_rect);
+		_ev_view_transform_doc_rect_to_view_rect (view, child->page, &doc_rect, &view_rect);
 		view_rect.x -= view->scroll_x;
 		view_rect.y -= view->scroll_y;
 
@@ -4363,7 +4352,7 @@ highlight_find_results (EvView *view,
 		}
 
 		rectangle = ev_view_find_get_result (view, page, i);
-		doc_rect_to_view_rect (view, page, rectangle, &view_rectangle);
+		_ev_view_transform_doc_rect_to_view_rect (view, page, rectangle, &view_rectangle);
 		draw_rubberband (view, cr, &view_rectangle, alpha);
         }
 }
@@ -4379,7 +4368,7 @@ highlight_forward_search_results (EvView *view,
 	if (GPOINTER_TO_INT (mapping->data) != page)
 		return;
 
-	doc_rect_to_view_rect (view, page, &mapping->area, &rect);
+	_ev_view_transform_doc_rect_to_view_rect (view, page, &mapping->area, &rect);
 
         cairo_save (cr);
 	cairo_set_source_rgb (cr, 1., 0., 0.);
@@ -4405,7 +4394,7 @@ focus_annotation (EvView       *view,
 	if (ev_annotation_get_page_index (annot) != page)
 		return;
 
-	doc_rect_to_view_rect (view, page, &mapping->area, &rect);
+	_ev_view_transform_doc_rect_to_view_rect (view, page, &mapping->area, &rect);
 
         gtk_render_focus (gtk_widget_get_style_context (widget),
                           cr,
@@ -5878,7 +5867,7 @@ jump_to_find_result (EvView *view)
 		GdkRectangle view_rect;
 
 		rect = ev_view_find_get_result (view, page, view->find_result);
-		doc_rect_to_view_rect (view, page, rect, &view_rect);
+		_ev_view_transform_doc_rect_to_view_rect (view, page, rect, &view_rect);
 		ensure_rectangle_is_visible (view, &view_rect);
 		view->jump_to_find_result = FALSE;
 	}
@@ -6038,7 +6027,7 @@ ev_view_highlight_forward_search (EvView       *view,
 	page = GPOINTER_TO_INT (mapping->data);
 	ev_document_model_set_page (view->model, page);
 
-	doc_rect_to_view_rect (view, page, &mapping->area, &view_rect);
+	_ev_view_transform_doc_rect_to_view_rect (view, page, &mapping->area, &view_rect);
 	ensure_rectangle_is_visible (view, &view_rect);
 	gtk_widget_queue_draw (GTK_WIDGET (view));
 }
@@ -6078,8 +6067,8 @@ compute_new_selection_rect (EvView       *view,
 
 				selection = g_new0 (EvViewSelection, 1);
 				selection->page = i;
-				view_rect_to_doc_rect (view, &overlap, &page_area,
-						       &(selection->rect));
+				_ev_view_transform_view_rect_to_doc_rect (view, &overlap, &page_area,
+									  &(selection->rect));
 
 				list = g_list_append (list, selection);
 			}
@@ -6169,9 +6158,9 @@ compute_new_selection_text (EvView          *view,
 			point = stop;
 
 		if (i == first)
-			view_point_to_doc_point (view, point, &page_area,
-						 &selection->rect.x1,
-						 &selection->rect.y1);
+			_ev_view_transform_view_point_to_doc_point (view, point, &page_area,
+								    &selection->rect.x1,
+								    &selection->rect.y1);
 
 		/* If the selection is contained within just one page,
 		 * make sure we don't write 'start' into both points
@@ -6180,9 +6169,9 @@ compute_new_selection_text (EvView          *view,
 			point = stop;
 
 		if (i == last)
-			view_point_to_doc_point (view, point, &page_area,
-						 &selection->rect.x2,
-						 &selection->rect.y2);
+			_ev_view_transform_view_point_to_doc_point (view, point, &page_area,
+								    &selection->rect.x2,
+								    &selection->rect.y2);
 
 		list = g_list_append (list, selection);
 	}



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