#include "config.h"
#include "champlain_defines.h"
+#include "champlain_private.h"
#include "champlain.h"
#include "champlain-marshal.h"
#include "champlainview.h"
#define CHAMPLAIN_VIEW_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), CHAMPLAIN_TYPE_VIEW, ChamplainViewPrivate))
-#define CHAMPLAIN_PARAM_READABLE \
- (G_PARAM_READABLE | \
- G_PARAM_STATIC_NICK | G_PARAM_STATIC_NAME | G_PARAM_STATIC_BLURB)
-
-#define CHAMPLAIN_PARAM_READWRITE \
- (G_PARAM_READABLE | G_PARAM_WRITABLE | \
- G_PARAM_STATIC_NICK | G_PARAM_STATIC_NAME | G_PARAM_STATIC_BLURB)
-
struct _ChamplainViewPrivate
{
- GtkWidget *clutterEmbed;
+ GtkWidget *clutter_embed;
- ChamplainMapSource mapSource;
+ ChamplainMapSource map_source;
gint zoomLevel; // only used when the zoom-level property is set before map is created
+ ClutterActor *map_layer;
ClutterActor *viewport;
- ClutterActor *fingerScroll;
- GdkRectangle viewportSize;
+ ClutterActor *finger_scroll;
+ GdkRectangle viewport_size;
+
+ ClutterActor *user_layers;
+
Map *map;
gboolean offline;
if(priv->map == NULL)
{
- priv->map = map_new(priv->mapSource);
+ priv->map = map_new(priv->map_source);
map_load_level(priv->map, priv->zoomLevel);
- clutter_container_add_actor (CLUTTER_CONTAINER (priv->viewport), priv->map->current_level->group);
+ clutter_container_add_actor (CLUTTER_CONTAINER (priv->map_layer), priv->map->current_level->group);
g_object_notify(G_OBJECT(champlainView), "zoom-level");
g_object_notify(G_OBJECT(champlainView), "map-source");
}
- clutter_actor_set_size (priv->fingerScroll, priv->viewportSize.width, priv->viewportSize.height);
+ clutter_actor_set_size (priv->finger_scroll, priv->viewport_size.width, priv->viewport_size.height);
tidy_scrollable_get_adjustments (TIDY_SCROLLABLE (priv->viewport), &hadjust, &vadjust);
}
g_object_set (hadjust, "lower", lower, "upper", upper,
"step-increment", 1.0, "elastic", TRUE, NULL);
-
+
//tidy_adjustment_get_values (vadjust, NULL, &lower, &upper, NULL, NULL, NULL);
if (priv->map->current_level->level < 8)
break;
}
case PROP_MAP_SOURCE:
- g_value_set_int(value, priv->mapSource);
+ g_value_set_int(value, priv->map_source);
break;
case PROP_OFFLINE:
g_value_set_boolean(value, priv->offline);
case PROP_MAP_SOURCE:
{
ChamplainMapSource source = g_value_get_int(value);
- if (priv->mapSource != source)
+ if (priv->map_source != source)
{
- priv->mapSource = source;
+ priv->map_source = source;
if (priv->map) {
gint currentLevel = priv->map->current_level->level;
GdkPoint anchor = priv->map->current_level->anchor;
map_free(priv->map);
- priv->map = map_new(priv->mapSource);
+ priv->map = map_new(priv->map_source);
// Keep same zoom level
if (currentLevel > priv->map->zoom_levels)
{
ChamplainViewPrivate *priv = CHAMPLAIN_VIEW_GET_PRIVATE (champlainView);
- priv->mapSource = CHAMPLAIN_MAP_SOURCE_OPENSTREETMAP;
+ priv->map_source = CHAMPLAIN_MAP_SOURCE_OPENSTREETMAP;
priv->zoomLevel = 0;
priv->offline = FALSE;
}
rect.y == priv->viewportSize.y)
return;
- priv->viewportSize.x = rect.x;
- priv->viewportSize.y = rect.y;
+ priv->viewport_size.x = rect.x;
+ priv->viewport_size.y = rect.y;
- map_load_visible_tiles (priv->map, priv->viewportSize, priv->offline);
+ map_load_visible_tiles (priv->map, priv->viewport_size, priv->offline);
g_object_notify(G_OBJECT(champlainView), "longitude");
g_object_notify(G_OBJECT(champlainView), "latitude");
{
ChamplainViewPrivate *priv = CHAMPLAIN_VIEW_GET_PRIVATE (champlainView);
- priv->viewportSize.width = allocation->width;
- priv->viewportSize.height = allocation->height;
+ priv->viewport_size.width = allocation->width;
+ priv->viewport_size.height = allocation->height;
resize_viewport(champlainView);
- map_load_visible_tiles (priv->map, priv->viewportSize, priv->offline);
+ map_load_visible_tiles (priv->map, priv->viewport_size, priv->offline);
}
/**
view = CHAMPLAIN_VIEW (g_object_new (CHAMPLAIN_TYPE_VIEW, NULL));
ChamplainViewPrivate *priv = CHAMPLAIN_VIEW_GET_PRIVATE (view);
- priv->clutterEmbed = gtk_clutter_embed_new ();
- g_signal_connect (priv->clutterEmbed,
+ priv->clutter_embed = gtk_clutter_embed_new ();
+ g_signal_connect (priv->clutter_embed,
"size-allocate",
G_CALLBACK (view_size_allocated_cb),
view);
// Setup stage
- stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (priv->clutterEmbed));
+ stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (priv->clutter_embed));
clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);
- gtk_container_add (GTK_CONTAINER (view), priv->clutterEmbed);
+ gtk_container_add (GTK_CONTAINER (view), priv->clutter_embed);
// Setup viewport
priv->viewport = tidy_viewport_new ();
clutter_container_add_actor (CLUTTER_CONTAINER (priv->fingerScroll), priv->viewport);
clutter_container_add_actor (CLUTTER_CONTAINER (stage), priv->fingerScroll);
+ // Map Layer
+ priv->map_layer = clutter_group_new();
+ clutter_actor_show(priv->map_layer);
+ clutter_container_add_actor (CLUTTER_CONTAINER (priv->viewport), priv->map_layer);
+
+ // Setup user_layers
+ priv->user_layers = clutter_group_new();
+ clutter_actor_show(priv->user_layers);
+ clutter_container_add_actor (CLUTTER_CONTAINER (priv->viewport), priv->user_layers);
+ clutter_actor_raise(priv->user_layers, priv->map_layer);
return GTK_WIDGET (view);
}
g_object_notify(G_OBJECT(champlainView), "longitude");
g_object_notify(G_OBJECT(champlainView), "latitude");
- map_load_visible_tiles (priv->map, priv->viewportSize, priv->offline);
+ map_load_visible_tiles (priv->map, priv->viewport_size, priv->offline);
+}
+
+static void
+for_each_marker (ChamplainMarker *marker, ChamplainView* champlainView)
+{
+ ChamplainViewPrivate *priv = CHAMPLAIN_VIEW_GET_PRIVATE (champlainView);
+ ChamplainMarkerPrivate *marker_priv = CHAMPLAIN_MARKER_GET_PRIVATE (marker);
+
+ gint x, y;
+
+ x = priv->map->longitude_to_x(priv->map, marker_priv->lon, priv->map->current_level->level);
+ y = priv->map->latitude_to_y(priv->map, marker_priv->lat, priv->map->current_level->level);
+
+ clutter_actor_set_position(CLUTTER_ACTOR(marker), x - marker_priv->anchor.x, y - marker_priv->anchor.y);
+}
+
+static void
+for_each_layer (ClutterActor *layer, ChamplainView* champlainView)
+{
+ clutter_container_foreach(CLUTTER_CONTAINER(layer), CLUTTER_CALLBACK(for_each_marker), champlainView);
+}
+
+static void
+marker_reposition (ChamplainView* champlainView)
+{
+ ChamplainViewPrivate *priv = CHAMPLAIN_VIEW_GET_PRIVATE (champlainView);
+ clutter_container_foreach(CLUTTER_CONTAINER(priv->user_layers), CLUTTER_CALLBACK(for_each_layer), champlainView);
}
/**
clutter_container_remove_actor (CLUTTER_CONTAINER (priv->viewport), group);
clutter_container_add_actor (CLUTTER_CONTAINER (priv->viewport), priv->map->current_level->group);
champlain_view_center_on(champlainView, lon, lat);
+ marker_reposition(champlainView);
g_object_notify(G_OBJECT(champlainView), "zoom-level");
}
}
-
/**
* champlain_view_zoom_out:
* @view: a #ChamplainView
clutter_container_remove_actor (CLUTTER_CONTAINER (priv->viewport), group);
clutter_container_add_actor (CLUTTER_CONTAINER (priv->viewport), priv->map->current_level->group);
champlain_view_center_on(champlainView, lon, lat);
+ marker_reposition(champlainView);
g_object_notify(G_OBJECT(champlainView), "zoom-level");
}
}
+
+void
+champlain_view_add_layer (ChamplainView *champlainView, ClutterActor *layer)
+{
+ ChamplainViewPrivate *priv = CHAMPLAIN_VIEW_GET_PRIVATE (champlainView);
+ clutter_container_add(CLUTTER_CONTAINER(priv->user_layers), layer, NULL);
+ clutter_actor_raise_top(layer);
+
+ marker_reposition(champlainView);
+}