[libchamplain] Get viewport origin in a single function instead of two



commit 3ea3c099b4026ed21cedd5889da1b0b8b0c8f875
Author: JiÅ?í Techet <techet gmail com>
Date:   Tue Feb 1 22:58:31 2011 +0100

    Get viewport origin in a single function instead of two

 champlain/champlain-marker-layer.c |   12 +++++-------
 champlain/champlain-view.c         |   24 ++++++++----------------
 champlain/champlain-view.h         |    3 +--
 3 files changed, 14 insertions(+), 25 deletions(-)
---
diff --git a/champlain/champlain-marker-layer.c b/champlain/champlain-marker-layer.c
index 70279e4..5a0da9b 100644
--- a/champlain/champlain-marker-layer.c
+++ b/champlain/champlain-marker-layer.c
@@ -464,18 +464,17 @@ static void
 set_marker_position (ChamplainMarkerLayer *layer, ChamplainMarker *marker)
 {
   ChamplainMarkerLayerPrivate *priv = layer->priv;
-  gint x, y;
+  gdouble x, y, origin_x, origin_y;
   
   /* layer not yet added to the view */
   if (priv->view == NULL)
     return;
 
+  champlain_view_get_viewport_origin (priv->view, &origin_x, &origin_y);
   x = champlain_view_longitude_to_x (priv->view, 
-    champlain_marker_get_longitude (marker));
-  x += champlain_view_get_viewport_x (priv->view);
+    champlain_marker_get_longitude (marker)) + origin_x;
   y = champlain_view_latitude_to_y (priv->view, 
-    champlain_marker_get_latitude (marker));
-  y += champlain_view_get_viewport_y (priv->view);
+    champlain_marker_get_latitude (marker)) + origin_y;
 
   clutter_actor_set_position (CLUTTER_ACTOR (marker), x, y);
 }
@@ -885,8 +884,7 @@ redraw_polygon (ChamplainMarkerLayer *layer)
   cairo_texture = clutter_cairo_texture_new (width, height);
   clutter_container_add_actor (CLUTTER_CONTAINER (priv->polygon_actor), cairo_texture);
   
-  x = champlain_view_get_viewport_x (priv->view);
-  y = champlain_view_get_viewport_y (priv->view);
+  champlain_view_get_viewport_origin (priv->view, &x, &y);
 
   clutter_actor_set_position (priv->polygon_actor, x, y);
 
diff --git a/champlain/champlain-view.c b/champlain/champlain-view.c
index b740e8f..9b99f28 100644
--- a/champlain/champlain-view.c
+++ b/champlain/champlain-view.c
@@ -1709,27 +1709,19 @@ champlain_view_latitude_to_y (ChamplainView *view,
 }
 
 
-double
-champlain_view_get_viewport_x (ChamplainView *view)
+void 
+champlain_view_get_viewport_origin (ChamplainView *view, gdouble *x, gdouble *y)
 {
   DEBUG_LOG ()
 
-  g_return_val_if_fail (CHAMPLAIN_IS_VIEW (view), 0.0);
-  ChamplainViewPrivate *priv = view->priv;
-  
-  return priv->viewport_size.x;
-}
-
-
-double
-champlain_view_get_viewport_y (ChamplainView *view)
-{
-  DEBUG_LOG ()
-
-  g_return_val_if_fail (CHAMPLAIN_IS_VIEW (view), 0.0);
+  g_return_if_fail (CHAMPLAIN_IS_VIEW (view));
   ChamplainViewPrivate *priv = view->priv;
   
-  return priv->viewport_size.y;
+  if (x)
+    *x = priv->viewport_size.x;
+ 
+  if (y)
+    *y = priv->viewport_size.y;
 }
 
 
diff --git a/champlain/champlain-view.h b/champlain/champlain-view.h
index 9aa538f..7655b1d 100644
--- a/champlain/champlain-view.h
+++ b/champlain/champlain-view.h
@@ -145,8 +145,7 @@ gdouble champlain_view_longitude_to_x (ChamplainView *view,
 gdouble champlain_view_latitude_to_y (ChamplainView *view, 
     gdouble latitude);
 
-double champlain_view_get_viewport_x (ChamplainView *view);
-double champlain_view_get_viewport_y (ChamplainView *view);
+void champlain_view_get_viewport_origin (ChamplainView *view, gdouble *x, gdouble *y);
 
 ClutterBinLayout *champlain_view_get_layout_manager (ChamplainView *view); 
 



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