From acf2621a3903ee2b44348f116d4b603ed9b89725 Mon Sep 17 00:00:00 2001 From: Pierre-Luc Beaudoin Date: Sat, 4 Apr 2009 17:09:46 +0300 Subject: [PATCH] Introduce ChamplainBaseMarker as a parent to ChamplainMarker --- champlain/Makefile.am | 6 +- champlain/champlain-base-marker.c | 217 ++++++++++++++++++++++++++ champlain/champlain-base-marker.h | 68 ++++++++ champlain/champlain-defines.h | 3 - champlain/champlain-layer.c | 7 +- champlain/champlain-marker.c | 136 ++++------------ champlain/champlain-marker.h | 21 +-- champlain/champlain-private.h | 3 +- champlain/champlain-view.c | 6 +- champlain/champlain-view.h | 3 +- champlain/champlain.h | 1 + demos/animated-marker.c | 2 +- demos/launcher-gtk.c | 8 +- demos/launcher.c | 14 +- docs/reference/libchamplain-docs.sgml | 1 + docs/reference/libchamplain.types | 1 + 16 files changed, 359 insertions(+), 138 deletions(-) create mode 100644 champlain/champlain-base-marker.c create mode 100644 champlain/champlain-base-marker.h diff --git a/champlain/Makefile.am b/champlain/Makefile.am index ac343f4..9a6f139 100644 --- a/champlain/Makefile.am +++ b/champlain/Makefile.am @@ -19,6 +19,7 @@ libchamplain_headers = \ champlain-defines.h \ champlain-view.h \ champlain-layer.h \ + champlain-base-marker.h \ champlain-marker.h \ champlain-map.h \ champlain-zoom-level.h \ @@ -35,6 +36,7 @@ libchamplain_0_3_la_SOURCES = \ champlain-debug.c \ champlain-view.c \ champlain-layer.c \ + champlain-base-marker.c \ champlain-marker.c \ champlain-map.c \ champlain-zoom-level.c \ @@ -45,7 +47,8 @@ libchamplain_0_3_la_SOURCES = \ noinst_HEADERS = \ champlain-debug.h \ champlain-view.h \ - champlain-marker.c \ + champlain-base-marker.h \ + champlain-marker.h \ champlain-private.h \ champlain-map.h \ champlain-zoom-level.h \ @@ -65,6 +68,7 @@ libchamplain_include_HEADERS = \ champlain-network-map-source.h \ champlain-tile.h \ champlain-zoom-level.h \ + champlain-base-marker.h \ champlain-marker.h \ champlain-version.h diff --git a/champlain/champlain-base-marker.c b/champlain/champlain-base-marker.c new file mode 100644 index 0000000..368d733 --- /dev/null +++ b/champlain/champlain-base-marker.c @@ -0,0 +1,217 @@ +/* + * Copyright (C) 2008 Pierre-Luc Beaudoin + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * SECTION:champlain-base_marker + * @short_description: A base_marker to identify points of interest on a map + * + * BaseMarkers reprensent points of interest on a map. BaseMarkers need to be placed on + * a layer (a #ClutterGroup). Layers have to be added to a #ChamplainView for + * the base_markers to show on the map. + * + * A base_marker is nothing more than a regular #ClutterActor. You can draw on it + * what ever you want. Don't forget to set the anchor position in the base_marker + * using #champlain_base_marker_set_anchor. Set the base_markers position on the map + * using #champlain_base_marker_set_position. + * + * Champlain has a default type of base_markers with text. To create one, + * use #champlain_base_marker_new_with_label. + */ + +#include "config.h" + +#include "champlain-base-marker.h" + +#include "champlain.h" +#include "champlain-defines.h" +#include "champlain-marshal.h" +#include "champlain-private.h" +#include "champlain-map.h" +#include "champlain-tile.h" +#include "champlain-zoom-level.h" + +#include +#include +#include +#include +#include +#include + +enum +{ + /* normal signals */ + LAST_SIGNAL +}; + +enum +{ + PROP_0, + PROP_LONGITUDE, + PROP_LATITUDE, +}; + +//static guint champlain_base_marker_signals[LAST_SIGNAL] = { 0, }; + +G_DEFINE_TYPE (ChamplainBaseMarker, champlain_base_marker, CLUTTER_TYPE_GROUP); + +#define CHAMPLAIN_BASE_MARKER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), CHAMPLAIN_TYPE_BASE_MARKER, ChamplainBaseMarkerPrivate)) + +static void +champlain_base_marker_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + ChamplainBaseMarker *base_marker = CHAMPLAIN_BASE_MARKER (object); + ChamplainBaseMarkerPrivate *priv = CHAMPLAIN_BASE_MARKER_GET_PRIVATE (base_marker); + + switch (prop_id) + { + case PROP_LONGITUDE: + g_value_set_double (value, priv->lon); + break; + case PROP_LATITUDE: + g_value_set_double (value, priv->lat); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + } +} + +static void +champlain_base_marker_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + ChamplainBaseMarker *base_marker = CHAMPLAIN_BASE_MARKER (object); + ChamplainBaseMarkerPrivate *priv = CHAMPLAIN_BASE_MARKER_GET_PRIVATE (base_marker); + + switch (prop_id) + { + case PROP_LONGITUDE: + { + gdouble lon = g_value_get_double (value); + champlain_base_marker_set_position (base_marker, lon, priv->lat); + break; + } + case PROP_LATITUDE: + { + gdouble lat = g_value_get_double (value); + champlain_base_marker_set_position (base_marker, priv->lon, lat); + break; + } + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + } +} + +static void +champlain_base_marker_finalize (GObject *object) +{ + //ChamplainBaseMarker *base_marker = CHAMPLAIN_BASE_MARKER (object); + //ChamplainBaseMarkerPrivate *priv = CHAMPLAIN_BASE_MARKER_GET_PRIVATE (base_marker); + + G_OBJECT_CLASS (champlain_base_marker_parent_class)->finalize (object); +} + +static void +champlain_base_marker_class_init (ChamplainBaseMarkerClass *champlainBaseMarkerClass) +{ + g_type_class_add_private (champlainBaseMarkerClass, sizeof (ChamplainBaseMarkerPrivate)); + + GObjectClass *object_class = G_OBJECT_CLASS (champlainBaseMarkerClass); + object_class->finalize = champlain_base_marker_finalize; + object_class->get_property = champlain_base_marker_get_property; + object_class->set_property = champlain_base_marker_set_property; + + /** + * ChamplainBaseMarker:longitude: + * + * The longitude coordonate of the map + * + * Since: 0.4 + */ + g_object_class_install_property (object_class, PROP_LONGITUDE, + g_param_spec_double ("longitude", "Longitude", + "The longitude coordonate of the base_marker", + -180.0f, 180.0f, 0.0f, CHAMPLAIN_PARAM_READWRITE)); + + /** + * ChamplainBaseMarker:latitude: + * + * The latitude coordonate of the map + * + * Since: 0.4 + */ + g_object_class_install_property (object_class, PROP_LATITUDE, + g_param_spec_double ("latitude", "Latitude", + "The latitude coordonate of the base_marker", + -90.0f, 90.0f, 0.0f, CHAMPLAIN_PARAM_READWRITE)); + +} + +static void +champlain_base_marker_init (ChamplainBaseMarker *marker) +{ + ChamplainBaseMarkerPrivate *priv = CHAMPLAIN_BASE_MARKER_GET_PRIVATE (marker); + marker->priv = priv; +} + + +/** + * champlain_base_marker_new: + * + * Returns a new #ChamplainBaseMarker ready to be used as a #ClutterActor. + * + * Since: 0.4 + */ +ClutterActor * +champlain_base_marker_new (void) +{ + ChamplainBaseMarker *base_marker; + + base_marker = CHAMPLAIN_BASE_MARKER (g_object_new (CHAMPLAIN_TYPE_BASE_MARKER, NULL)); + //ChamplainBaseMarkerPrivate *priv = CHAMPLAIN_BASE_MARKER_GET_PRIVATE (base_marker); + + return CLUTTER_ACTOR (base_marker); +} + +/** + * champlain_base_marker_set_position: + * @base_marker: a #ChamplainBaseMarker + * @longitude: the longitude to center the map at + * @latitude: the longitude to center the map at + * + * Positions the base_marker on the map at the coordinates + * + * Since: 0.4 + */ +void +champlain_base_marker_set_position (ChamplainBaseMarker *champlainBaseMarker, gdouble latitude, gdouble longitude) +{ + g_return_if_fail (CHAMPLAIN_IS_BASE_MARKER (champlainBaseMarker)); + + ChamplainBaseMarkerPrivate *priv = CHAMPLAIN_BASE_MARKER_GET_PRIVATE (champlainBaseMarker); + + priv->lon = longitude; + priv->lat = latitude; + + g_object_notify (G_OBJECT (champlainBaseMarker), "latitude"); + g_object_notify (G_OBJECT (champlainBaseMarker), "longitude"); +} diff --git a/champlain/champlain-base-marker.h b/champlain/champlain-base-marker.h new file mode 100644 index 0000000..e303afc --- /dev/null +++ b/champlain/champlain-base-marker.h @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2008 Pierre-Luc Beaudoin + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#if !defined (__CHAMPLAIN_CHAMPLAIN_H_INSIDE__) && !defined (CHAMPLAIN_COMPILATION) +#error "Only can be included directly." +#endif + +#ifndef CHAMPLAIN_BASE_MARKER_H +#define CHAMPLAIN_BASE_MARKER_H + +#include + +#include +#include + +G_BEGIN_DECLS + +#define CHAMPLAIN_TYPE_BASE_MARKER (champlain_base_marker_get_type()) +#define CHAMPLAIN_BASE_MARKER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), CHAMPLAIN_TYPE_BASE_MARKER, ChamplainBaseMarker)) +#define CHAMPLAIN_BASE_MARKER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), CHAMPLAIN_TYPE_BASE_MARKER, ChamplainBaseMarkerClass)) +#define CHAMPLAIN_IS_BASE_MARKER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), CHAMPLAIN_TYPE_BASE_MARKER)) +#define CHAMPLAIN_IS_BASE_MARKER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), CHAMPLAIN_TYPE_BASE_MARKER)) +#define CHAMPLAIN_BASE_MARKER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), CHAMPLAIN_TYPE_BASE_MARKER, ChamplainBaseMarkerClass)) + +typedef struct _ChamplainBaseMarkerPrivate ChamplainBaseMarkerPrivate; + +typedef struct _ChamplainBaseMarker ChamplainBaseMarker; +typedef struct _ChamplainBaseMarkerClass ChamplainBaseMarkerClass; + + +struct _ChamplainBaseMarker +{ + ClutterGroup group; + + ChamplainBaseMarkerPrivate *priv; +}; + +struct _ChamplainBaseMarkerClass +{ + ClutterGroupClass parent_class; + +}; + +GType champlain_base_marker_get_type (void); + +ClutterActor *champlain_base_marker_new (void); + +void champlain_base_marker_set_position (ChamplainBaseMarker *marker, + gdouble longitude, gdouble latitude); + +G_END_DECLS + +#endif diff --git a/champlain/champlain-defines.h b/champlain/champlain-defines.h index 3534a5a..771b322 100644 --- a/champlain/champlain-defines.h +++ b/champlain/champlain-defines.h @@ -29,9 +29,6 @@ typedef struct _ChamplainView ChamplainView; typedef struct _ChamplainViewClass ChamplainViewClass; -typedef struct _ChamplainMarker ChamplainMarker; -typedef struct _ChamplainMarkerClass ChamplainMarkerClass; - #define CHAMPLAIN_PARAM_READABLE \ (G_PARAM_READABLE | \ G_PARAM_STATIC_NICK | G_PARAM_STATIC_NAME | G_PARAM_STATIC_BLURB) diff --git a/champlain/champlain-layer.c b/champlain/champlain-layer.c index a993cc1..3fe1d3d 100644 --- a/champlain/champlain-layer.c +++ b/champlain/champlain-layer.c @@ -32,6 +32,7 @@ #include "champlain-layer.h" #include "champlain-defines.h" +#include "champlain-base-marker.h" #include #include @@ -130,7 +131,7 @@ layer_add_cb (ClutterGroup *layer, GList* markers = clutter_container_get_children (CLUTTER_CONTAINER(layer)); gint size, i; gdouble y, tmp_y, low_y; - ChamplainMarker *lowest = NULL; + ChamplainBaseMarker *lowest = NULL; size = g_list_length (markers); g_object_get(G_OBJECT(marker), "latitude", &y, NULL); @@ -139,11 +140,11 @@ layer_add_cb (ClutterGroup *layer, for (i = 0; i < size; i++) { - ChamplainMarker *prev_marker = (ChamplainMarker*) g_list_nth_data (markers, i); + ChamplainBaseMarker *prev_marker = (ChamplainBaseMarker*) g_list_nth_data (markers, i); g_object_get(G_OBJECT(prev_marker), "latitude", &tmp_y, NULL); tmp_y = 90 - tmp_y; - if (prev_marker == (ChamplainMarker*) marker) + if (prev_marker == (ChamplainBaseMarker*) marker) continue; if (y < tmp_y && tmp_y < low_y) diff --git a/champlain/champlain-marker.c b/champlain/champlain-marker.c index bef0b76..defe131 100644 --- a/champlain/champlain-marker.c +++ b/champlain/champlain-marker.c @@ -38,6 +38,7 @@ #include "champlain-marker.h" #include "champlain.h" +#include "champlain-base-marker.h" #include "champlain-defines.h" #include "champlain-marshal.h" #include "champlain-private.h" @@ -61,15 +62,18 @@ enum enum { PROP_0, - PROP_LONGITUDE, - PROP_LATITUDE, - PROP_ANCHOR_X, - PROP_ANCHOR_Y, }; //static guint champlain_marker_signals[LAST_SIGNAL] = { 0, }; -G_DEFINE_TYPE (ChamplainMarker, champlain_marker, CLUTTER_TYPE_GROUP); +struct _ChamplainMarkerPrivate +{ + gboolean tmp; +}; + +G_DEFINE_TYPE (ChamplainMarker, champlain_marker, CHAMPLAIN_TYPE_BASE_MARKER); + +#define CHAMPLAIN_MARKER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), CHAMPLAIN_TYPE_MARKER, ChamplainMarkerPrivate)) static void champlain_marker_get_property (GObject *object, @@ -77,17 +81,11 @@ champlain_marker_get_property (GObject *object, GValue *value, GParamSpec *pspec) { - ChamplainMarker *marker = CHAMPLAIN_MARKER (object); - ChamplainMarkerPrivate *priv = CHAMPLAIN_MARKER_GET_PRIVATE (marker); + //ChamplainMarker *marker = CHAMPLAIN_MARKER (object); + //ChamplainMarkerPrivate *priv = CHAMPLAIN_MARKER_GET_PRIVATE (marker); switch (prop_id) { - case PROP_LONGITUDE: - g_value_set_double (value, priv->lon); - break; - case PROP_LATITUDE: - g_value_set_double (value, priv->lat); - break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); } @@ -99,23 +97,11 @@ champlain_marker_set_property (GObject *object, const GValue *value, GParamSpec *pspec) { - ChamplainMarker *marker = CHAMPLAIN_MARKER (object); - ChamplainMarkerPrivate *priv = CHAMPLAIN_MARKER_GET_PRIVATE (marker); + //ChamplainMarker *marker = CHAMPLAIN_MARKER (object); + //ChamplainMarkerPrivate *priv = CHAMPLAIN_MARKER_GET_PRIVATE (marker); switch (prop_id) { - case PROP_LONGITUDE: - { - gdouble lon = g_value_get_double (value); - champlain_marker_set_position (marker, lon, priv->lat); - break; - } - case PROP_LATITUDE: - { - gdouble lat = g_value_get_double (value); - champlain_marker_set_position (marker, priv->lon, lat); - break; - } default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); } @@ -131,56 +117,24 @@ champlain_marker_finalize (GObject *object) } static void -champlain_marker_class_init (ChamplainMarkerClass *champlainMarkerClass) +champlain_marker_class_init (ChamplainMarkerClass *markerClass) { - g_type_class_add_private (champlainMarkerClass, sizeof (ChamplainMarkerPrivate)); + g_type_class_add_private (markerClass, sizeof (ChamplainMarkerPrivate)); - GObjectClass *object_class = G_OBJECT_CLASS (champlainMarkerClass); + GObjectClass *object_class = G_OBJECT_CLASS (markerClass); object_class->finalize = champlain_marker_finalize; object_class->get_property = champlain_marker_get_property; object_class->set_property = champlain_marker_set_property; - /** - * ChamplainMarker:longitude: - * - * The longitude coordonate of the map - * - * Since: 0.2 - */ - g_object_class_install_property (object_class, PROP_LONGITUDE, - g_param_spec_double ("longitude", - "Longitude", - "The longitude coordonate of the marker", - -180.0f, - 180.0f, - 0.0f, - CHAMPLAIN_PARAM_READWRITE)); - - /** - * ChamplainMarker:latitude: - * - * The latitude coordonate of the map - * - * Since: 0.2 - */ - g_object_class_install_property (object_class, PROP_LATITUDE, - g_param_spec_double ("latitude", - "Latitude", - "The latitude coordonate of the marker", - -90.0f, - 90.0f, - 0.0f, - CHAMPLAIN_PARAM_READWRITE)); - } static void -champlain_marker_init (ChamplainMarker *champlainMarker) +champlain_marker_init (ChamplainMarker *marker) { - //ChamplainMarkerPrivate *priv = CHAMPLAIN_MARKER_GET_PRIVATE (champlainMarker); + ChamplainMarkerPrivate *priv = CHAMPLAIN_MARKER_GET_PRIVATE (marker); + marker->priv = priv; } - /** * champlain_marker_new: * @@ -199,30 +153,6 @@ champlain_marker_new (void) return CLUTTER_ACTOR (marker); } -/** - * champlain_marker_set_position: - * @marker: a #ChamplainMarker - * @longitude: the longitude to center the map at - * @latitude: the longitude to center the map at - * - * Positions the marker on the map at the coordinates - * - * Since: 0.2 - */ -void -champlain_marker_set_position (ChamplainMarker *champlainMarker, gdouble latitude, gdouble longitude) -{ - g_return_if_fail (CHAMPLAIN_IS_MARKER (champlainMarker)); - - ChamplainMarkerPrivate *priv = CHAMPLAIN_MARKER_GET_PRIVATE (champlainMarker); - - priv->lon = longitude; - priv->lat = latitude; - - g_object_notify (G_OBJECT (champlainMarker), "latitude"); - g_object_notify (G_OBJECT (champlainMarker), "longitude"); -} - /** * champlain_marker_new_with_label: * @label: the text of the label @@ -240,7 +170,7 @@ champlain_marker_new_with_label (const gchar *label, ClutterColor *text_color, ClutterColor *marker_color) { - ChamplainMarker *champlainMarker = CHAMPLAIN_MARKER (champlain_marker_new ()); + ChamplainMarker *marker = CHAMPLAIN_MARKER (champlain_marker_new ()); ClutterColor default_text_color = { 0x22, 0x22, 0x22, 0xFF }, default_marker_color = { 0x2A, 0xB1, 0x26, 0xEE }, darker_color; @@ -261,7 +191,7 @@ champlain_marker_new_with_label (const gchar *label, text_width = clutter_actor_get_width (actor) + 2 * padding; text_height = clutter_actor_get_height (actor)+ padding; clutter_label_set_color (CLUTTER_LABEL (actor), text_color); - clutter_container_add_actor (CLUTTER_CONTAINER (champlainMarker), actor); + clutter_container_add_actor (CLUTTER_CONTAINER (marker), actor); point = (text_height + 2 * padding) / 4.0; @@ -293,12 +223,12 @@ champlain_marker_new_with_label (const gchar *label, cairo_destroy (cr); - clutter_container_add_actor (CLUTTER_CONTAINER (champlainMarker), bg); + clutter_container_add_actor (CLUTTER_CONTAINER (marker), bg); clutter_actor_raise (actor, bg); - clutter_actor_set_anchor_point (CLUTTER_ACTOR (champlainMarker), 0, text_height + point); + clutter_actor_set_anchor_point (CLUTTER_ACTOR (marker), 0, text_height + point); - return CLUTTER_ACTOR (champlainMarker); + return CLUTTER_ACTOR (marker); } /** @@ -316,17 +246,17 @@ champlain_marker_new_with_image (const gchar *filename, GError **error) if (filename == NULL) return NULL; - ChamplainMarker *champlainMarker = CHAMPLAIN_MARKER (champlain_marker_new ()); + ChamplainMarker *marker = CHAMPLAIN_MARKER (champlain_marker_new ()); ClutterActor *actor = clutter_texture_new_from_file (filename, error); if (actor == NULL){ - g_object_unref (G_OBJECT (champlainMarker)); + g_object_unref (G_OBJECT (marker)); return NULL; } - clutter_container_add_actor (CLUTTER_CONTAINER (champlainMarker), actor); + clutter_container_add_actor (CLUTTER_CONTAINER (marker), actor); - return CLUTTER_ACTOR (champlainMarker); + return CLUTTER_ACTOR (marker); } /** @@ -353,21 +283,21 @@ champlain_marker_new_with_image_full (const gchar *filename, if (filename == NULL) return NULL; - ChamplainMarker *champlainMarker = CHAMPLAIN_MARKER (champlain_marker_new ()); + ChamplainMarker *marker = CHAMPLAIN_MARKER (champlain_marker_new ()); ClutterActor *actor = clutter_texture_new_from_file (filename, error); if (actor == NULL) { - g_object_unref (G_OBJECT (champlainMarker)); + g_object_unref (G_OBJECT (marker)); return NULL; } clutter_actor_set_size (actor, width, height); - clutter_container_add_actor (CLUTTER_CONTAINER (champlainMarker), actor); - clutter_actor_set_anchor_point (CLUTTER_ACTOR (champlainMarker), anchor_x, + clutter_container_add_actor (CLUTTER_CONTAINER (marker), actor); + clutter_actor_set_anchor_point (CLUTTER_ACTOR (marker), anchor_x, anchor_y); - return CLUTTER_ACTOR (champlainMarker); + return CLUTTER_ACTOR (marker); } diff --git a/champlain/champlain-marker.h b/champlain/champlain-marker.h index fb0c7ee..e9246e5 100644 --- a/champlain/champlain-marker.h +++ b/champlain/champlain-marker.h @@ -23,11 +23,13 @@ #ifndef CHAMPLAIN_MARKER_H #define CHAMPLAIN_MARKER_H -#include +#include #include #include +G_BEGIN_DECLS + #define CHAMPLAIN_TYPE_MARKER (champlain_marker_get_type()) #define CHAMPLAIN_MARKER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), CHAMPLAIN_TYPE_MARKER, ChamplainMarker)) #define CHAMPLAIN_MARKER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), CHAMPLAIN_TYPE_MARKER, ChamplainMarkerClass)) @@ -37,26 +39,23 @@ typedef struct _ChamplainMarkerPrivate ChamplainMarkerPrivate; -struct _ChamplainMarker +typedef struct { - ClutterGroup group; + ChamplainBaseMarker base; ChamplainMarkerPrivate *priv; -}; +} ChamplainMarker; -struct _ChamplainMarkerClass +typedef struct { - ClutterGroupClass parent_class; + ChamplainBaseMarkerClass parent_class; -}; +} ChamplainMarkerClass; GType champlain_marker_get_type (void); ClutterActor *champlain_marker_new (void); -void champlain_marker_set_position (ChamplainMarker *marker, - gdouble longitude, gdouble latitude); - ClutterActor *champlain_marker_new_with_label (const gchar *label, const gchar *font, ClutterColor *text_color, ClutterColor *marker_color); @@ -66,4 +65,6 @@ ClutterActor *champlain_marker_new_with_image(const gchar *filename, ClutterActor *champlain_marker_new_with_image_full(const gchar *filename, gint width, gint height, gint anchor_x, gint anchor_y, GError **error); +G_END_DECLS + #endif diff --git a/champlain/champlain-private.h b/champlain/champlain-private.h index 5c053eb..f3c398b 100644 --- a/champlain/champlain-private.h +++ b/champlain/champlain-private.h @@ -21,7 +21,6 @@ #include -#define CHAMPLAIN_MARKER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), CHAMPLAIN_TYPE_MARKER, ChamplainMarkerPrivate)) typedef struct _Map Map; @@ -32,7 +31,7 @@ typedef struct gint z; } ChamplainPoint; -struct _ChamplainMarkerPrivate +struct _ChamplainBaseMarkerPrivate { gdouble lon; gdouble lat; diff --git a/champlain/champlain-view.c b/champlain/champlain-view.c index 5726aa0..243e821 100644 --- a/champlain/champlain-view.c +++ b/champlain/champlain-view.c @@ -307,7 +307,7 @@ marker_reposition_cb (ChamplainMarker *marker, ChamplainView *view) { ChamplainViewPrivate *priv = view->priv; - ChamplainMarkerPrivate *marker_priv = CHAMPLAIN_MARKER_GET_PRIVATE (marker); + ChamplainBaseMarkerPrivate *marker_priv = CHAMPLAIN_BASE_MARKER(marker)->priv; gint x, y; @@ -1840,11 +1840,11 @@ champlain_view_ensure_visible (ChamplainView *view, */ void champlain_view_ensure_markers_visible (ChamplainView *view, - ChamplainMarker *markers[], + ChamplainBaseMarker *markers[], gboolean animate) { gdouble min_lat, min_lon, max_lat, max_lon; - ChamplainMarker *marker = NULL; + ChamplainBaseMarker *marker = NULL; gint i = 0; min_lat = min_lon = 200; diff --git a/champlain/champlain-view.h b/champlain/champlain-view.h index d21de1c..afc88a1 100644 --- a/champlain/champlain-view.h +++ b/champlain/champlain-view.h @@ -25,6 +25,7 @@ #include #include +#include #include #include @@ -94,7 +95,7 @@ void champlain_view_ensure_visible (ChamplainView *view, gdouble lon2, gboolean animate); void champlain_view_ensure_markers_visible (ChamplainView *view, - ChamplainMarker *markers[], + ChamplainBaseMarker *markers[], gboolean animate); void champlain_view_set_map_source (ChamplainView *champlainView, diff --git a/champlain/champlain.h b/champlain/champlain.h index 0d0a59f..75abce4 100644 --- a/champlain/champlain.h +++ b/champlain/champlain.h @@ -30,6 +30,7 @@ #include "champlain/champlain-defines.h" #include "champlain/champlain-layer.h" +#include "champlain/champlain-base-marker.h" #include "champlain/champlain-marker.h" #include "champlain/champlain-view.h" #include "champlain/champlain-enum-types.h" diff --git a/demos/animated-marker.c b/demos/animated-marker.c index 2b92532..9574778 100644 --- a/demos/animated-marker.c +++ b/demos/animated-marker.c @@ -94,7 +94,7 @@ create_marker () clutter_timeline_start (timeline); /* Sets marker position on the map */ - champlain_marker_set_position (CHAMPLAIN_MARKER (marker), + champlain_base_marker_set_position (CHAMPLAIN_BASE_MARKER (marker), 45.528178, -73.563788); return marker; diff --git a/demos/launcher-gtk.c b/demos/launcher-gtk.c index ba52682..e93292e 100644 --- a/demos/launcher-gtk.c +++ b/demos/launcher-gtk.c @@ -48,15 +48,15 @@ create_marker_layer () ClutterColor orange = { 0xf3, 0x94, 0x07, 0xbb }; ClutterColor white = { 0xff, 0xff, 0xff, 0xff }; marker = champlain_marker_new_with_label ("Montréal", "Airmole 14", NULL, NULL); - champlain_marker_set_position (CHAMPLAIN_MARKER (marker), 45.528178, -73.563788); + champlain_base_marker_set_position (CHAMPLAIN_BASE_MARKER (marker), 45.528178, -73.563788); clutter_container_add (CLUTTER_CONTAINER (layer), marker, NULL); marker = champlain_marker_new_with_label ("New York", "Sans 25", &white, NULL); - champlain_marker_set_position (CHAMPLAIN_MARKER (marker), 40.77, -73.98); + champlain_base_marker_set_position (CHAMPLAIN_BASE_MARKER (marker), 40.77, -73.98); clutter_container_add (CLUTTER_CONTAINER (layer), marker, NULL); marker = champlain_marker_new_with_label ("Saint-Tite-des-Caps", "Serif 12", NULL, &orange); - champlain_marker_set_position(CHAMPLAIN_MARKER (marker), 47.130885, -70.764141); + champlain_base_marker_set_position (CHAMPLAIN_BASE_MARKER (marker), 47.130885, -70.764141); clutter_container_add (CLUTTER_CONTAINER (layer), marker, NULL); clutter_actor_hide (CLUTTER_ACTOR (layer)); @@ -223,7 +223,7 @@ main (int argc, button = gtk_image_new (); g_signal_connect (view, "notify::state", G_CALLBACK (view_state_changed), button); - gtk_box_pack_end (GTK_HBOX (bbox), button, FALSE, FALSE, 0); + gtk_box_pack_end (GTK_BOX (bbox), button, FALSE, FALSE, 0); viewport = gtk_viewport_new (NULL, NULL); gtk_viewport_set_shadow_type (GTK_VIEWPORT(viewport), GTK_SHADOW_ETCHED_IN); diff --git a/demos/launcher.c b/demos/launcher.c index 259751f..809530f 100644 --- a/demos/launcher.c +++ b/demos/launcher.c @@ -19,7 +19,7 @@ #include #define PADDING 10 -ChamplainMarker *markers [4]; +ChamplainBaseMarker *markers [4]; static gboolean map_view_button_release_cb (ClutterActor *actor, @@ -91,8 +91,8 @@ create_marker_layer (ChamplainView *view) marker = champlain_marker_new_with_label ("Montréal", "Airmole 14", NULL, NULL); - markers[0] = CHAMPLAIN_MARKER (marker); - champlain_marker_set_position (CHAMPLAIN_MARKER (marker), + markers[0] = CHAMPLAIN_BASE_MARKER (marker); + champlain_base_marker_set_position (CHAMPLAIN_BASE_MARKER (marker), 45.528178, -73.563788); clutter_container_add (CLUTTER_CONTAINER (layer), marker, NULL); clutter_actor_set_reactive (marker, TRUE); @@ -101,14 +101,14 @@ create_marker_layer (ChamplainView *view) marker = champlain_marker_new_with_label ("New York", "Sans 25", &white, NULL); - markers[1] = CHAMPLAIN_MARKER (marker); - champlain_marker_set_position (CHAMPLAIN_MARKER (marker), 40.77, -73.98); + markers[1] = CHAMPLAIN_BASE_MARKER (marker); + champlain_base_marker_set_position (CHAMPLAIN_BASE_MARKER (marker), 40.77, -73.98); clutter_container_add (CLUTTER_CONTAINER (layer), marker, NULL); marker = champlain_marker_new_with_label ("Saint-Tite-des-Caps", "Serif 12", NULL, &orange); - markers[2] = CHAMPLAIN_MARKER (marker); - champlain_marker_set_position (CHAMPLAIN_MARKER (marker), 47.130885, + markers[2] = CHAMPLAIN_BASE_MARKER (marker); + champlain_base_marker_set_position (CHAMPLAIN_BASE_MARKER (marker), 47.130885, -70.764141); clutter_container_add (CLUTTER_CONTAINER (layer), marker, NULL); diff --git a/docs/reference/libchamplain-docs.sgml b/docs/reference/libchamplain-docs.sgml index 84b245e..5e75780 100644 --- a/docs/reference/libchamplain-docs.sgml +++ b/docs/reference/libchamplain-docs.sgml @@ -42,6 +42,7 @@ I. View API Reference + diff --git a/docs/reference/libchamplain.types b/docs/reference/libchamplain.types index 75c38b9..f13ddb4 100644 --- a/docs/reference/libchamplain.types +++ b/docs/reference/libchamplain.types @@ -2,6 +2,7 @@ champlain_view_get_type champlain_marker_get_type +champlain_base_marker_get_type champlain_layer_get_type champlain_map_source_get_type champlain_network_map_source_get_type -- 2.39.5