[libchamplain] Introduce ChamplainPoint and fix lots marker-related bugs
- From: Jiří Techet <jiritechet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libchamplain] Introduce ChamplainPoint and fix lots marker-related bugs
- Date: Wed, 9 Feb 2011 08:38:19 +0000 (UTC)
commit 248d5690fa6b76b6d143aa0274b301ae316e12a0
Author: JiÅ?Ã Techet <techet gmail com>
Date: Sun Jan 30 00:46:59 2011 +0100
Introduce ChamplainPoint and fix lots marker-related bugs
ChamplainPoint is a simple ChamplainMarker in the form of a point.
champlain/champlain-base-marker.c | 32 ++--
champlain/champlain-base-marker.h | 24 +--
champlain/champlain-layer.c | 223 +++++++++++++--------
champlain/champlain-layer.h | 13 +-
champlain/champlain-marshal.list | 2 +-
champlain/champlain-point.c | 396 ++++++++++++++++++++++++++++++++-----
champlain/champlain-point.h | 64 +++++--
champlain/champlain-view.c | 13 --
demos/launcher-gtk.c | 53 +++--
demos/markers.c | 10 +-
demos/polygons.c | 64 ++++---
11 files changed, 656 insertions(+), 238 deletions(-)
---
diff --git a/champlain/champlain-base-marker.c b/champlain/champlain-base-marker.c
index 1d0d460..250e318 100644
--- a/champlain/champlain-base-marker.c
+++ b/champlain/champlain-base-marker.c
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2008 Pierre-Luc Beaudoin <pierre-luc pierlux com>
+ * Copyright (C) 2011 Jiri Techet <techet gmail com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -52,9 +53,12 @@
enum
{
/* normal signals */
- LAST_SIGNAL
+ MOVE_BY_SIGNAL,
+ LAST_SIGNAL,
};
+static guint signals[LAST_SIGNAL] = { 0, };
+
enum
{
PROP_0,
@@ -256,7 +260,11 @@ champlain_base_marker_class_init (ChamplainBaseMarkerClass *marker_class)
g_param_spec_boolean ("movable", "Movable",
"The movable state of the marker",
FALSE, CHAMPLAIN_PARAM_READWRITE));
-
+
+ signals[MOVE_BY_SIGNAL] =
+ g_signal_new ("move-by", G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST, 0, NULL, NULL,
+ _champlain_marshal_VOID__FLOAT_FLOAT, G_TYPE_NONE, 2, G_TYPE_FLOAT, G_TYPE_FLOAT);
}
@@ -279,7 +287,7 @@ motion_event_cb (ClutterActor *stage,
gfloat dx = coord.x - priv->click_coord.x;
gfloat dy = coord.y - priv->click_coord.y;
- clutter_actor_move_by (CLUTTER_ACTOR (marker), dx, dy);
+ g_signal_emit_by_name (marker, "move-by", dx, dy);
}
return TRUE;
@@ -322,7 +330,7 @@ button_press_event_cb (ClutterActor *actor,
bevent->button != 1 ||
!stage)
{
- return swallow_event;
+ return FALSE;
}
if (priv->selectable)
@@ -340,16 +348,16 @@ button_press_event_cb (ClutterActor *actor,
"captured-event",
G_CALLBACK (motion_event_cb),
marker);
- }
-
- g_signal_connect (stage,
- "captured-event",
- G_CALLBACK (button_release_event_cb),
- marker);
+
+ g_signal_connect (stage,
+ "captured-event",
+ G_CALLBACK (button_release_event_cb),
+ marker);
- clutter_set_motion_events_enabled (FALSE);
+ clutter_set_motion_events_enabled (FALSE);
- swallow_event = TRUE;
+ swallow_event = TRUE;
+ }
}
return swallow_event;
diff --git a/champlain/champlain-base-marker.h b/champlain/champlain-base-marker.h
index 00ce68d..36b113b 100644
--- a/champlain/champlain-base-marker.h
+++ b/champlain/champlain-base-marker.h
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2008 Pierre-Luc Beaudoin <pierre-luc pierlux com>
+ * Copyright (C) 2011 Jiri Techet <techet gmail com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -74,6 +75,15 @@ void champlain_base_marker_set_position (ChamplainBaseMarker *marker,
gdouble longitude);
gdouble champlain_base_marker_get_latitude (ChamplainBaseMarker *marker);
gdouble champlain_base_marker_get_longitude (ChamplainBaseMarker *marker);
+
+void champlain_base_marker_set_selectable (ChamplainBaseMarker *marker,
+ gboolean value);
+gboolean champlain_base_marker_get_selectable (ChamplainBaseMarker *marker);
+
+void champlain_base_marker_set_movable (ChamplainBaseMarker *marker,
+ gboolean value);
+gboolean champlain_base_marker_get_movable (ChamplainBaseMarker *marker);
+
void champlain_base_marker_set_highlighted (ChamplainBaseMarker *marker,
gboolean value);
gboolean champlain_base_marker_get_highlighted (ChamplainBaseMarker *marker);
@@ -85,20 +95,6 @@ void champlain_base_marker_animate_out (ChamplainBaseMarker *marker);
void champlain_base_marker_animate_out_with_delay (ChamplainBaseMarker *marker,
guint delay);
-void
-champlain_base_marker_set_selectable (ChamplainBaseMarker *marker,
- gboolean value);
-gboolean
-champlain_base_marker_get_selectable (ChamplainBaseMarker *marker);
-void
-champlain_base_marker_set_movable (ChamplainBaseMarker *marker,
- gboolean value);
-gboolean
-champlain_base_marker_get_movable (ChamplainBaseMarker *marker);
-
-
-
-
G_END_DECLS
#endif
diff --git a/champlain/champlain-layer.c b/champlain/champlain-layer.c
index 0a0fa18..38412f4 100644
--- a/champlain/champlain-layer.c
+++ b/champlain/champlain-layer.c
@@ -88,6 +88,9 @@ struct _ChamplainLayerPrivate
static void marker_highlighted_cb (ChamplainBaseMarker *marker,
G_GNUC_UNUSED GParamSpec *arg1,
ChamplainLayer *layer);
+
+static void redraw_polygon (ChamplainLayer *layer);
+
static void
champlain_layer_get_property (GObject *object,
@@ -369,20 +372,6 @@ champlain_layer_class_init (ChamplainLayerClass *klass)
}
-static gboolean
-button_release_cb (G_GNUC_UNUSED ClutterActor *actor,
- ClutterEvent *event,
- ChamplainLayer *layer)
-{
- if (clutter_event_get_button (event) != 1)
- return FALSE;
-
- champlain_layer_unselect_all (layer);
-
- return FALSE;
-}
-
-
static void
champlain_layer_init (ChamplainLayer *self)
{
@@ -405,10 +394,6 @@ champlain_layer_init (ChamplainLayer *self)
priv->polygon_actor = clutter_group_new ();
clutter_container_add_actor (CLUTTER_CONTAINER (self), priv->polygon_actor);
-
- clutter_actor_set_reactive (CLUTTER_ACTOR (self), TRUE);
- g_signal_connect (self, "button-release-event",
- G_CALLBACK (button_release_cb), self);
}
@@ -436,32 +421,28 @@ set_highlighted_all_but_one (ChamplainLayer *layer,
{
int i;
- for (i = 0; i < clutter_group_get_n_children (CLUTTER_GROUP (layer)); i++)
+ for (i = 1; i < clutter_group_get_n_children (CLUTTER_GROUP (layer)); i++)
{
ClutterActor *actor = clutter_group_get_nth_child (CLUTTER_GROUP (layer), i);
- if (CHAMPLAIN_IS_BASE_MARKER (actor))
- {
- ChamplainBaseMarker *marker = CHAMPLAIN_BASE_MARKER (actor);
-
- if (marker != not_highlighted)
- {
- g_signal_handlers_block_by_func (marker,
- G_CALLBACK (marker_highlighted_cb),
- layer);
-
- champlain_base_marker_set_highlighted (marker, highlight);
- champlain_base_marker_set_selectable (marker, layer->priv->mode != CHAMPLAIN_SELECTION_NONE);
-
- g_signal_handlers_unblock_by_func (marker,
- G_CALLBACK (marker_highlighted_cb),
- layer);
- }
+ ChamplainBaseMarker *marker = CHAMPLAIN_BASE_MARKER (actor);
+
+ if (marker != not_highlighted)
+ {
+ g_signal_handlers_block_by_func (marker,
+ G_CALLBACK (marker_highlighted_cb),
+ layer);
+
+ champlain_base_marker_set_highlighted (marker, highlight);
+ champlain_base_marker_set_selectable (marker, layer->priv->mode != CHAMPLAIN_SELECTION_NONE);
+
+ g_signal_handlers_unblock_by_func (marker,
+ G_CALLBACK (marker_highlighted_cb),
+ layer);
}
}
}
-
static void
marker_highlighted_cb (ChamplainBaseMarker *marker,
G_GNUC_UNUSED GParamSpec *arg1,
@@ -474,6 +455,58 @@ marker_highlighted_cb (ChamplainBaseMarker *marker,
}
+static void
+set_marker_position (ChamplainLayer *layer, ChamplainBaseMarker *marker)
+{
+ ChamplainLayerPrivate *priv = layer->priv;
+ gint x, y;
+
+ /* layer not yet added to the view */
+ if (priv->view == NULL)
+ return;
+
+ x = champlain_view_longitude_to_layer_x (priv->view,
+ champlain_base_marker_get_longitude (marker));
+ y = champlain_view_latitude_to_layer_y (priv->view,
+ champlain_base_marker_get_latitude (marker));
+
+ clutter_actor_set_position (CLUTTER_ACTOR (marker), x, y);
+}
+
+
+static void
+marker_position_notify (ChamplainBaseMarker *marker,
+ G_GNUC_UNUSED GParamSpec *pspec,
+ ChamplainLayer *layer)
+{
+ set_marker_position (layer, marker);
+ redraw_polygon (layer);
+}
+
+
+static void
+marker_move_by_cb (ChamplainBaseMarker *marker,
+ gfloat dx,
+ gfloat dy,
+ ChamplainLayer *layer)
+{
+ ChamplainLayerPrivate *priv = layer->priv;
+ ChamplainView *view = priv->view;
+ gdouble x, y, lat, lon;
+
+ x = champlain_view_longitude_to_x (view, champlain_base_marker_get_longitude (marker));
+ y = champlain_view_latitude_to_y (view, champlain_base_marker_get_latitude (marker));
+
+ x += dx;
+ y += dy;
+
+ lon = champlain_view_x_to_longitude (view, x);
+ lat = champlain_view_y_to_latitude (view, y);
+
+ champlain_base_marker_set_position (marker, lat, lon);
+}
+
+
/**
* champlain_layer_add_marker:
* @layer: a #ChamplainLayer
@@ -495,7 +528,15 @@ champlain_layer_add_marker (ChamplainLayer *layer,
g_signal_connect (G_OBJECT (marker), "notify::highlighted",
G_CALLBACK (marker_highlighted_cb), layer);
+ g_signal_connect (G_OBJECT (marker), "notify::latitude",
+ G_CALLBACK (marker_position_notify), layer);
+
+ g_signal_connect (G_OBJECT (marker), "move-by",
+ G_CALLBACK (marker_move_by_cb), layer);
+
clutter_container_add_actor (CLUTTER_CONTAINER (layer), CLUTTER_ACTOR (marker));
+ set_marker_position (layer, marker);
+ redraw_polygon (layer);
}
@@ -518,7 +559,11 @@ champlain_layer_remove_marker (ChamplainLayer *layer,
g_signal_handlers_disconnect_by_func (G_OBJECT (marker),
G_CALLBACK (marker_highlighted_cb), layer);
+ g_signal_handlers_disconnect_by_func (G_OBJECT (marker),
+ G_CALLBACK (marker_position_notify), layer);
+
clutter_container_remove_actor (CLUTTER_CONTAINER (layer), CLUTTER_ACTOR (marker));
+ redraw_polygon (layer);
}
@@ -538,16 +583,13 @@ champlain_layer_animate_in_all_markers (ChamplainLayer *layer)
g_return_if_fail (CHAMPLAIN_IS_LAYER (layer));
- for (i = 0; i < clutter_group_get_n_children (CLUTTER_GROUP (layer)); i++)
+ for (i = 1; i < clutter_group_get_n_children (CLUTTER_GROUP (layer)); i++)
{
ClutterActor *actor = clutter_group_get_nth_child (CLUTTER_GROUP (layer), i);
- if (CHAMPLAIN_IS_BASE_MARKER (actor))
- {
- ChamplainBaseMarker *marker = CHAMPLAIN_BASE_MARKER (actor);
+ ChamplainBaseMarker *marker = CHAMPLAIN_BASE_MARKER (actor);
- champlain_base_marker_animate_in_with_delay (marker, delay);
- delay += 50;
- }
+ champlain_base_marker_animate_in_with_delay (marker, delay);
+ delay += 50;
}
}
@@ -568,16 +610,13 @@ champlain_layer_animate_out_all_markers (ChamplainLayer *layer)
g_return_if_fail (CHAMPLAIN_IS_LAYER (layer));
- for (i = 0; i < clutter_group_get_n_children (CLUTTER_GROUP (layer)); i++)
+ for (i = 1; i < clutter_group_get_n_children (CLUTTER_GROUP (layer)); i++)
{
ClutterActor *actor = clutter_group_get_nth_child (CLUTTER_GROUP (layer), i);
- if (CHAMPLAIN_IS_BASE_MARKER (actor))
- {
- ChamplainBaseMarker *marker = CHAMPLAIN_BASE_MARKER (actor);
+ ChamplainBaseMarker *marker = CHAMPLAIN_BASE_MARKER (actor);
- champlain_base_marker_animate_out_with_delay (marker, delay);
- delay += 50;
- }
+ champlain_base_marker_animate_out_with_delay (marker, delay);
+ delay += 50;
}
}
@@ -597,7 +636,7 @@ champlain_layer_show_all_markers (ChamplainLayer *layer)
g_return_if_fail (CHAMPLAIN_IS_LAYER (layer));
- for (i = 0; i < clutter_group_get_n_children (CLUTTER_GROUP (layer)); i++)
+ for (i = 1; i < clutter_group_get_n_children (CLUTTER_GROUP (layer)); i++)
{
ClutterActor *marker = CLUTTER_ACTOR (clutter_group_get_nth_child (CLUTTER_GROUP (layer), i));
@@ -620,7 +659,7 @@ champlain_layer_hide_all_markers (ChamplainLayer *layer)
g_return_if_fail (CHAMPLAIN_IS_LAYER (layer));
- for (i = 0; i < clutter_group_get_n_children (CLUTTER_GROUP (layer)); i++)
+ for (i = 1; i < clutter_group_get_n_children (CLUTTER_GROUP (layer)); i++)
{
ClutterActor *marker = CLUTTER_ACTOR (clutter_group_get_nth_child (CLUTTER_GROUP (layer), i));
@@ -629,6 +668,39 @@ champlain_layer_hide_all_markers (ChamplainLayer *layer)
}
+void
+champlain_layer_set_all_markers_movable (ChamplainLayer *layer)
+{
+ guint i;
+
+ g_return_if_fail (CHAMPLAIN_IS_LAYER (layer));
+
+ for (i = 1; i < clutter_group_get_n_children (CLUTTER_GROUP (layer)); i++)
+ {
+ ChamplainBaseMarker *marker = CHAMPLAIN_BASE_MARKER (clutter_group_get_nth_child (CLUTTER_GROUP (layer), i));
+
+ champlain_base_marker_set_movable (marker, TRUE);
+ }
+}
+
+
+void
+champlain_layer_set_all_markers_unmovable (ChamplainLayer *layer)
+{
+ guint i;
+
+ g_return_if_fail (CHAMPLAIN_IS_LAYER (layer));
+
+ for (i = 1; i < clutter_group_get_n_children (CLUTTER_GROUP (layer)); i++)
+ {
+ ChamplainBaseMarker *marker = CHAMPLAIN_BASE_MARKER (clutter_group_get_nth_child (CLUTTER_GROUP (layer), i));
+
+ champlain_base_marker_set_movable (marker, FALSE);
+ }
+}
+
+
+
/**
* champlain_layer_get_selected_markers:
* @layer: a #ChamplainLayer
@@ -650,7 +722,7 @@ champlain_layer_get_selected_markers (ChamplainLayer *layer)
gint i, n_children;
n_children = clutter_group_get_n_children (CLUTTER_GROUP (layer));
- for (i = 0; i < n_children; i++)
+ for (i = 1; i < n_children; i++)
{
ClutterActor *actor = clutter_group_get_nth_child (CLUTTER_GROUP (layer), i);
@@ -760,22 +832,15 @@ relocate (ChamplainLayer *layer)
g_return_if_fail (CHAMPLAIN_IS_VIEW (priv->view));
n_children = clutter_group_get_n_children (CLUTTER_GROUP (layer));
- for (i = 0; i < n_children; i++)
+ for (i = 1; i < n_children; i++)
{
ClutterActor *actor = clutter_group_get_nth_child (CLUTTER_GROUP (layer), i);
- if (CHAMPLAIN_IS_BASE_MARKER (actor))
- {
- ChamplainBaseMarker *marker = CHAMPLAIN_BASE_MARKER (actor);
- gint x, y;
-
- x = champlain_view_longitude_to_layer_x (priv->view,
- champlain_base_marker_get_longitude (marker));
- y = champlain_view_latitude_to_layer_y (priv->view,
- champlain_base_marker_get_latitude (marker));
-
- clutter_actor_set_position (CLUTTER_ACTOR (marker), x, y);
- }
+ ChamplainBaseMarker *marker = CHAMPLAIN_BASE_MARKER (actor);
+
+ set_marker_position (layer, marker);
}
+
+ redraw_polygon (layer);
}
static void
@@ -801,6 +866,10 @@ redraw_polygon (ChamplainLayer *layer)
gdouble lon, lat;
gdouble x, y;
+ /* layer not yet added to the view */
+ if (view == NULL)
+ return;
+
clutter_actor_get_size (CLUTTER_ACTOR (view), &width, &height);
if (!priv->visible || width == 0.0 || height == 0.0)
@@ -818,26 +887,18 @@ redraw_polygon (ChamplainLayer *layer)
cr = clutter_cairo_texture_create (CLUTTER_CAIRO_TEXTURE (cairo_texture));
- /* Clear the drawing area */
- cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
- cairo_rectangle (cr, 0, 0, width, height);
- cairo_fill (cr);
-
cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
n_children = clutter_group_get_n_children (CLUTTER_GROUP (layer));
- for (i = 0; i < n_children; i++)
+ for (i = 1; i < n_children; i++)
{
ClutterActor *actor = clutter_group_get_nth_child (CLUTTER_GROUP (layer), i);
- if (CHAMPLAIN_IS_BASE_MARKER (actor))
- {
- ChamplainBaseMarker *marker = CHAMPLAIN_BASE_MARKER (actor);
- gfloat x, y;
+ ChamplainBaseMarker *marker = CHAMPLAIN_BASE_MARKER (actor);
+ gfloat x, y;
- x = champlain_view_longitude_to_x (view, champlain_base_marker_get_longitude (marker));
- y = champlain_view_latitude_to_y (view, champlain_base_marker_get_latitude (marker));
+ x = champlain_view_longitude_to_x (view, champlain_base_marker_get_longitude (marker));
+ y = champlain_view_latitude_to_y (view, champlain_base_marker_get_latitude (marker));
- cairo_line_to (cr, x, y);
- }
+ cairo_line_to (cr, x, y);
}
if (priv->closed_path)
diff --git a/champlain/champlain-layer.h b/champlain/champlain-layer.h
index ca58fdd..075eb26 100644
--- a/champlain/champlain-layer.h
+++ b/champlain/champlain-layer.h
@@ -98,8 +98,8 @@ void champlain_layer_animate_out_all_markers (ChamplainLayer *layer);
void champlain_layer_show_all_markers (ChamplainLayer *layer);
void champlain_layer_hide_all_markers (ChamplainLayer *layer);
-gboolean champlain_layer_marker_is_selected (ChamplainLayer *layer,
- ChamplainBaseMarker *marker);
+void champlain_layer_set_all_markers_movable (ChamplainLayer *layer);
+void champlain_layer_set_all_markers_unmovable (ChamplainLayer *layer);
void champlain_layer_select_all (ChamplainLayer *layer);
void champlain_layer_unselect_all (ChamplainLayer *layer);
@@ -113,22 +113,25 @@ ChamplainSelectionMode champlain_layer_get_selection_mode (
// ChamplainBaseMarker *markers[],
// gboolean animate);
+ClutterColor *champlain_layer_get_polygon_fill_color (ChamplainLayer *layer);
void champlain_layer_set_polygon_fill_color (ChamplainLayer *layer,
const ClutterColor *color);
+
+ClutterColor *champlain_layer_get_polygon_stroke_color (ChamplainLayer *layer);
void champlain_layer_set_polygon_stroke_color (ChamplainLayer *layer,
const ClutterColor *color);
-ClutterColor *champlain_layer_get_polygon_fill_color (ChamplainLayer *layer);
-ClutterColor *champlain_layer_get_polygon_stroke_color (ChamplainLayer *layer);
gboolean champlain_layer_get_polygon_fill (ChamplainLayer *layer);
void champlain_layer_set_polygon_fill (ChamplainLayer *layer,
gboolean value);
+
gboolean champlain_layer_get_polygon_stroke (ChamplainLayer *layer);
void champlain_layer_set_polygon_stroke (ChamplainLayer *layer,
gboolean value);
+
+gdouble champlain_layer_get_polygon_stroke_width (ChamplainLayer *layer);
void champlain_layer_set_polygon_stroke_width (ChamplainLayer *layer,
gdouble value);
-gdouble champlain_layer_get_polygon_stroke_width (ChamplainLayer *layer);
void champlain_layer_show_polygon (ChamplainLayer *layer);
void champlain_layer_hide_polygon (ChamplainLayer *layer);
diff --git a/champlain/champlain-marshal.list b/champlain/champlain-marshal.list
index 8b13789..e26b60a 100644
--- a/champlain/champlain-marshal.list
+++ b/champlain/champlain-marshal.list
@@ -1 +1 @@
-
+VOID:FLOAT,FLOAT
diff --git a/champlain/champlain-point.c b/champlain/champlain-point.c
index bcf7801..8f6aad7 100644
--- a/champlain/champlain-point.c
+++ b/champlain/champlain-point.c
@@ -1,8 +1,5 @@
/*
- * Copyright (C) 2009 Pierre-Luc Beaudoin <pierre-luc pierlux com>
- *
- * This file is inspired by clutter-color.c which is
- * Copyright (C) 2006 OpenedHand, and has the same license.
+ * Copyright (C) 2008 Pierre-Luc Beaudoin <pierre-luc pierlux com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,90 +17,391 @@
*/
/**
- * SECTION:champlain-point
- * @short_description: A base struct to store a latitude and longitude
+ * SECTION:champlain-marker
+ * @short_description: A marker to identify points of interest on a map
+ *
+ * Markers reprensent points of interest on a map. Markers need to be placed on
+ * a layer (a #ChamplainLayer). Layers have to be added to a #ChamplainView for
+ * the markers to show on the map.
+ *
+ * A marker is nothing more than a regular #ClutterActor. You can draw on it
+ * what ever you want. Set the markers position on the map
+ * using #champlain_marker_set_position.
+ *
+ * Champlain has a default type of markers with text. To create one,
+ * use #champlain_marker_new_with_text.
+ */
+
+#include "config.h"
+
+#include "champlain-marker.h"
+
+#include "champlain.h"
+#include "champlain-base-marker.h"
+#include "champlain-defines.h"
+#include "champlain-marshal.h"
+#include "champlain-private.h"
+#include "champlain-tile.h"
+
+#include <clutter/clutter.h>
+#include <glib.h>
+#include <glib-object.h>
+#include <cairo.h>
+#include <math.h>
+#include <string.h>
+
+#define DEFAULT_FONT_NAME "Sans 11"
+
+static ClutterColor SELECTED_COLOR = { 0x00, 0x33, 0xcc, 0xff };
+
+static ClutterColor DEFAULT_COLOR = { 0x33, 0x33, 0x33, 0xff };
+
+enum
+{
+ /* normal signals */
+ LAST_SIGNAL
+};
+
+enum
+{
+ PROP_0,
+ PROP_COLOR,
+ PROP_SIZE,
+};
+
+/* static guint champlain_marker_signals[LAST_SIGNAL] = { 0, }; */
+
+struct _ChamplainPointPrivate
+{
+ ClutterColor *color;
+ gdouble size;
+
+ guint redraw_id;
+};
+
+G_DEFINE_TYPE (ChamplainPoint, champlain_point, CHAMPLAIN_TYPE_BASE_MARKER);
+
+#define GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE ((obj), CHAMPLAIN_TYPE_POINT, ChamplainPointPrivate))
+
+static void draw_marker (ChamplainPoint *marker);
+
+/**
+ * champlain_marker_set_highlight_color:
+ * @color: a #ClutterColor
+ *
+ * Changes the highlight color, this is to ensure a better integration with
+ * the desktop, this is automatically done by GtkChamplainEmbed.
+ *
+ * Since: 0.4
+ */
+void
+champlain_point_set_highlight_color (ClutterColor *color)
+{
+ SELECTED_COLOR.red = color->red;
+ SELECTED_COLOR.green = color->green;
+ SELECTED_COLOR.blue = color->blue;
+ SELECTED_COLOR.alpha = color->alpha;
+}
+
+
+/**
+ * champlain_marker_get_highlight_color:
+ *
+ * Gets the highlight color.
*
- * A base struct to store a latitude and longitude.
+ * Returns: the highlight color. Should not be freed.
*
+ * Since: 0.4.1
*/
+const ClutterColor *
+champlain_point_get_highlight_color ()
+{
+ return &SELECTED_COLOR;
+}
+
+
+
+static void
+champlain_point_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ ChamplainPointPrivate *priv = CHAMPLAIN_POINT (object)->priv;
+
+ switch (prop_id)
+ {
+ case PROP_COLOR:
+ clutter_value_set_color (value, priv->color);
+ break;
+
+ case PROP_SIZE:
+ g_value_set_double (value, priv->size);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
-#include "champlain-point.h"
-GType
-champlain_point_get_type (void)
+static void
+champlain_point_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- static GType type = 0;
+ ChamplainPoint *marker = CHAMPLAIN_POINT (object);
- if (G_UNLIKELY (type == 0))
+ switch (prop_id)
{
- type = g_boxed_type_register_static (g_intern_static_string ("ChamplainPoint"),
- (GBoxedCopyFunc) champlain_point_copy,
- (GBoxedFreeFunc) champlain_point_free);
+ case PROP_COLOR:
+ champlain_point_set_color (marker, clutter_value_get_color (value));
+ break;
+
+ case PROP_SIZE:
+ champlain_point_set_size (marker, g_value_get_double (value));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
+}
+
- return type;
+static void
+champlain_point_dispose (GObject *object)
+{
+// ChamplainPointPrivate *priv = CHAMPLAIN_POINT (object)->priv;
+
+ G_OBJECT_CLASS (champlain_point_parent_class)->dispose (object);
+}
+
+
+static void
+champlain_point_finalize (GObject *object)
+{
+ ChamplainPointPrivate *priv = CHAMPLAIN_POINT (object)->priv;
+
+ if (priv->color)
+ {
+ clutter_color_free (priv->color);
+ priv->color = NULL;
+ }
+
+ G_OBJECT_CLASS (champlain_point_parent_class)->finalize (object);
+}
+
+
+static void
+champlain_point_class_init (ChamplainPointClass *markerClass)
+{
+ g_type_class_add_private (markerClass, sizeof (ChamplainPointPrivate));
+
+ GObjectClass *object_class = G_OBJECT_CLASS (markerClass);
+ object_class->finalize = champlain_point_finalize;
+ object_class->dispose = champlain_point_dispose;
+ object_class->get_property = champlain_point_get_property;
+ object_class->set_property = champlain_point_set_property;
+
+ /**
+ * ChamplainMarker:color:
+ *
+ * The marker's color
+ *
+ * Since: 0.4
+ */
+ g_object_class_install_property (object_class, PROP_COLOR,
+ clutter_param_spec_color ("color", "Color", "The marker's color",
+ &DEFAULT_COLOR, CHAMPLAIN_PARAM_READWRITE));
+
+ /**
+ * TODO
+ */
+ g_object_class_install_property (object_class, PROP_SIZE,
+ g_param_spec_double ("size", "Size", "The point size", 0, G_MAXDOUBLE,
+ 12, CHAMPLAIN_PARAM_READWRITE));
+}
+
+
+static void
+draw_marker (ChamplainPoint *marker)
+{
+ ChamplainPointPrivate *priv = marker->priv;
+ ClutterActor *cairo_texture;
+ cairo_t *cr;
+ gdouble size = priv->size;
+ gdouble radius = size / 2.0;
+ ClutterColor *color;
+
+ clutter_group_remove_all (CLUTTER_GROUP (marker));
+ cairo_texture = clutter_cairo_texture_new (size, size);
+ clutter_container_add_actor (CLUTTER_CONTAINER (marker), cairo_texture);
+ clutter_actor_set_anchor_point (CLUTTER_ACTOR (marker), radius, radius);
+
+ cr = clutter_cairo_texture_create (CLUTTER_CAIRO_TEXTURE (cairo_texture));
+
+ if (champlain_base_marker_get_highlighted (CHAMPLAIN_BASE_MARKER (marker)))
+ color = &SELECTED_COLOR;
+ else
+ color = priv->color;
+
+ cairo_set_source_rgba (cr,
+ color->red / 255.0,
+ color->green / 255.0,
+ color->blue / 255.0,
+ color->alpha / 255.0);
+
+ cairo_arc (cr, radius, radius, radius, 0, 2 * M_PI);
+ cairo_fill (cr);
+
+
+ cairo_fill_preserve (cr);
+ cairo_set_line_width (cr, 1.0);
+ cairo_stroke (cr);
+
+ cairo_destroy (cr);
+}
+
+
+static void
+notify_highlighted (GObject *gobject,
+ G_GNUC_UNUSED GParamSpec *pspec,
+ G_GNUC_UNUSED gpointer user_data)
+{
+ draw_marker (CHAMPLAIN_POINT (gobject));
+}
+
+
+
+static void
+champlain_point_init (ChamplainPoint *marker)
+{
+ ChamplainPointPrivate *priv = GET_PRIVATE (marker);
+
+ marker->priv = priv;
+
+ priv->color = clutter_color_copy (&DEFAULT_COLOR);
+ priv->size = 12;
+
+ draw_marker (marker);
+
+ g_signal_connect (marker, "notify::highlighted", G_CALLBACK (notify_highlighted), NULL);
}
/**
- * champlain_point_copy:
- * @point: a #ChamplainPoint
+ * champlain_marker_new:
*
- * Makes a copy of the point structure. The result must be
- * freed using champlain_point_free().
+ * Creates a new instance of #ChamplainMarker.
*
- * Return value: an allocated copy of @point.
+ * Returns: a new #ChamplainMarker ready to be used as a #ClutterActor.
*
- * Since: 0.4
+ * Since: 0.2
*/
-ChamplainPoint *
-champlain_point_copy (const ChamplainPoint *point)
+ClutterActor *
+champlain_point_new (void)
{
- if (G_LIKELY (point != NULL))
- return g_slice_dup (ChamplainPoint, point);
-
- return NULL;
+ return CLUTTER_ACTOR (g_object_new (CHAMPLAIN_TYPE_POINT, NULL));
}
+
+
/**
- * champlain_point_free:
- * @point: a #ChamplainPoint
+ * champlain_marker_new_full:
+ * @text: The text
+ * @actor: The image
*
- * Frees a point structure created with #champlain_point_new or
- * #champlain_point_copy
+ * Creates a new instance of #ChamplainMarker consisting of a custom #ClutterActor.
+ *
+ * Returns: a new #ChamplainMarker with a drawn marker containing the given
+ * image.
*
* Since: 0.4
*/
+ClutterActor *
+champlain_point_new_full (gdouble size,
+ const ClutterColor *color)
+{
+ ChamplainPoint *marker = CHAMPLAIN_POINT (champlain_point_new ());
+
+ champlain_point_set_size (marker, size);
+ champlain_point_set_color (marker, color);
+
+ return CLUTTER_ACTOR (marker);
+}
+
+
+/**
+ */
void
-champlain_point_free (ChamplainPoint *point)
+champlain_point_set_size (ChamplainPoint *point,
+ gdouble size)
{
- if (G_LIKELY (point != NULL))
- g_slice_free (ChamplainPoint, point);
+ g_return_if_fail (CHAMPLAIN_IS_POINT (point));
+
+ point->priv->size = size;
+ g_object_notify (G_OBJECT (point), "size");
+ draw_marker (point);
}
/**
- * champlain_point_new:
- * @lat: the latitude
- * @lon: the longitude
- *
- * Creates an instance of #ChamplainPoint.
+ */
+gdouble
+champlain_point_get_size (ChamplainPoint *point)
+{
+ g_return_val_if_fail (CHAMPLAIN_IS_POINT (point), 0);
+
+ return point->priv->size;
+}
+
+
+/**
+ * champlain_point_set_color:
+ * @point: The point
+ * @color: (allow-none): The point's background color or NULL to reset the background to the
+ * default color. The color parameter is copied.
*
- * Return value: a newly allocated #ChamplainPoint to be freed with #champlain_point_free
+ * Set the point's background color.
*
* Since: 0.4
*/
-ChamplainPoint *
-champlain_point_new (gdouble lat,
- gdouble lon)
+void
+champlain_point_set_color (ChamplainPoint *point,
+ const ClutterColor *color)
{
- ChamplainPoint *point;
+ g_return_if_fail (CHAMPLAIN_IS_POINT (point));
+
+ ChamplainPointPrivate *priv = point->priv;
- point = g_slice_new (ChamplainPoint);
+ if (priv->color != NULL)
+ clutter_color_free (priv->color);
+
+ if (color == NULL)
+ color = &DEFAULT_COLOR;
+
+ priv->color = clutter_color_copy (color);
+ g_object_notify (G_OBJECT (point), "color");
+ draw_marker (point);
+}
- point->lat = lat;
- point->lon = lon;
+/**
+ * champlain_point_get_color:
+ * @point: The point
+ *
+ * Gets the point's color.
+ *
+ * Returns: the point's color.
+ *
+ * Since: 0.4
+ */
+ClutterColor *
+champlain_point_get_color (ChamplainPoint *point)
+{
+ g_return_val_if_fail (CHAMPLAIN_IS_POINT (point), NULL);
- return point;
+ return point->priv->color;
}
diff --git a/champlain/champlain-point.h b/champlain/champlain-point.h
index 6e4b507..24486af 100644
--- a/champlain/champlain-point.h
+++ b/champlain/champlain-point.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009 Pierre-Luc Beaudoin <pierre-luc pierlux com>
+ * Copyright (C) 2008 Pierre-Luc Beaudoin <pierre-luc pierlux com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -23,35 +23,65 @@
#ifndef CHAMPLAIN_POINT_H
#define CHAMPLAIN_POINT_H
+#include <champlain/champlain-base-marker.h>
+
#include <glib-object.h>
+#include <clutter/clutter.h>
G_BEGIN_DECLS
+#define CHAMPLAIN_TYPE_POINT champlain_point_get_type ()
+
+#define CHAMPLAIN_POINT(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), CHAMPLAIN_TYPE_POINT, ChamplainPoint))
+
+#define CHAMPLAIN_POINT_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST ((klass), CHAMPLAIN_TYPE_POINT, ChamplainPointClass))
+
+#define CHAMPLAIN_IS_POINT(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CHAMPLAIN_TYPE_POINT))
+
+#define CHAMPLAIN_IS_POINT_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE ((klass), CHAMPLAIN_TYPE_POINT))
+
+#define CHAMPLAIN_POINT_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), CHAMPLAIN_TYPE_POINT, ChamplainPointClass))
+
+typedef struct _ChamplainPointPrivate ChamplainPointPrivate;
+
typedef struct _ChamplainPoint ChamplainPoint;
+typedef struct _ChamplainPointClass ChamplainPointClass;
-/**
- * ChamplainPoint:
- * @lat: latitude
- * @lon: longitude
- *
- * A base struct to store a latitude and longitude.
- */
struct _ChamplainPoint
{
- double lat;
- double lon;
+ ChamplainBaseMarker base;
+
+ ChamplainPointPrivate *priv;
+};
+
+struct _ChamplainPointClass
+{
+ ChamplainBaseMarkerClass parent_class;
};
-GType champlain_point_get_type (void) G_GNUC_CONST;
-#define CHAMPLAIN_TYPE_POINT (champlain_point_get_type ())
-#define CHAMPLAIN_POINT(x) ((ChamplainPoint *) (x))
+GType champlain_point_get_type (void);
+
+ClutterActor *champlain_point_new (void);
+
+ClutterActor *champlain_point_new_full (gdouble size,
+ const ClutterColor *color);
+
+void champlain_point_set_color (ChamplainPoint *marker,
+ const ClutterColor *color);
-ChamplainPoint *champlain_point_copy (const ChamplainPoint *point);
+ClutterColor *champlain_point_get_color (ChamplainPoint *marker);
-void champlain_point_free (ChamplainPoint *point);
+void champlain_point_set_highlight_color (ClutterColor *color);
+const ClutterColor *champlain_point_get_highlight_color (void);
-ChamplainPoint *champlain_point_new (gdouble lat,
- gdouble lon);
+void champlain_point_set_size (ChamplainPoint *point,
+ gdouble size);
+gdouble champlain_point_get_size (ChamplainPoint *point);
G_END_DECLS
diff --git a/champlain/champlain-view.c b/champlain/champlain-view.c
index f0172db..ff8fe6f 100644
--- a/champlain/champlain-view.c
+++ b/champlain/champlain-view.c
@@ -1072,17 +1072,6 @@ create_license (ChamplainView *view)
clutter_actor_raise_top (priv->license_actor);
}
-/*
-static gboolean
-button_release_cb (G_GNUC_UNUSED ClutterActor *actor,
- ClutterEvent *event,
- ChamplainView *view)
-{
- DEBUG_LOG ()
-
- return TRUE;
-}
-*/
static void
update_scale (ChamplainView *view)
@@ -1351,8 +1340,6 @@ champlain_view_init (ChamplainView *view)
G_CALLBACK (panning_completed), view);
g_signal_connect (priv->finger_scroll, "button-press-event",
G_CALLBACK (finger_scroll_button_press_cb), view);
-// g_signal_connect_after (priv->finger_scroll, "button-release-event",
-// G_CALLBACK (button_release_cb), view);
clutter_stage_set_key_focus (CLUTTER_STAGE (clutter_stage_get_default ()),
priv->finger_scroll);
diff --git a/demos/launcher-gtk.c b/demos/launcher-gtk.c
index 8a2aba7..9d55b93 100644
--- a/demos/launcher-gtk.c
+++ b/demos/launcher-gtk.c
@@ -28,7 +28,7 @@
#define COL_ID 0
#define COL_NAME 1
-//static ChamplainPolygon *polygon;
+static ChamplainLayer *polygon;
static gboolean destroying = FALSE;
/*
@@ -48,12 +48,14 @@ toggle_layer (GtkToggleButton *widget,
{
if (gtk_toggle_button_get_active (widget))
{
-// champlain_polygon_show (polygon);
+ champlain_layer_show_polygon (polygon);
+ champlain_layer_animate_in_all_markers (polygon);
champlain_layer_animate_in_all_markers (CHAMPLAIN_LAYER (layer));
}
else
{
-// champlain_polygon_hide (polygon);
+ champlain_layer_hide_polygon (polygon);
+ champlain_layer_animate_out_all_markers (polygon);
champlain_layer_animate_out_all_markers (CHAMPLAIN_LAYER (layer));
}
}
@@ -198,6 +200,18 @@ build_combo_box (GtkComboBox *box)
}
+static void
+append_point (ChamplainLayer *layer, gdouble lon, gdouble lat)
+{
+ ClutterActor *point;
+ static ClutterColor color = { 0xa4, 0x00, 0x00, 0xff };
+
+ point = champlain_point_new_full (10, &color);
+ champlain_base_marker_set_position (CHAMPLAIN_BASE_MARKER (point), lon, lat);
+ champlain_layer_add_marker (layer, CHAMPLAIN_BASE_MARKER (point));
+}
+
+
int
main (int argc,
char *argv[])
@@ -244,26 +258,23 @@ main (int argc,
layer = create_marker_layer (view);
champlain_view_add_layer (view, layer);
- champlain_layer_hide_all_markers (CHAMPLAIN_LAYER (layer));
-// polygon = champlain_polygon_new ();
+ polygon = champlain_layer_new_full (CHAMPLAIN_SELECTION_NONE);
/* Cheap approx of Highway 10 */
-/* champlain_polygon_append_point (polygon, 45.4095, -73.3197);
- champlain_polygon_append_point (polygon, 45.4104, -73.2846);
- champlain_polygon_append_point (polygon, 45.4178, -73.2239);
- champlain_polygon_append_point (polygon, 45.4176, -73.2181);
- champlain_polygon_append_point (polygon, 45.4151, -73.2126);
- champlain_polygon_append_point (polygon, 45.4016, -73.1926);
- champlain_polygon_append_point (polygon, 45.3994, -73.1877);
- champlain_polygon_append_point (polygon, 45.4000, -73.1815);
- champlain_polygon_append_point (polygon, 45.4151, -73.1218);
- champlain_polygon_set_stroke_width (polygon, 5.0);
- g_object_set (G_OBJECT (polygon),
- "mark-points", TRUE,
- NULL);
- champlain_view_add_polygon (CHAMPLAIN_VIEW (view), polygon);
- champlain_polygon_hide (polygon);
-*/
+ append_point (polygon, 45.4095, -73.3197);
+ append_point (polygon, 45.4104, -73.2846);
+ append_point (polygon, 45.4178, -73.2239);
+ append_point (polygon, 45.4176, -73.2181);
+ append_point (polygon, 45.4151, -73.2126);
+ append_point (polygon, 45.4016, -73.1926);
+ append_point (polygon, 45.3994, -73.1877);
+ append_point (polygon, 45.4000, -73.1815);
+ append_point (polygon, 45.4151, -73.1218);
+ champlain_layer_set_polygon_stroke_width (polygon, 5.0);
+ champlain_layer_hide_all_markers (polygon);
+ champlain_layer_hide_polygon (polygon);
+ champlain_view_add_layer (view, polygon);
+
gtk_widget_set_size_request (widget, 640, 480);
bbox = gtk_hbox_new (FALSE, 10);
diff --git a/demos/markers.c b/demos/markers.c
index 53527fd..9fd8908 100644
--- a/demos/markers.c
+++ b/demos/markers.c
@@ -48,7 +48,7 @@ create_marker_layer (G_GNUC_UNUSED ChamplainView *view)
ClutterActor *layer_actor;
ClutterColor orange = { 0xf3, 0x94, 0x07, 0xbb };
- layer = champlain_layer_new_full (CHAMPLAIN_SELECTION_MULTIPLE);
+ layer = champlain_layer_new_full (CHAMPLAIN_SELECTION_SINGLE);
layer_actor = CLUTTER_ACTOR (layer);
marker = champlain_marker_new_with_text ("Montréal\n<span size=\"xx-small\">Québec</span>",
@@ -73,6 +73,7 @@ create_marker_layer (G_GNUC_UNUSED ChamplainView *view)
marker = champlain_marker_new_from_file ("/usr/share/icons/gnome/24x24/emblems/emblem-generic.png", NULL);
champlain_marker_set_text (CHAMPLAIN_MARKER (marker), "New York");
champlain_base_marker_set_position (CHAMPLAIN_BASE_MARKER (marker), 40.77, -73.98);
+ champlain_marker_set_draw_background (CHAMPLAIN_MARKER (marker), FALSE);
champlain_layer_add_marker (layer, CHAMPLAIN_BASE_MARKER (marker));
marker = champlain_marker_new_from_file ("/usr/share/icons/gnome/24x24/emblems/emblem-important.png", NULL);
@@ -80,11 +81,18 @@ create_marker_layer (G_GNUC_UNUSED ChamplainView *view)
-70.764141);
champlain_layer_add_marker (layer, CHAMPLAIN_BASE_MARKER (marker));
+ marker = champlain_point_new ();
+ champlain_base_marker_set_position (CHAMPLAIN_BASE_MARKER (marker), 45.130885,
+ -65.764141);
+ champlain_layer_add_marker (layer, CHAMPLAIN_BASE_MARKER (marker));
+
marker = champlain_marker_new_from_file ("/usr/share/icons/gnome/24x24/emblems/emblem-favorite.png", NULL);
champlain_marker_set_draw_background (CHAMPLAIN_MARKER (marker), FALSE);
champlain_base_marker_set_position (CHAMPLAIN_BASE_MARKER (marker), 45.41484,
-71.918907);
champlain_layer_add_marker (layer, CHAMPLAIN_BASE_MARKER (marker));
+
+ champlain_layer_set_all_markers_movable (layer);
clutter_actor_show (layer_actor);
return layer;
diff --git a/demos/polygons.c b/demos/polygons.c
index fa5e638..8923e93 100644
--- a/demos/polygons.c
+++ b/demos/polygons.c
@@ -66,12 +66,24 @@ make_button (char *text)
}
+static void
+append_point (ChamplainLayer *layer, gdouble lon, gdouble lat)
+{
+ ClutterActor *point;
+ static ClutterColor color = { 0xa4, 0x00, 0x00, 0xff };
+
+ point = champlain_point_new_full (10, &color);
+ champlain_base_marker_set_position (CHAMPLAIN_BASE_MARKER (point), lon, lat);
+ champlain_layer_add_marker (layer, CHAMPLAIN_BASE_MARKER (point));
+}
+
+
int
main (int argc,
char *argv[])
{
ClutterActor *actor, *stage, *buttons, *button;
-// ChamplainPolygon *polygon;
+ ChamplainLayer *layer;
gfloat width, total_width = 0;;
g_thread_init (NULL);
@@ -110,31 +122,35 @@ main (int argc,
clutter_container_add_actor (CLUTTER_CONTAINER (stage), buttons);
/* draw a line */
-// polygon = champlain_polygon_new ();
+ layer = champlain_layer_new_full (CHAMPLAIN_SELECTION_NONE);
/* Cheap approx of Highway 10 */
-/* champlain_polygon_append_point (polygon, 45.4095, -73.3197);
- champlain_polygon_append_point (polygon, 45.4104, -73.2846);
- champlain_polygon_append_point (polygon, 45.4178, -73.2239);
- champlain_polygon_append_point (polygon, 45.4176, -73.2181);
- champlain_polygon_append_point (polygon, 45.4151, -73.2126);
- champlain_polygon_append_point (polygon, 45.4016, -73.1926);
- champlain_polygon_append_point (polygon, 45.3994, -73.1877);
- champlain_polygon_append_point (polygon, 45.4000, -73.1815);
- champlain_polygon_append_point (polygon, 45.4151, -73.1218);
- champlain_polygon_set_stroke_width (polygon, 5.0);
- champlain_view_add_polygon (CHAMPLAIN_VIEW (actor), polygon);
-*/
+ append_point (layer, 45.4095, -73.3197);
+ append_point (layer, 45.4104, -73.2846);
+ append_point (layer, 45.4178, -73.2239);
+ append_point (layer, 45.4176, -73.2181);
+ append_point (layer, 45.4151, -73.2126);
+ append_point (layer, 45.4016, -73.1926);
+ append_point (layer, 45.3994, -73.1877);
+ append_point (layer, 45.4000, -73.1815);
+ append_point (layer, 45.4151, -73.1218);
+ champlain_layer_set_polygon_stroke_width (layer, 5.0);
+ champlain_layer_hide_all_markers (layer);
+ champlain_layer_show_polygon (layer);
+ champlain_view_add_layer (CHAMPLAIN_VIEW (actor), layer);
+
/* draw a polygon */
-/* polygon = champlain_polygon_new ();
- champlain_polygon_append_point (polygon, 45.1386, -73.9196);
- champlain_polygon_append_point (polygon, 45.1229, -73.8991);
- champlain_polygon_append_point (polygon, 45.0946, -73.9531);
- champlain_polygon_append_point (polygon, 45.1085, -73.9714);
- champlain_polygon_append_point (polygon, 45.1104, -73.9761);
- g_object_set (polygon, "closed-path", TRUE, NULL);
- g_object_set (polygon, "fill", TRUE, NULL);
- champlain_view_add_polygon (CHAMPLAIN_VIEW (actor), polygon);
-*/
+ layer = champlain_layer_new_full (CHAMPLAIN_SELECTION_NONE);
+ append_point (layer, 45.1386, -73.9196);
+ append_point (layer, 45.1229, -73.8991);
+ append_point (layer, 45.0946, -73.9531);
+ append_point (layer, 45.1085, -73.9714);
+ append_point (layer, 45.1104, -73.9761);
+ g_object_set (layer, "closed-path", TRUE, NULL);
+ g_object_set (layer, "fill", TRUE, NULL);
+ champlain_layer_hide_all_markers (layer);
+ champlain_layer_show_polygon (layer);
+ champlain_view_add_layer (CHAMPLAIN_VIEW (actor), layer);
+
/* Finish initialising the map view */
g_object_set (G_OBJECT (actor), "zoom-level", 8,
"scroll-mode", CHAMPLAIN_SCROLL_MODE_KINETIC, NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]