From: Pierre-Luc Beaudoin Date: Fri, 1 May 2009 02:54:23 +0000 (-0400) Subject: Add a champlain_view_get_coords_at for x, y in the view X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=63f37d8c51ff1beee8af0522e0dc5475935287be;p=libchamplain Add a champlain_view_get_coords_at for x, y in the view --- diff --git a/champlain/champlain-view.c b/champlain/champlain-view.c index ea45fc5..2f987a6 100644 --- a/champlain/champlain-view.c +++ b/champlain/champlain-view.c @@ -1331,7 +1331,7 @@ champlain_view_add_layer (ChamplainView *view, * @latitude: a variable where to put the latitude of the event * @longitude: a variable where to put the longitude of the event * - * Returns a new #ChamplainView ready to be used as a #ClutterActor. + * Returns the latitude, longitude coordinates for the given ClutterEvent. * * Since: 0.2.8 */ @@ -1345,12 +1345,7 @@ champlain_view_get_coords_from_event (ChamplainView *view, /* Apparently there isn a more precise test */ g_return_val_if_fail (event, FALSE); - ChamplainViewPrivate *priv = view->priv; guint x, y; - gint actor_x, actor_y; - gint rel_x, rel_y; - - clutter_actor_get_transformed_position (priv->finger_scroll, &actor_x, &actor_y); switch (clutter_event_type (event)) { @@ -1388,6 +1383,35 @@ champlain_view_get_coords_from_event (ChamplainView *view, return FALSE; } + return champlain_view_get_coords_at (view, x, y, latitude, longitude); +} + +/** + * champlain_view_get_coords_at: + * @view: a #ChamplainView + * @x: the x position in the view + * @y: the y position in the view + * @latitude: a variable where to put the latitude of the event + * @longitude: a variable where to put the longitude of the event + * + * Returns the latitude, longitude coordinates for the given x, y position in + * the view. Use if you get coordinates from GtkEvents for example. + * + * Since: 0.4 + */ +gboolean champlain_view_get_coords_at (ChamplainView *view, + guint x, + guint y, + gdouble *latitude, + gdouble *longitude) +{ + g_return_val_if_fail (CHAMPLAIN_IS_VIEW (view), FALSE); + ChamplainViewPrivate *priv = view->priv; + gint actor_x, actor_y; + gint rel_x, rel_y; + + clutter_actor_get_transformed_position (priv->finger_scroll, &actor_x, &actor_y); + rel_x = x - actor_x; rel_y = y - actor_y; diff --git a/champlain/champlain-view.h b/champlain/champlain-view.h index 5bbc20c..d93037d 100644 --- a/champlain/champlain-view.h +++ b/champlain/champlain-view.h @@ -123,6 +123,12 @@ gboolean champlain_view_get_coords_from_event (ChamplainView *view, gdouble *lat, gdouble *lon); +gboolean champlain_view_get_coords_at (ChamplainView *view, + guint x, + guint y, + gdouble *lat, + gdouble *lon); + void champlain_view_tile_ready (ChamplainView *view, ChamplainZoomLevel *level, ChamplainTile *tile,