From: Tollef Fog Heen Date: Mon, 16 Nov 2009 15:38:49 +0000 (+0100) Subject: Make it possible to hide the scale X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fheads%2Fscale;p=libchamplain Make it possible to hide the scale --- diff --git a/champlain/champlain-view.c b/champlain/champlain-view.c index f5acee4..6ea10da 100644 --- a/champlain/champlain-view.c +++ b/champlain/champlain-view.c @@ -1017,6 +1017,12 @@ update_scale (gpointer *unused, if (! priv || !priv->map || !priv->map->current_level) { return; } + if (priv->display_scale) { + clutter_actor_show(priv->scale_actor); + } else { + clutter_actor_hide(priv->scale_actor); + } + level = priv->map->current_level; tile = champlain_zoom_level_get_nth_tile(level, 0); m_per_pixel = 2 * M_PI * 6378100 * sin(M_PI/2 - M_PI / 180*priv->latitude) / @@ -1044,6 +1050,8 @@ create_scale (ChamplainView *view) view); g_signal_connect (priv->viewport, "notify::y-origin", G_CALLBACK (update_scale), view); + g_signal_connect (view, "notify::display-scale", + G_CALLBACK (update_scale), view); scale = clutter_cairo_texture_new (SCALE_WIDTH, SCALE_HEIGHT); cr = clutter_cairo_texture_create (CLUTTER_CAIRO_TEXTURE (scale)); @@ -2786,3 +2794,21 @@ champlain_view_remove_polygon (ChamplainView *view, g_object_unref (polygon); } + +void +champlain_view_show_scale (ChamplainView* view) +{ + g_return_if_fail (CHAMPLAIN_IS_VIEW (view)); + + g_object_set (G_OBJECT (view), "display-scale", TRUE, NULL); +} + +void +champlain_view_hide_scale (ChamplainView* view) +{ + g_return_if_fail (CHAMPLAIN_IS_VIEW (view)); + + g_object_set (G_OBJECT (view), "display-scale", FALSE, NULL); + +} + diff --git a/champlain/champlain-view.h b/champlain/champlain-view.h index 85eb0e8..0549b08 100644 --- a/champlain/champlain-view.h +++ b/champlain/champlain-view.h @@ -147,6 +147,8 @@ void champlain_view_add_polygon (ChamplainView *view, void champlain_view_remove_polygon (ChamplainView *view, ChamplainPolygon *polygon); +void champlain_view_show_scale (ChamplainView *view); +void champlain_view_hide_scale (ChamplainView *view); G_END_DECLS