[libchamplain] Rename ChamplainMarker to ChamplainLabel and ChamplainBaseMarker to ChamplainMarker
- From: Jiří Techet <jiritechet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libchamplain] Rename ChamplainMarker to ChamplainLabel and ChamplainBaseMarker to ChamplainMarker
- Date: Wed, 9 Feb 2011 08:38:24 +0000 (UTC)
commit 14483f14b0f95e6f86df525b97e5ce942bf92315
Author: JiÅ?Ã Techet <techet gmail com>
Date: Sun Jan 30 01:48:40 2011 +0100
Rename ChamplainMarker to ChamplainLabel and ChamplainBaseMarker to ChamplainMarker
champlain-gtk/gtk-champlain-embed.c | 24 -
champlain/Makefile.am | 8 +-
champlain/champlain-base-marker.c | 711 ----------------
champlain/champlain-base-marker.h | 100 ---
champlain/champlain-label.c | 1557 +++++++++++++++++++++++++++++++++++
champlain/champlain-label.h | 136 +++
champlain/champlain-layer.c | 73 +-
champlain/champlain-layer.h | 8 +-
champlain/champlain-marker.c | 1517 ++++++++--------------------------
champlain/champlain-marker.h | 94 +--
champlain/champlain-point.c | 139 +---
champlain/champlain-point.h | 12 +-
champlain/champlain-view.h | 1 -
champlain/champlain.h | 2 +-
demos/animated-marker.c | 8 +-
demos/launcher-gtk.c | 4 +-
demos/markers.c | 39 +-
demos/polygons.c | 4 +-
demos/url-marker.c | 4 +-
19 files changed, 2169 insertions(+), 2272 deletions(-)
---
diff --git a/champlain-gtk/gtk-champlain-embed.c b/champlain-gtk/gtk-champlain-embed.c
index 703443e..f8f38bc 100644
--- a/champlain-gtk/gtk-champlain-embed.c
+++ b/champlain-gtk/gtk-champlain-embed.c
@@ -249,38 +249,14 @@ gtk_champlain_embed_init (GtkChamplainEmbed *embed)
}
-static inline void
-gdk_to_clutter_color (GdkColor *gtk_color,
- ClutterColor *color)
-{
- color->red = CLAMP (((gtk_color->red / 65535.0) * 255), 0, 255);
- color->green = CLAMP (((gtk_color->green / 65535.0) * 255), 0, 255);
- color->blue = CLAMP (((gtk_color->blue / 65535.0) * 255), 0, 255);
- color->alpha = 255;
-}
-
-
static void
view_realize_cb (GtkWidget *widget,
GtkChamplainEmbed *view)
{
- ClutterColor color = { 0, 0, 0, };
GtkChamplainEmbedPrivate *priv = view->priv;
- GtkStyle *style;
/* Setup mouse cursor to a hand */
gdk_window_set_cursor (gtk_widget_get_window (priv->clutter_embed), priv->cursor_hand_open);
-
- /* Set selection color */
- style = gtk_widget_get_style (widget);
-
- gdk_to_clutter_color (&style->text[GTK_STATE_SELECTED], &color);
- champlain_marker_set_highlight_text_color (&color);
-
- gdk_to_clutter_color (&style->bg[GTK_STATE_SELECTED], &color);
- champlain_marker_set_highlight_color (&color);
-
- /* To be added later: bg[active] (for selected markers, but focus is on another widget) */
}
diff --git a/champlain/Makefile.am b/champlain/Makefile.am
index 5a31e64..68ebb8a 100644
--- a/champlain/Makefile.am
+++ b/champlain/Makefile.am
@@ -17,8 +17,8 @@ libchamplain_headers_public = \
$(srcdir)/champlain-point.h \
$(srcdir)/champlain-view.h \
$(srcdir)/champlain-layer.h \
- $(srcdir)/champlain-base-marker.h \
- $(srcdir)/champlain-marker.h \
+ $(srcdir)/champlain-marker.h \
+ $(srcdir)/champlain-label.h \
$(srcdir)/champlain-tile.h \
$(srcdir)/champlain-map-source.h \
$(srcdir)/champlain-map-source-chain.h \
@@ -52,8 +52,8 @@ libchamplain_sources = \
$(srcdir)/champlain-debug.c \
$(srcdir)/champlain-view.c \
$(srcdir)/champlain-layer.c \
- $(srcdir)/champlain-base-marker.c \
- $(srcdir)/champlain-marker.c \
+ $(srcdir)/champlain-marker.c \
+ $(srcdir)/champlain-label.c \
$(srcdir)/champlain-tile.c \
$(srcdir)/champlain-map-source.c \
$(srcdir)/champlain-map-source-chain.c \
diff --git a/champlain/champlain-label.c b/champlain/champlain-label.c
new file mode 100644
index 0000000..d904584
--- /dev/null
+++ b/champlain/champlain-label.c
@@ -0,0 +1,1557 @@
+/*
+ * 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
+ * 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-label
+ * @short_description: A label 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_label_new_with_text.
+ */
+
+#include "config.h"
+
+#include "champlain-label.h"
+
+#include "champlain.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 SELECTED_TEXT_COLOR = { 0xff, 0xff, 0xff, 0xff };
+
+static ClutterColor DEFAULT_COLOR = { 0x33, 0x33, 0x33, 0xff };
+static ClutterColor DEFAULT_TEXT_COLOR = { 0xee, 0xee, 0xee, 0xff };
+
+enum
+{
+ /* normal signals */
+ LAST_SIGNAL
+};
+
+enum
+{
+ PROP_0,
+ PROP_IMAGE,
+ PROP_TEXT,
+ PROP_USE_MARKUP,
+ PROP_ALIGNMENT,
+ PROP_ATTRIBUTES,
+ PROP_ELLIPSIZE,
+ PROP_COLOR,
+ PROP_TEXT_COLOR,
+ PROP_FONT_NAME,
+ PROP_WRAP,
+ PROP_WRAP_MODE,
+ PROP_SINGLE_LINE_MODE,
+ PROP_DRAW_BACKGROUND
+};
+
+/* static guint champlain_label_signals[LAST_SIGNAL] = { 0, }; */
+
+struct _ChamplainLabelPrivate
+{
+ gchar *text;
+ ClutterActor *image;
+ gboolean use_markup;
+ PangoAlignment alignment;
+ PangoAttrList *attributes;
+ ClutterColor *color;
+ ClutterColor *text_color;
+ gchar *font_name;
+ gboolean wrap;
+ PangoWrapMode wrap_mode;
+ gboolean single_line_mode;
+ PangoEllipsizeMode ellipsize;
+ gboolean draw_background;
+
+ ClutterActor *text_actor;
+ ClutterActor *shadow;
+ ClutterActor *background;
+ guint redraw_id;
+};
+
+G_DEFINE_TYPE (ChamplainLabel, champlain_label, CHAMPLAIN_TYPE_MARKER);
+
+#define GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE ((obj), CHAMPLAIN_TYPE_LABEL, ChamplainLabelPrivate))
+
+static void draw_label (ChamplainLabel *label);
+
+/**
+ * champlain_label_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_label_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_label_get_highlight_color:
+ *
+ * Gets the highlight color.
+ *
+ * Returns: the highlight color. Should not be freed.
+ *
+ * Since: 0.4.1
+ */
+const ClutterColor *
+champlain_label_get_highlight_color ()
+{
+ return &SELECTED_COLOR;
+}
+
+
+/**
+ * champlain_label_set_highlight_text_color:
+ * @color: a #ClutterColor
+ *
+ * Changes the highlight text color, this is to ensure a better integration with
+ * the desktop, this is automatically done by GtkChamplainEmbed.
+ *
+ * Since: 0.4
+ */
+void
+champlain_label_set_highlight_text_color (ClutterColor *color)
+{
+ SELECTED_TEXT_COLOR.red = color->red;
+ SELECTED_TEXT_COLOR.green = color->green;
+ SELECTED_TEXT_COLOR.blue = color->blue;
+ SELECTED_TEXT_COLOR.alpha = color->alpha;
+}
+
+
+/**
+ * champlain_label_get_highlight_text_color:
+ *
+ * Gets the highlight text color.
+ *
+ * Returns: the highlight text color. Should not be freed.
+ *
+ * Since: 0.4.1
+ */
+const ClutterColor *
+champlain_label_get_highlight_text_color ()
+{
+ return &SELECTED_TEXT_COLOR;
+}
+
+
+static void
+champlain_label_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ ChamplainLabelPrivate *priv = CHAMPLAIN_LABEL (object)->priv;
+
+ switch (prop_id)
+ {
+ case PROP_TEXT:
+ g_value_set_string (value, priv->text);
+ break;
+
+ case PROP_IMAGE:
+ g_value_set_object (value, priv->image);
+ break;
+
+ case PROP_USE_MARKUP:
+ g_value_set_boolean (value, priv->use_markup);
+ break;
+
+ case PROP_ALIGNMENT:
+ g_value_set_enum (value, priv->alignment);
+ break;
+
+ case PROP_COLOR:
+ clutter_value_set_color (value, priv->color);
+ break;
+
+ case PROP_TEXT_COLOR:
+ clutter_value_set_color (value, priv->text_color);
+ break;
+
+ case PROP_FONT_NAME:
+ g_value_set_string (value, priv->font_name);
+ break;
+
+ case PROP_WRAP:
+ g_value_set_boolean (value, priv->wrap);
+ break;
+
+ case PROP_WRAP_MODE:
+ g_value_set_enum (value, priv->wrap_mode);
+ break;
+
+ case PROP_DRAW_BACKGROUND:
+ g_value_set_boolean (value, priv->draw_background);
+ break;
+
+ case PROP_ELLIPSIZE:
+ g_value_set_enum (value, priv->ellipsize);
+ break;
+
+ case PROP_SINGLE_LINE_MODE:
+ g_value_set_enum (value, priv->single_line_mode);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+
+static void
+champlain_label_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ ChamplainLabel *label = CHAMPLAIN_LABEL (object);
+
+ switch (prop_id)
+ {
+ case PROP_TEXT:
+ champlain_label_set_text (label, g_value_get_string (value));
+ break;
+
+ case PROP_IMAGE:
+ champlain_label_set_image (label, g_value_get_object (value));
+ break;
+
+ case PROP_USE_MARKUP:
+ champlain_label_set_use_markup (label, g_value_get_boolean (value));
+ break;
+
+ case PROP_ALIGNMENT:
+ champlain_label_set_alignment (label, g_value_get_enum (value));
+ break;
+
+ case PROP_COLOR:
+ champlain_label_set_color (label, clutter_value_get_color (value));
+ break;
+
+ case PROP_TEXT_COLOR:
+ champlain_label_set_text_color (label, clutter_value_get_color (value));
+ break;
+
+ case PROP_FONT_NAME:
+ champlain_label_set_font_name (label, g_value_get_string (value));
+ break;
+
+ case PROP_WRAP:
+ champlain_label_set_wrap (label, g_value_get_boolean (value));
+ break;
+
+ case PROP_WRAP_MODE:
+ champlain_label_set_wrap_mode (label, g_value_get_enum (value));
+ break;
+
+ case PROP_ELLIPSIZE:
+ champlain_label_set_ellipsize (label, g_value_get_enum (value));
+ break;
+
+ case PROP_DRAW_BACKGROUND:
+ champlain_label_set_draw_background (label, g_value_get_boolean (value));
+ break;
+
+ case PROP_SINGLE_LINE_MODE:
+ champlain_label_set_single_line_mode (label, g_value_get_boolean (value));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+
+static void
+champlain_label_dispose (GObject *object)
+{
+ ChamplainLabelPrivate *priv = CHAMPLAIN_LABEL (object)->priv;
+
+ if (priv->background)
+ {
+ g_object_unref (priv->background);
+ priv->background = NULL;
+ }
+
+ if (priv->shadow)
+ {
+ g_object_unref (priv->shadow);
+ priv->shadow = NULL;
+ }
+
+ if (priv->text_actor)
+ {
+ g_object_unref (priv->text_actor);
+ priv->text_actor = NULL;
+ }
+
+ if (priv->image)
+ {
+ g_object_unref (priv->image);
+ priv->image = NULL;
+ }
+
+ if (priv->attributes)
+ {
+ pango_attr_list_unref (priv->attributes);
+ priv->attributes = NULL;
+ }
+
+ G_OBJECT_CLASS (champlain_label_parent_class)->dispose (object);
+}
+
+
+static void
+champlain_label_finalize (GObject *object)
+{
+ ChamplainLabelPrivate *priv = CHAMPLAIN_LABEL (object)->priv;
+
+ if (priv->text)
+ {
+ g_free (priv->text);
+ priv->text = NULL;
+ }
+
+ if (priv->font_name)
+ {
+ g_free (priv->font_name);
+ priv->font_name = NULL;
+ }
+
+ if (priv->color)
+ {
+ clutter_color_free (priv->color);
+ priv->color = NULL;
+ }
+
+ if (priv->text_color)
+ {
+ clutter_color_free (priv->text_color);
+ priv->text_color = NULL;
+ }
+
+ if (priv->redraw_id)
+ {
+ g_source_remove (priv->redraw_id);
+ priv->redraw_id = 0;
+ }
+
+ G_OBJECT_CLASS (champlain_label_parent_class)->finalize (object);
+}
+
+
+static void
+champlain_label_class_init (ChamplainLabelClass *labelClass)
+{
+ g_type_class_add_private (labelClass, sizeof (ChamplainLabelPrivate));
+
+ GObjectClass *object_class = G_OBJECT_CLASS (labelClass);
+ object_class->finalize = champlain_label_finalize;
+ object_class->dispose = champlain_label_dispose;
+ object_class->get_property = champlain_label_get_property;
+ object_class->set_property = champlain_label_set_property;
+
+ labelClass->draw_label = draw_label;
+ /**
+ * ChamplainLabel:text:
+ *
+ * The text of the label
+ *
+ * Since: 0.4
+ */
+ g_object_class_install_property (object_class, PROP_TEXT,
+ g_param_spec_string ("text", "Text", "The text of the label",
+ "", CHAMPLAIN_PARAM_READWRITE));
+
+ /**
+ * ChamplainLabel:image:
+ *
+ * The image of the label
+ *
+ * Since: 0.4
+ */
+ g_object_class_install_property (object_class, PROP_IMAGE,
+ g_param_spec_object ("image", "Image", "The image of the label",
+ CLUTTER_TYPE_ACTOR, CHAMPLAIN_PARAM_READWRITE));
+
+ /**
+ * ChamplainLabel:use-markup:
+ *
+ * If the label's text uses markup
+ *
+ * Since: 0.4
+ */
+ g_object_class_install_property (object_class, PROP_USE_MARKUP,
+ g_param_spec_boolean ("use-markup", "Use Markup", "The text uses markup",
+ FALSE, CHAMPLAIN_PARAM_READWRITE));
+
+ /**
+ * ChamplainLabel:alignment:
+ *
+ * The label's alignment
+ *
+ * Since: 0.4
+ */
+ g_object_class_install_property (object_class, PROP_ALIGNMENT,
+ g_param_spec_enum ("alignment", "Alignment", "The label's alignment",
+ PANGO_TYPE_ALIGNMENT, PANGO_ALIGN_LEFT, CHAMPLAIN_PARAM_READWRITE));
+
+ /**
+ * ChamplainLabel:color:
+ *
+ * The label's color
+ *
+ * Since: 0.4
+ */
+ g_object_class_install_property (object_class, PROP_COLOR,
+ clutter_param_spec_color ("color", "Color", "The label's color",
+ &DEFAULT_COLOR, CHAMPLAIN_PARAM_READWRITE));
+
+ /**
+ * ChamplainLabel:text-color:
+ *
+ * The label's text color
+ *
+ * Since: 0.4
+ */
+ g_object_class_install_property (object_class, PROP_TEXT_COLOR,
+ clutter_param_spec_color ("text-color", "Text Color", "The label's text color",
+ &DEFAULT_TEXT_COLOR, CHAMPLAIN_PARAM_READWRITE));
+
+ /**
+ * ChamplainLabel:font-name:
+ *
+ * The label's text font name
+ *
+ * Since: 0.4
+ */
+ g_object_class_install_property (object_class, PROP_FONT_NAME,
+ g_param_spec_string ("font-name", "Font Name", "The label's text font name",
+ "Sans 11", CHAMPLAIN_PARAM_READWRITE));
+
+ /**
+ * ChamplainLabel:wrap:
+ *
+ * If the label's text wrap is set
+ *
+ * Since: 0.4
+ */
+ g_object_class_install_property (object_class, PROP_WRAP,
+ g_param_spec_boolean ("wrap", "Wrap", "The label's text wrap",
+ FALSE, CHAMPLAIN_PARAM_READWRITE));
+
+ /**
+ * ChamplainLabel:wrap-mode:
+ *
+ * The label's text wrap mode
+ *
+ * Since: 0.4
+ */
+ g_object_class_install_property (object_class, PROP_WRAP_MODE,
+ g_param_spec_enum ("wrap-mode", "Wrap Mode", "The label's text wrap mode",
+ PANGO_TYPE_WRAP_MODE, PANGO_WRAP_WORD, CHAMPLAIN_PARAM_READWRITE));
+
+ /**
+ * ChamplainLabel:ellipsize:
+ *
+ * The label's ellipsize mode
+ *
+ * Since: 0.4
+ */
+ g_object_class_install_property (object_class, PROP_ELLIPSIZE,
+ g_param_spec_enum ("ellipsize", "Ellipsize Mode", "The label's text ellipsize mode",
+ PANGO_TYPE_ELLIPSIZE_MODE, PANGO_ELLIPSIZE_NONE, CHAMPLAIN_PARAM_READWRITE));
+
+ /**
+ * ChamplainLabel:draw-background:
+ *
+ * If the label has a background
+ *
+ * Since: 0.4
+ */
+ g_object_class_install_property (object_class, PROP_DRAW_BACKGROUND,
+ g_param_spec_boolean ("draw-background", "Draw Background", "The label has a background",
+ TRUE, CHAMPLAIN_PARAM_READWRITE));
+
+ /**
+ * ChamplainLabel:single-line-mode:
+ *
+ * If the label is in single line mode
+ *
+ * Since: 0.4
+ */
+ g_object_class_install_property (object_class, PROP_SINGLE_LINE_MODE,
+ g_param_spec_boolean ("single-line-mode", "Single Line Mode", "The label's single line mode",
+ TRUE, CHAMPLAIN_PARAM_READWRITE));
+}
+
+
+#define RADIUS 10
+#define PADDING (RADIUS / 2)
+
+static void
+draw_box (cairo_t *cr,
+ gint width,
+ gint height,
+ gint point,
+ gboolean mirror)
+{
+ if (mirror)
+ {
+ cairo_move_to (cr, RADIUS, 0);
+ cairo_line_to (cr, width - RADIUS, 0);
+ cairo_arc (cr, width - RADIUS, RADIUS, RADIUS - 1, 3 * M_PI / 2.0, 0);
+ cairo_line_to (cr, width, height - RADIUS);
+ cairo_arc (cr, width - RADIUS, height - RADIUS, RADIUS - 1, 0, M_PI / 2.0);
+ cairo_line_to (cr, point, height);
+ cairo_line_to (cr, 0, height + point);
+ cairo_arc (cr, RADIUS, RADIUS, RADIUS - 1, M_PI, 3 * M_PI / 2.0);
+ cairo_close_path (cr);
+ }
+ else
+ {
+ cairo_move_to (cr, RADIUS, 0);
+ cairo_line_to (cr, width - RADIUS, 0);
+ cairo_arc (cr, width - RADIUS, RADIUS, RADIUS - 1, 3 * M_PI / 2.0, 0);
+ cairo_line_to (cr, width, height + point);
+ cairo_line_to (cr, width - point, height);
+ cairo_line_to (cr, RADIUS, height);
+ cairo_arc (cr, RADIUS, height - RADIUS, RADIUS - 1, M_PI / 2.0, M_PI);
+ cairo_line_to (cr, 0, RADIUS);
+ cairo_arc (cr, RADIUS, RADIUS, RADIUS - 1, M_PI, 3 * M_PI / 2.0);
+ cairo_close_path (cr);
+ }
+}
+
+
+static void
+draw_shadow (ChamplainLabel *label,
+ gint width,
+ gint height,
+ gint point)
+{
+ ChamplainLabelPrivate *priv = label->priv;
+ ClutterActor *shadow = NULL;
+ cairo_t *cr;
+ gdouble slope;
+ gdouble scaling;
+ gint x;
+ cairo_matrix_t matrix;
+
+ slope = -0.3;
+ scaling = 0.65;
+ if (priv->alignment == PANGO_ALIGN_LEFT)
+ x = -40 * slope;
+ else
+ x = -58 * slope;
+
+ shadow = clutter_cairo_texture_new (width + x, (height + point));
+ cr = clutter_cairo_texture_create (CLUTTER_CAIRO_TEXTURE (shadow));
+
+ cairo_matrix_init (&matrix,
+ 1, 0,
+ slope, scaling,
+ x, 0);
+ cairo_set_matrix (cr, &matrix);
+
+ draw_box (cr, width, height, point, priv->alignment == PANGO_ALIGN_LEFT);
+
+ cairo_set_source_rgba (cr, 0, 0, 0, 0.15);
+ cairo_fill (cr);
+
+ cairo_destroy (cr);
+
+ clutter_actor_set_position (shadow, 0, height / 2.0);
+
+ clutter_container_add_actor (CLUTTER_CONTAINER (label), shadow);
+
+ if (priv->shadow != NULL)
+ {
+ clutter_container_remove_actor (CLUTTER_CONTAINER (label),
+ priv->shadow);
+ g_object_unref (priv->shadow);
+ }
+
+ priv->shadow = g_object_ref (shadow);
+}
+
+
+static void
+draw_background (ChamplainLabel *label,
+ gint width,
+ gint height,
+ gint point)
+{
+ ChamplainLabelPrivate *priv = label->priv;
+ ChamplainMarker *marker = CHAMPLAIN_MARKER (label);
+ ClutterActor *bg = NULL;
+ ClutterColor *color;
+ ClutterColor darker_color;
+ cairo_t *cr;
+
+ bg = clutter_cairo_texture_new (width, height + point);
+ cr = clutter_cairo_texture_create (CLUTTER_CAIRO_TEXTURE (bg));
+
+ /* If selected, add the selection color to the marker's color */
+ if (champlain_marker_get_highlighted (marker))
+ color = &SELECTED_COLOR;
+ else
+ color = priv->color;
+
+
+ draw_box (cr, width, height, point, priv->alignment == PANGO_ALIGN_LEFT);
+
+ clutter_color_darken (color, &darker_color);
+
+ cairo_set_source_rgba (cr,
+ color->red / 255.0,
+ color->green / 255.0,
+ color->blue / 255.0,
+ color->alpha / 255.0);
+ cairo_fill_preserve (cr);
+
+ cairo_set_line_width (cr, 1.0);
+ cairo_set_source_rgba (cr,
+ darker_color.red / 255.0,
+ darker_color.green / 255.0,
+ darker_color.blue / 255.0,
+ darker_color.alpha / 255.0);
+ cairo_stroke (cr);
+ cairo_destroy (cr);
+
+ clutter_container_add_actor (CLUTTER_CONTAINER (label), bg);
+
+ if (priv->background != NULL)
+ {
+ clutter_container_remove_actor (CLUTTER_CONTAINER (label),
+ priv->background);
+ g_object_unref (priv->background);
+ }
+
+ priv->background = g_object_ref (bg);
+}
+
+
+static void
+draw_label (ChamplainLabel *label)
+{
+ ChamplainLabelPrivate *priv = label->priv;
+ ChamplainMarker *marker = CHAMPLAIN_MARKER (label);
+ guint height = 0, point = 0;
+ guint total_width = 0, total_height = 0;
+
+ if (priv->image != NULL)
+ {
+ clutter_actor_set_position (priv->image, PADDING, PADDING);
+ total_width = clutter_actor_get_width (priv->image) + 2 * PADDING;
+ total_height = clutter_actor_get_height (priv->image) + 2 * PADDING;
+ if (clutter_actor_get_parent (priv->image) == NULL)
+ clutter_container_add_actor (CLUTTER_CONTAINER (label), priv->image);
+ }
+
+ if (priv->text != NULL && strlen (priv->text) > 0)
+ {
+ ClutterText *text;
+ if (priv->text_actor == NULL)
+ {
+ priv->text_actor = clutter_text_new_with_text (priv->font_name, priv->text);
+ g_object_ref (priv->text_actor);
+ }
+
+ text = CLUTTER_TEXT (priv->text_actor);
+ clutter_text_set_font_name (text, priv->font_name);
+ clutter_text_set_text (text, priv->text);
+ clutter_text_set_line_alignment (text, priv->alignment);
+ clutter_text_set_line_wrap (text, priv->wrap);
+ clutter_text_set_line_wrap_mode (text, priv->wrap_mode);
+ clutter_text_set_ellipsize (text, priv->ellipsize);
+ clutter_text_set_attributes (text, priv->attributes);
+ clutter_text_set_use_markup (text, priv->use_markup);
+
+ height = clutter_actor_get_height (priv->text_actor);
+ if (priv->image != NULL)
+ {
+ clutter_actor_set_position (priv->text_actor, total_width, (total_height - height) / 2.0);
+ total_width += clutter_actor_get_width (priv->text_actor) + 2 * PADDING;
+ }
+ else
+ {
+ clutter_actor_set_position (priv->text_actor, 2 * PADDING, PADDING);
+ total_width += clutter_actor_get_width (priv->text_actor) + 4 * PADDING;
+ }
+
+ height += 2 * PADDING;
+ if (height > total_height)
+ total_height = height;
+
+ clutter_text_set_color (CLUTTER_TEXT (priv->text_actor),
+ (champlain_marker_get_highlighted (marker) ? &SELECTED_TEXT_COLOR : priv->text_color));
+ if (clutter_actor_get_parent (priv->text_actor) == NULL)
+ clutter_container_add_actor (CLUTTER_CONTAINER (label), priv->text_actor);
+ }
+
+ if (priv->text_actor == NULL && priv->image == NULL)
+ {
+ total_width = 6 * PADDING;
+ total_height = 6 * PADDING;
+ }
+
+ point = (total_height + 2 * PADDING) / 4.0;
+
+ if (priv->draw_background)
+ {
+ draw_shadow (label, total_width, total_height, point);
+ draw_background (label, total_width, total_height, point);
+ }
+ else
+ {
+ if (priv->background != NULL)
+ {
+ clutter_container_remove_actor (CLUTTER_CONTAINER (label), priv->background);
+ g_object_unref (G_OBJECT (priv->background));
+ priv->background = NULL;
+ }
+
+ if (priv->shadow != NULL)
+ {
+ clutter_container_remove_actor (CLUTTER_CONTAINER (label), priv->shadow);
+ g_object_unref (G_OBJECT (priv->shadow));
+ priv->shadow = NULL;
+ }
+ }
+
+ if (priv->text_actor != NULL && priv->background != NULL)
+ clutter_actor_raise (priv->text_actor, priv->background);
+ if (priv->image != NULL && priv->background != NULL)
+ clutter_actor_raise (priv->image, priv->background);
+
+ if (priv->draw_background)
+ {
+ if (priv->alignment == PANGO_ALIGN_RIGHT)
+ clutter_actor_set_anchor_point (CLUTTER_ACTOR (label), total_width, total_height + point);
+ else
+ clutter_actor_set_anchor_point (CLUTTER_ACTOR (label), 0, total_height + point);
+ }
+ else if (priv->image != NULL)
+ clutter_actor_set_anchor_point (CLUTTER_ACTOR (label),
+ clutter_actor_get_width (priv->image) / 2.0 + PADDING,
+ clutter_actor_get_height (priv->image) / 2.0 + PADDING);
+ else if (priv->text_actor != NULL)
+ clutter_actor_set_anchor_point (CLUTTER_ACTOR (label),
+ 0,
+ clutter_actor_get_height (priv->text_actor) / 2.0);
+}
+
+
+static gboolean
+redraw_on_idle (gpointer gobject)
+{
+ ChamplainLabel *label = CHAMPLAIN_LABEL (gobject);
+
+ CHAMPLAIN_LABEL_GET_CLASS (gobject)->draw_label (label);
+ label->priv->redraw_id = 0;
+ return FALSE;
+}
+
+
+/**
+ * champlain_label_queue_redraw:
+ * @label: a #ChamplainLabel
+ *
+ * Queue a redraw of the label as soon as possible. This function should not
+ * be used unless you are subclassing ChamplainLabel and adding new properties
+ * that affect the aspect of the label. When they change, call this function
+ * to update the label.
+ *
+ * Since: 0.4.3
+ */
+void
+champlain_label_queue_redraw (ChamplainLabel *label)
+{
+ ChamplainLabelPrivate *priv = label->priv;
+
+ if (!priv->redraw_id)
+ {
+ priv->redraw_id =
+ g_idle_add_full (G_PRIORITY_DEFAULT,
+ (GSourceFunc) redraw_on_idle,
+ g_object_ref (label),
+ (GDestroyNotify) g_object_unref);
+ }
+}
+
+
+static void
+notify_highlighted (GObject *gobject,
+ G_GNUC_UNUSED GParamSpec *pspec,
+ G_GNUC_UNUSED gpointer user_data)
+{
+ champlain_label_queue_redraw (CHAMPLAIN_LABEL (gobject));
+}
+
+
+static void
+champlain_label_init (ChamplainLabel *label)
+{
+ ChamplainLabelPrivate *priv = GET_PRIVATE (label);
+
+ label->priv = priv;
+
+ priv->text = NULL;
+ priv->image = NULL;
+ priv->background = NULL;
+ priv->use_markup = FALSE;
+ priv->alignment = PANGO_ALIGN_LEFT;
+ priv->attributes = NULL;
+ priv->color = clutter_color_copy (&DEFAULT_COLOR);
+ priv->text_color = clutter_color_copy (&DEFAULT_TEXT_COLOR);
+ priv->font_name = g_strdup (DEFAULT_FONT_NAME);
+ priv->wrap = FALSE;
+ priv->wrap_mode = PANGO_WRAP_WORD;
+ priv->single_line_mode = TRUE;
+ priv->ellipsize = PANGO_ELLIPSIZE_NONE;
+ priv->draw_background = TRUE;
+ priv->redraw_id = 0;
+ priv->shadow = NULL;
+ priv->text_actor = NULL;
+
+ g_signal_connect (label, "notify::highlighted", G_CALLBACK (notify_highlighted), NULL);
+}
+
+
+/**
+ * champlain_label_new:
+ *
+ * Creates a new instance of #ChamplainLabel.
+ *
+ * Returns: a new #ChamplainLabel ready to be used as a #ClutterActor.
+ *
+ * Since: 0.2
+ */
+ClutterActor *
+champlain_label_new (void)
+{
+ return CLUTTER_ACTOR (g_object_new (CHAMPLAIN_TYPE_LABEL, NULL));
+}
+
+
+/**
+ * champlain_label_new_with_text:
+ * @text: the text of the text
+ * @font: (allow-none): the font to use to draw the text, for example "Courrier Bold 11", can be NULL
+ * @text_color: (allow-none): a #ClutterColor, the color of the text, can be NULL
+ * @label_color: (allow-none): a #ClutterColor, the color of the label, can be NULL
+ *
+ * Creates a new instance of #ChamplainLabel with text value.
+ *
+ * Returns: a new #ChamplainLabel with a drawn label containing the given text.
+ *
+ * Since: 0.2
+ */
+ClutterActor *
+champlain_label_new_with_text (const gchar *text,
+ const gchar *font,
+ ClutterColor *text_color,
+ ClutterColor *label_color)
+{
+ ChamplainLabel *label = CHAMPLAIN_LABEL (champlain_label_new ());
+
+ champlain_label_set_text (label, text);
+
+ if (font != NULL)
+ champlain_label_set_font_name (label, font);
+
+ if (text_color != NULL)
+ champlain_label_set_text_color (label, text_color);
+
+ if (label_color != NULL)
+ champlain_label_set_color (label, label_color);
+
+ return CLUTTER_ACTOR (label);
+}
+
+
+/**
+ * champlain_label_new_with_image:
+ * @actor: The actor of the image.
+ *
+ * Creates a new instance of #ChamplainLabel with image.
+ *
+ * Returns: a new #ChamplainLabel with a drawn label containing the given
+ * image.
+ *
+ * Since: 0.4
+ */
+ClutterActor *
+champlain_label_new_with_image (ClutterActor *actor)
+{
+ ChamplainLabel *label = CHAMPLAIN_LABEL (champlain_label_new ());
+
+ if (actor != NULL)
+ {
+ champlain_label_set_image (label, actor);
+ }
+
+ return CLUTTER_ACTOR (label);
+}
+
+
+/**
+ * champlain_label_new_from_file:
+ * @filename: The filename of the image.
+ * @error: Return location for an error.
+ *
+ * Creates a new instance of #ChamplainLabel with image loaded from file.
+ *
+ * Returns: a new #ChamplainLabel with a drawn label containing the given
+ * image.
+ *
+ * Since: 0.4
+ */
+ClutterActor *
+champlain_label_new_from_file (const gchar *filename,
+ GError **error)
+{
+ if (filename == NULL)
+ return NULL;
+
+ ChamplainLabel *label = CHAMPLAIN_LABEL (champlain_label_new ());
+ ClutterActor *actor = clutter_texture_new_from_file (filename, error);
+
+ if (actor != NULL)
+ {
+ champlain_label_set_image (label, actor);
+ }
+
+ return CLUTTER_ACTOR (label);
+}
+
+
+/**
+ * champlain_label_new_full:
+ * @text: The text
+ * @actor: The image
+ *
+ * Creates a new instance of #ChamplainLabel consisting of a custom #ClutterActor.
+ *
+ * Returns: a new #ChamplainLabel with a drawn label containing the given
+ * image.
+ *
+ * Since: 0.4
+ */
+ClutterActor *
+champlain_label_new_full (const gchar *text,
+ ClutterActor *actor)
+{
+ ChamplainLabel *label = CHAMPLAIN_LABEL (champlain_label_new ());
+
+ if (actor != NULL)
+ {
+ champlain_label_set_image (label, actor);
+ }
+ champlain_label_set_text (label, text);
+
+ return CLUTTER_ACTOR (label);
+}
+
+
+/**
+ * champlain_label_set_text:
+ * @label: The label
+ * @text: The text
+ *
+ * Sets the label's text.
+ *
+ * Since: 0.4
+ */
+void
+champlain_label_set_text (ChamplainLabel *label,
+ const gchar *text)
+{
+ g_return_if_fail (CHAMPLAIN_IS_LABEL (label));
+
+ ChamplainLabelPrivate *priv = label->priv;
+
+ if (priv->text != NULL)
+ g_free (priv->text);
+
+ priv->text = g_strdup (text);
+ champlain_label_queue_redraw (label);
+}
+
+
+/**
+ * champlain_label_set_image:
+ * @label: The label.
+ * @image: (allow-none): The image as a @ClutterActor or NULL to remove the current image.
+ *
+ * Sets the label's image.
+ *
+ * Since: 0.4
+ */
+void
+champlain_label_set_image (ChamplainLabel *label,
+ ClutterActor *image)
+{
+ g_return_if_fail (CHAMPLAIN_IS_LABEL (label));
+
+ ChamplainLabelPrivate *priv = label->priv;
+
+ if (priv->image != NULL)
+ clutter_actor_destroy (priv->image);
+
+ if (image != NULL)
+ {
+ g_return_if_fail (CLUTTER_IS_ACTOR (image));
+ priv->image = g_object_ref (image);
+ }
+ else
+ priv->image = image;
+
+ g_object_notify (G_OBJECT (label), "image");
+ champlain_label_queue_redraw (label);
+}
+
+
+/**
+ * champlain_label_set_use_markup:
+ * @label: The label
+ * @use_markup: The value
+ *
+ * Sets if the label's text uses markup.
+ *
+ * Since: 0.4
+ */
+void
+champlain_label_set_use_markup (ChamplainLabel *label,
+ gboolean markup)
+{
+ g_return_if_fail (CHAMPLAIN_IS_LABEL (label));
+
+ label->priv->use_markup = markup;
+ g_object_notify (G_OBJECT (label), "use-markup");
+ champlain_label_queue_redraw (label);
+}
+
+
+/**
+ * champlain_label_set_alignment:
+ * @label: The label
+ * @alignment: The label's alignment
+ *
+ * Set the label's text alignment.
+ *
+ * Since: 0.4
+ */
+void
+champlain_label_set_alignment (ChamplainLabel *label,
+ PangoAlignment alignment)
+{
+ g_return_if_fail (CHAMPLAIN_IS_LABEL (label));
+
+ label->priv->alignment = alignment;
+ g_object_notify (G_OBJECT (label), "alignment");
+ champlain_label_queue_redraw (label);
+}
+
+
+/**
+ * champlain_label_set_color:
+ * @label: The label
+ * @color: (allow-none): The label's background color or NULL to reset the background to the
+ * default color. The color parameter is copied.
+ *
+ * Set the label's background color.
+ *
+ * Since: 0.4
+ */
+void
+champlain_label_set_color (ChamplainLabel *label,
+ const ClutterColor *color)
+{
+ g_return_if_fail (CHAMPLAIN_IS_LABEL (label));
+
+ ChamplainLabelPrivate *priv = label->priv;
+
+ 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 (label), "color");
+ champlain_label_queue_redraw (label);
+}
+
+
+/**
+ * champlain_label_set_text_color:
+ * @label: The label
+ * @color: (allow-none): The label's text color or NULL to reset the text to the default
+ * color. The color parameter is copied.
+ *
+ * Set the label's text color.
+ *
+ * Since: 0.4
+ */
+void
+champlain_label_set_text_color (ChamplainLabel *label,
+ const ClutterColor *color)
+{
+ g_return_if_fail (CHAMPLAIN_IS_LABEL (label));
+
+ ChamplainLabelPrivate *priv = label->priv;
+
+ if (priv->text_color != NULL)
+ clutter_color_free (priv->text_color);
+
+ if (color == NULL)
+ color = &DEFAULT_TEXT_COLOR;
+
+ priv->text_color = clutter_color_copy (color);
+ g_object_notify (G_OBJECT (label), "text-color");
+ champlain_label_queue_redraw (label);
+}
+
+
+/**
+ * champlain_label_set_font_name:
+ * @label: The label
+ * @font_name: (allow-none): The label's font name or NULL to reset the font to the default
+ * value.
+ *
+ * Set the label's font name such as "Sans 12".
+ *
+ * Since: 0.4
+ */
+void
+champlain_label_set_font_name (ChamplainLabel *label,
+ const gchar *font_name)
+{
+ g_return_if_fail (CHAMPLAIN_IS_LABEL (label));
+
+ ChamplainLabelPrivate *priv = label->priv;
+
+ if (priv->font_name != NULL)
+ g_free (priv->font_name);
+
+ if (font_name == NULL)
+ font_name = DEFAULT_FONT_NAME;
+
+ priv->font_name = g_strdup (font_name);
+ g_object_notify (G_OBJECT (label), "font-name");
+ champlain_label_queue_redraw (label);
+}
+
+
+/**
+ * champlain_label_set_wrap:
+ * @label: The label
+ * @wrap: The label's wrap.
+ *
+ * Set if the label's text wrap.
+ *
+ * Since: 0.4
+ */
+void
+champlain_label_set_wrap (ChamplainLabel *label,
+ gboolean wrap)
+{
+ g_return_if_fail (CHAMPLAIN_IS_LABEL (label));
+
+ label->priv->wrap = wrap;
+ g_object_notify (G_OBJECT (label), "wrap");
+ champlain_label_queue_redraw (label);
+}
+
+
+/**
+ * champlain_label_set_wrap_mode:
+ * @label: The label
+ * @wrap_mode: The label's wrap.
+ *
+ * Set the label's text color.
+ *
+ * Since: 0.4
+ */
+void
+champlain_label_set_wrap_mode (ChamplainLabel *label,
+ PangoWrapMode wrap_mode)
+{
+ g_return_if_fail (CHAMPLAIN_IS_LABEL (label));
+
+ label->priv->wrap_mode = wrap_mode;
+ g_object_notify (G_OBJECT (label), "wrap");
+ champlain_label_queue_redraw (label);
+}
+
+
+/**
+ * champlain_label_set_attributes:
+ * @label: The label
+ * @list: The label's text attributes.
+ *
+ * Set the label's text attribute.
+ *
+ * Since: 0.4
+ */
+void
+champlain_label_set_attributes (ChamplainLabel *label,
+ PangoAttrList *attributes)
+{
+ g_return_if_fail (CHAMPLAIN_IS_LABEL (label));
+
+ ChamplainLabelPrivate *priv = label->priv;
+
+ if (attributes)
+ pango_attr_list_ref (attributes);
+
+ if (priv->attributes)
+ pango_attr_list_unref (priv->attributes);
+
+ priv->attributes = attributes;
+
+ g_object_notify (G_OBJECT (label), "attributes");
+ champlain_label_queue_redraw (label);
+}
+
+
+/**
+ * champlain_label_set_ellipsize:
+ * @label: The label
+ * @mode: The label's ellipsize mode.
+ *
+ * Set the label's text ellipsize mode.
+ *
+ * Since: 0.4
+ */
+void
+champlain_label_set_ellipsize (ChamplainLabel *label,
+ PangoEllipsizeMode ellipsize)
+{
+ g_return_if_fail (CHAMPLAIN_IS_LABEL (label));
+
+ label->priv->ellipsize = ellipsize;
+ g_object_notify (G_OBJECT (label), "ellipsize");
+ champlain_label_queue_redraw (label);
+}
+
+
+/**
+ * champlain_label_set_single_line_mode:
+ * @label: The label
+ * @mode: The label's single line mode
+ *
+ * Set if the label's text is on a single line.
+ *
+ * Since: 0.4
+ */
+void
+champlain_label_set_single_line_mode (ChamplainLabel *label,
+ gboolean mode)
+{
+ g_return_if_fail (CHAMPLAIN_IS_LABEL (label));
+
+ label->priv->single_line_mode = mode;
+
+ g_object_notify (G_OBJECT (label), "single-line-mode");
+ champlain_label_queue_redraw (label);
+}
+
+
+/**
+ * champlain_label_set_draw_background:
+ * @label: The label
+ * @background: value.
+ *
+ * Set if the label has a background.
+ *
+ * Since: 0.4
+ */
+void
+champlain_label_set_draw_background (ChamplainLabel *label,
+ gboolean background)
+{
+ g_return_if_fail (CHAMPLAIN_IS_LABEL (label));
+
+ label->priv->draw_background = background;
+ g_object_notify (G_OBJECT (label), "draw-background");
+ champlain_label_queue_redraw (label);
+}
+
+
+/**
+ * champlain_label_get_image:
+ * @label: The label
+ *
+ * Get the label's image.
+ *
+ * Returns: (transfer none): the label's image.
+ *
+ * Since: 0.4
+ */
+ClutterActor *
+champlain_label_get_image (ChamplainLabel *label)
+{
+ g_return_val_if_fail (CHAMPLAIN_IS_LABEL (label), NULL);
+
+ return label->priv->image;
+}
+
+
+/**
+ * champlain_label_get_use_markup:
+ * @label: The label
+ *
+ * Check whether the label uses markup.
+ *
+ * Returns: if the label's text contains markup.
+ *
+ * Since: 0.4
+ */
+gboolean
+champlain_label_get_use_markup (ChamplainLabel *label)
+{
+ g_return_val_if_fail (CHAMPLAIN_IS_LABEL (label), FALSE);
+
+ return label->priv->use_markup;
+}
+
+
+/**
+ * champlain_label_get_text:
+ * @label: The label
+ *
+ * Get the label's text.
+ *
+ * Returns: the label's text.
+ *
+ * Since: 0.4
+ */
+const gchar *
+champlain_label_get_text (ChamplainLabel *label)
+{
+ g_return_val_if_fail (CHAMPLAIN_IS_LABEL (label), FALSE);
+
+ return label->priv->text;
+}
+
+
+/**
+ * champlain_label_get_alignment:
+ * @label: The label
+ *
+ * Get the label's text alignment.
+ *
+ * Returns: the label's text alignment.
+ *
+ * Since: 0.4
+ */
+PangoAlignment
+champlain_label_get_alignment (ChamplainLabel *label)
+{
+ g_return_val_if_fail (CHAMPLAIN_IS_LABEL (label), FALSE);
+
+ return label->priv->alignment;
+}
+
+
+/**
+ * champlain_label_get_color:
+ * @label: The label
+ *
+ * Gets the label's color.
+ *
+ * Returns: the label's color.
+ *
+ * Since: 0.4
+ */
+ClutterColor *
+champlain_label_get_color (ChamplainLabel *label)
+{
+ g_return_val_if_fail (CHAMPLAIN_IS_LABEL (label), NULL);
+
+ return label->priv->color;
+}
+
+
+/**
+ * champlain_label_get_text_color:
+ * @label: The label
+ *
+ * Gets the label's text color.
+ *
+ * Returns: the label's text color.
+ *
+ * Since: 0.4
+ */
+ClutterColor *
+champlain_label_get_text_color (ChamplainLabel *label)
+{
+ g_return_val_if_fail (CHAMPLAIN_IS_LABEL (label), NULL);
+
+ return label->priv->text_color;
+}
+
+
+/**
+ * champlain_label_get_font_name:
+ * @label: The label
+ *
+ * Gets the label's font name.
+ *
+ * Returns: the label's font name.
+ *
+ * Since: 0.4
+ */
+const gchar *
+champlain_label_get_font_name (ChamplainLabel *label)
+{
+ g_return_val_if_fail (CHAMPLAIN_IS_LABEL (label), FALSE);
+
+ return label->priv->font_name;
+}
+
+
+/**
+ * champlain_label_get_wrap:
+ * @label: The label
+ *
+ * Check whether the label text wraps.
+ *
+ * Returns: if the label's text wraps.
+ *
+ * Since: 0.4
+ */
+gboolean
+champlain_label_get_wrap (ChamplainLabel *label)
+{
+ g_return_val_if_fail (CHAMPLAIN_IS_LABEL (label), FALSE);
+
+ return label->priv->wrap;
+}
+
+
+/**
+ * champlain_label_get_wrap_mode:
+ * @label: The label
+ *
+ * Get the label's text wrap mode.
+ *
+ * Returns: the label's text wrap mode.
+ *
+ * Since: 0.4
+ */
+PangoWrapMode
+champlain_label_get_wrap_mode (ChamplainLabel *label)
+{
+ g_return_val_if_fail (CHAMPLAIN_IS_LABEL (label), FALSE);
+
+ return label->priv->wrap_mode;
+}
+
+
+/**
+ * champlain_label_get_ellipsize:
+ * @label: The label
+ *
+ * Get the label's text ellipsize mode.
+ *
+ * Returns: the label's text ellipsize mode.
+ *
+ * Since: 0.4
+ */
+PangoEllipsizeMode
+champlain_label_get_ellipsize (ChamplainLabel *label)
+{
+ g_return_val_if_fail (CHAMPLAIN_IS_LABEL (label), FALSE);
+
+ return label->priv->ellipsize;
+}
+
+
+/**
+ * champlain_label_get_single_line_mode:
+ * @label: The label
+ *
+ * Checks the label's single line mode.
+ *
+ * Returns: the label's text single line mode.
+ *
+ * Since: 0.4
+ */
+gboolean
+champlain_label_get_single_line_mode (ChamplainLabel *label)
+{
+ g_return_val_if_fail (CHAMPLAIN_IS_LABEL (label), FALSE);
+
+ return label->priv->single_line_mode;
+}
+
+
+/**
+ * champlain_label_get_draw_background:
+ * @label: The label
+ *
+ * Checks whether the label has a background.
+ *
+ * Returns: if the label's has a background.
+ *
+ * Since: 0.4
+ */
+gboolean
+champlain_label_get_draw_background (ChamplainLabel *label)
+{
+ g_return_val_if_fail (CHAMPLAIN_IS_LABEL (label), FALSE);
+
+ return label->priv->draw_background;
+}
diff --git a/champlain/champlain-label.h b/champlain/champlain-label.h
new file mode 100644
index 0000000..0dd1ec4
--- /dev/null
+++ b/champlain/champlain-label.h
@@ -0,0 +1,136 @@
+/*
+ * 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
+ * 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 <champlain/champlain.h> can be included directly."
+#endif
+
+#ifndef CHAMPLAIN_LABEL_H
+#define CHAMPLAIN_LABEL_H
+
+#include <champlain/champlain-marker.h>
+
+#include <glib-object.h>
+#include <clutter/clutter.h>
+
+G_BEGIN_DECLS
+
+#define CHAMPLAIN_TYPE_LABEL champlain_label_get_type ()
+
+#define CHAMPLAIN_LABEL(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), CHAMPLAIN_TYPE_LABEL, ChamplainLabel))
+
+#define CHAMPLAIN_LABEL_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST ((klass), CHAMPLAIN_TYPE_LABEL, ChamplainLabelClass))
+
+#define CHAMPLAIN_IS_LABEL(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CHAMPLAIN_TYPE_LABEL))
+
+#define CHAMPLAIN_IS_LABEL_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE ((klass), CHAMPLAIN_TYPE_LABEL))
+
+#define CHAMPLAIN_LABEL_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), CHAMPLAIN_TYPE_LABEL, ChamplainLabelClass))
+
+typedef struct _ChamplainLabelPrivate ChamplainLabelPrivate;
+
+typedef struct _ChamplainLabel ChamplainLabel;
+typedef struct _ChamplainLabelClass ChamplainLabelClass;
+
+struct _ChamplainLabel
+{
+ ChamplainMarker parent;
+
+ ChamplainLabelPrivate *priv;
+};
+
+struct _ChamplainLabelClass
+{
+ ChamplainMarkerClass parent_class;
+
+ void (*draw_label)(ChamplainLabel *label);
+};
+
+GType champlain_label_get_type (void);
+
+ClutterActor *champlain_label_new (void);
+
+ClutterActor *champlain_label_new_with_text (const gchar *text,
+ const gchar *font,
+ ClutterColor *text_color,
+ ClutterColor *label_color);
+
+ClutterActor *champlain_label_new_with_image (ClutterActor *actor);
+
+ClutterActor *champlain_label_new_from_file (const gchar *filename,
+ GError **error);
+
+ClutterActor *champlain_label_new_full (const gchar *text,
+ ClutterActor *actor);
+
+void champlain_label_set_text (ChamplainLabel *label,
+ const gchar *text);
+void champlain_label_set_image (ChamplainLabel *label,
+ ClutterActor *image);
+void champlain_label_set_use_markup (ChamplainLabel *label,
+ gboolean use_markup);
+void champlain_label_set_alignment (ChamplainLabel *label,
+ PangoAlignment alignment);
+void champlain_label_set_color (ChamplainLabel *label,
+ const ClutterColor *color);
+void champlain_label_set_text_color (ChamplainLabel *label,
+ const ClutterColor *color);
+void champlain_label_set_font_name (ChamplainLabel *label,
+ const gchar *font_name);
+void champlain_label_set_wrap (ChamplainLabel *label,
+ gboolean wrap);
+void champlain_label_set_wrap_mode (ChamplainLabel *label,
+ PangoWrapMode wrap_mode);
+void champlain_label_set_attributes (ChamplainLabel *label,
+ PangoAttrList *list);
+void champlain_label_set_single_line_mode (ChamplainLabel *label,
+ gboolean mode);
+void champlain_label_set_ellipsize (ChamplainLabel *label,
+ PangoEllipsizeMode mode);
+void champlain_label_set_draw_background (ChamplainLabel *label,
+ gboolean background);
+
+gboolean champlain_label_get_use_markup (ChamplainLabel *label);
+const gchar *champlain_label_get_text (ChamplainLabel *label);
+ClutterActor *champlain_label_get_image (ChamplainLabel *label);
+PangoAlignment champlain_label_get_alignment (ChamplainLabel *label);
+ClutterColor *champlain_label_get_color (ChamplainLabel *label);
+ClutterColor *champlain_label_get_text_color (ChamplainLabel *label);
+const gchar *champlain_label_get_font_name (ChamplainLabel *label);
+gboolean champlain_label_get_wrap (ChamplainLabel *label);
+PangoWrapMode champlain_label_get_wrap_mode (ChamplainLabel *label);
+PangoEllipsizeMode champlain_label_get_ellipsize (ChamplainLabel *label);
+gboolean champlain_label_get_single_line_mode (ChamplainLabel *label);
+gboolean champlain_label_get_draw_background (ChamplainLabel *label);
+
+void champlain_label_set_highlight_color (ClutterColor *color);
+const ClutterColor *champlain_label_get_highlight_color (void);
+
+void champlain_label_set_highlight_text_color (ClutterColor *color);
+const ClutterColor *champlain_label_get_highlight_text_color (void);
+
+void champlain_label_queue_redraw (ChamplainLabel *label);
+
+G_END_DECLS
+
+#endif
diff --git a/champlain/champlain-layer.c b/champlain/champlain-layer.c
index 38412f4..5ae1b36 100644
--- a/champlain/champlain-layer.c
+++ b/champlain/champlain-layer.c
@@ -32,7 +32,6 @@
#include "champlain-layer.h"
#include "champlain-defines.h"
-#include "champlain-base-marker.h"
#include "champlain-enum-types.h"
#include "champlain-private.h"
#include "champlain-view.h"
@@ -85,7 +84,7 @@ struct _ChamplainLayerPrivate
};
-static void marker_highlighted_cb (ChamplainBaseMarker *marker,
+static void marker_highlighted_cb (ChamplainMarker *marker,
G_GNUC_UNUSED GParamSpec *arg1,
ChamplainLayer *layer);
@@ -416,7 +415,7 @@ champlain_layer_new_full (ChamplainSelectionMode mode)
static void
set_highlighted_all_but_one (ChamplainLayer *layer,
- ChamplainBaseMarker *not_highlighted,
+ ChamplainMarker *not_highlighted,
gboolean highlight)
{
int i;
@@ -424,7 +423,7 @@ set_highlighted_all_but_one (ChamplainLayer *layer,
for (i = 1; i < clutter_group_get_n_children (CLUTTER_GROUP (layer)); i++)
{
ClutterActor *actor = clutter_group_get_nth_child (CLUTTER_GROUP (layer), i);
- ChamplainBaseMarker *marker = CHAMPLAIN_BASE_MARKER (actor);
+ ChamplainMarker *marker = CHAMPLAIN_MARKER (actor);
if (marker != not_highlighted)
{
@@ -432,8 +431,8 @@ set_highlighted_all_but_one (ChamplainLayer *layer,
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);
+ champlain_marker_set_highlighted (marker, highlight);
+ champlain_marker_set_selectable (marker, layer->priv->mode != CHAMPLAIN_SELECTION_NONE);
g_signal_handlers_unblock_by_func (marker,
G_CALLBACK (marker_highlighted_cb),
@@ -444,7 +443,7 @@ set_highlighted_all_but_one (ChamplainLayer *layer,
static void
-marker_highlighted_cb (ChamplainBaseMarker *marker,
+marker_highlighted_cb (ChamplainMarker *marker,
G_GNUC_UNUSED GParamSpec *arg1,
ChamplainLayer *layer)
{
@@ -456,7 +455,7 @@ marker_highlighted_cb (ChamplainBaseMarker *marker,
static void
-set_marker_position (ChamplainLayer *layer, ChamplainBaseMarker *marker)
+set_marker_position (ChamplainLayer *layer, ChamplainMarker *marker)
{
ChamplainLayerPrivate *priv = layer->priv;
gint x, y;
@@ -466,16 +465,16 @@ set_marker_position (ChamplainLayer *layer, ChamplainBaseMarker *marker)
return;
x = champlain_view_longitude_to_layer_x (priv->view,
- champlain_base_marker_get_longitude (marker));
+ champlain_marker_get_longitude (marker));
y = champlain_view_latitude_to_layer_y (priv->view,
- champlain_base_marker_get_latitude (marker));
+ champlain_marker_get_latitude (marker));
clutter_actor_set_position (CLUTTER_ACTOR (marker), x, y);
}
static void
-marker_position_notify (ChamplainBaseMarker *marker,
+marker_position_notify (ChamplainMarker *marker,
G_GNUC_UNUSED GParamSpec *pspec,
ChamplainLayer *layer)
{
@@ -485,7 +484,7 @@ marker_position_notify (ChamplainBaseMarker *marker,
static void
-marker_move_by_cb (ChamplainBaseMarker *marker,
+marker_move_by_cb (ChamplainMarker *marker,
gfloat dx,
gfloat dy,
ChamplainLayer *layer)
@@ -494,8 +493,8 @@ marker_move_by_cb (ChamplainBaseMarker *marker,
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 = champlain_view_longitude_to_x (view, champlain_marker_get_longitude (marker));
+ y = champlain_view_latitude_to_y (view, champlain_marker_get_latitude (marker));
x += dx;
y += dy;
@@ -503,14 +502,14 @@ marker_move_by_cb (ChamplainBaseMarker *marker,
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_marker_set_position (marker, lat, lon);
}
/**
* champlain_layer_add_marker:
* @layer: a #ChamplainLayer
- * @marker: a #ChamplainBaseMarker
+ * @marker: a #ChamplainMarker
*
* Adds the marker to the layer.
*
@@ -518,12 +517,12 @@ marker_move_by_cb (ChamplainBaseMarker *marker,
*/
void
champlain_layer_add_marker (ChamplainLayer *layer,
- ChamplainBaseMarker *marker)
+ ChamplainMarker *marker)
{
g_return_if_fail (CHAMPLAIN_IS_LAYER (layer));
- g_return_if_fail (CHAMPLAIN_IS_BASE_MARKER (marker));
+ g_return_if_fail (CHAMPLAIN_IS_MARKER (marker));
- champlain_base_marker_set_selectable (marker, layer->priv->mode != CHAMPLAIN_SELECTION_NONE);
+ champlain_marker_set_selectable (marker, layer->priv->mode != CHAMPLAIN_SELECTION_NONE);
g_signal_connect (G_OBJECT (marker), "notify::highlighted",
G_CALLBACK (marker_highlighted_cb), layer);
@@ -543,7 +542,7 @@ champlain_layer_add_marker (ChamplainLayer *layer,
/**
* champlain_layer_remove_marker:
* @layer: a #ChamplainLayer
- * @marker: a #ChamplainBaseMarker
+ * @marker: a #ChamplainMarker
*
* Removes the marker from the layer.
*
@@ -551,10 +550,10 @@ champlain_layer_add_marker (ChamplainLayer *layer,
*/
void
champlain_layer_remove_marker (ChamplainLayer *layer,
- ChamplainBaseMarker *marker)
+ ChamplainMarker *marker)
{
g_return_if_fail (CHAMPLAIN_IS_LAYER (layer));
- g_return_if_fail (CHAMPLAIN_IS_BASE_MARKER (marker));
+ g_return_if_fail (CHAMPLAIN_IS_MARKER (marker));
g_signal_handlers_disconnect_by_func (G_OBJECT (marker),
G_CALLBACK (marker_highlighted_cb), layer);
@@ -586,9 +585,9 @@ champlain_layer_animate_in_all_markers (ChamplainLayer *layer)
for (i = 1; i < clutter_group_get_n_children (CLUTTER_GROUP (layer)); i++)
{
ClutterActor *actor = clutter_group_get_nth_child (CLUTTER_GROUP (layer), i);
- ChamplainBaseMarker *marker = CHAMPLAIN_BASE_MARKER (actor);
+ ChamplainMarker *marker = CHAMPLAIN_MARKER (actor);
- champlain_base_marker_animate_in_with_delay (marker, delay);
+ champlain_marker_animate_in_with_delay (marker, delay);
delay += 50;
}
}
@@ -613,9 +612,9 @@ champlain_layer_animate_out_all_markers (ChamplainLayer *layer)
for (i = 1; i < clutter_group_get_n_children (CLUTTER_GROUP (layer)); i++)
{
ClutterActor *actor = clutter_group_get_nth_child (CLUTTER_GROUP (layer), i);
- ChamplainBaseMarker *marker = CHAMPLAIN_BASE_MARKER (actor);
+ ChamplainMarker *marker = CHAMPLAIN_MARKER (actor);
- champlain_base_marker_animate_out_with_delay (marker, delay);
+ champlain_marker_animate_out_with_delay (marker, delay);
delay += 50;
}
}
@@ -677,9 +676,9 @@ champlain_layer_set_all_markers_movable (ChamplainLayer *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));
+ ChamplainMarker *marker = CHAMPLAIN_MARKER (clutter_group_get_nth_child (CLUTTER_GROUP (layer), i));
- champlain_base_marker_set_movable (marker, TRUE);
+ champlain_marker_set_movable (marker, TRUE);
}
}
@@ -693,9 +692,9 @@ champlain_layer_set_all_markers_unmovable (ChamplainLayer *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));
+ ChamplainMarker *marker = CHAMPLAIN_MARKER (clutter_group_get_nth_child (CLUTTER_GROUP (layer), i));
- champlain_base_marker_set_movable (marker, FALSE);
+ champlain_marker_set_movable (marker, FALSE);
}
}
@@ -707,7 +706,7 @@ champlain_layer_set_all_markers_unmovable (ChamplainLayer *layer)
*
* Gets the list of selected markers.
*
- * Returns: (transfer container) (element-type ChamplainBaseMarker): the list of selected #ChamplainBaseMarker or NULL if none is selected.
+ * Returns: (transfer container) (element-type ChamplainMarker): the list of selected #ChamplainMarker or NULL if none is selected.
* You should free the list but not the elements of the list.
*
* Since: 0.10
@@ -835,7 +834,7 @@ relocate (ChamplainLayer *layer)
for (i = 1; i < n_children; i++)
{
ClutterActor *actor = clutter_group_get_nth_child (CLUTTER_GROUP (layer), i);
- ChamplainBaseMarker *marker = CHAMPLAIN_BASE_MARKER (actor);
+ ChamplainMarker *marker = CHAMPLAIN_MARKER (actor);
set_marker_position (layer, marker);
}
@@ -892,11 +891,11 @@ redraw_polygon (ChamplainLayer *layer)
for (i = 1; i < n_children; i++)
{
ClutterActor *actor = clutter_group_get_nth_child (CLUTTER_GROUP (layer), i);
- ChamplainBaseMarker *marker = CHAMPLAIN_BASE_MARKER (actor);
+ ChamplainMarker *marker = CHAMPLAIN_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_marker_get_longitude (marker));
+ y = champlain_view_latitude_to_y (view, champlain_marker_get_latitude (marker));
cairo_line_to (cr, x, y);
}
@@ -981,13 +980,13 @@ void champlain_layer_set_view (ChamplainLayer *layer,
*/
/*void
champlain_view_ensure_markers_visible (ChamplainView *view,
- ChamplainBaseMarker *markers[],
+ ChamplainMarker *markers[],
gboolean animate)
{
DEBUG_LOG ()
gdouble min_lat, min_lon, max_lat, max_lon;
- ChamplainBaseMarker *marker = NULL;
+ ChamplainMarker *marker = NULL;
gint i = 0;
min_lat = min_lon = 200;
diff --git a/champlain/champlain-layer.h b/champlain/champlain-layer.h
index 075eb26..0b791d2 100644
--- a/champlain/champlain-layer.h
+++ b/champlain/champlain-layer.h
@@ -24,7 +24,7 @@
#define CHAMPLAIN_LAYER_H
#include <champlain/champlain-defines.h>
-#include <champlain/champlain-base-marker.h>
+#include <champlain/champlain-marker.h>
#include <glib-object.h>
#include <clutter/clutter.h>
@@ -85,9 +85,9 @@ GType champlain_layer_get_type (void);
ChamplainLayer *champlain_layer_new_full (ChamplainSelectionMode mode);
void champlain_layer_add_marker (ChamplainLayer *layer,
- ChamplainBaseMarker *marker);
+ ChamplainMarker *marker);
void champlain_layer_remove_marker (ChamplainLayer *layer,
- ChamplainBaseMarker *marker);
+ ChamplainMarker *marker);
void champlain_layer_set_view (ChamplainLayer *layer,
ChamplainView *view);
@@ -110,7 +110,7 @@ void champlain_layer_set_selection_mode (ChamplainLayer *layer,
ChamplainSelectionMode champlain_layer_get_selection_mode (
ChamplainLayer *layer);
//void champlain_view_ensure_markers_visible (ChamplainView *view,
-// ChamplainBaseMarker *markers[],
+// ChamplainMarker *markers[],
// gboolean animate);
ClutterColor *champlain_layer_get_polygon_fill_color (ChamplainLayer *layer);
diff --git a/champlain/champlain-marker.c b/champlain/champlain-marker.c
index 476a4d1..d03f6b9 100644
--- a/champlain/champlain-marker.c
+++ b/champlain/champlain-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
@@ -20,16 +21,17 @@
* 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.
+ * 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.
+ * A 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
+ * marker using #clutter_actor_set_anchor_point. 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.
+ * champlain has a more evoluted type of markers with text and image support.
+ * See #ChamplainMarker.
*/
#include "config.h"
@@ -37,7 +39,6 @@
#include "champlain-marker.h"
#include "champlain.h"
-#include "champlain-base-marker.h"
#include "champlain-defines.h"
#include "champlain-marshal.h"
#include "champlain-private.h"
@@ -48,140 +49,43 @@
#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 SELECTED_TEXT_COLOR = { 0xff, 0xff, 0xff, 0xff };
-
-static ClutterColor DEFAULT_COLOR = { 0x33, 0x33, 0x33, 0xff };
-static ClutterColor DEFAULT_TEXT_COLOR = { 0xee, 0xee, 0xee, 0xff };
enum
{
/* normal signals */
- LAST_SIGNAL
+ MOVE_BY_SIGNAL,
+ LAST_SIGNAL,
};
+static guint signals[LAST_SIGNAL] = { 0, };
+
enum
{
PROP_0,
- PROP_IMAGE,
- PROP_TEXT,
- PROP_USE_MARKUP,
- PROP_ALIGNMENT,
- PROP_ATTRIBUTES,
- PROP_ELLIPSIZE,
- PROP_COLOR,
- PROP_TEXT_COLOR,
- PROP_FONT_NAME,
- PROP_WRAP,
- PROP_WRAP_MODE,
- PROP_SINGLE_LINE_MODE,
- PROP_DRAW_BACKGROUND
+ PROP_LONGITUDE,
+ PROP_LATITUDE,
+ PROP_HIGHLIGHTED,
+ PROP_SELECTABLE,
+ PROP_MOVABLE,
};
/* static guint champlain_marker_signals[LAST_SIGNAL] = { 0, }; */
-struct _ChamplainMarkerPrivate
-{
- gchar *text;
- ClutterActor *image;
- gboolean use_markup;
- PangoAlignment alignment;
- PangoAttrList *attributes;
- ClutterColor *color;
- ClutterColor *text_color;
- gchar *font_name;
- gboolean wrap;
- PangoWrapMode wrap_mode;
- gboolean single_line_mode;
- PangoEllipsizeMode ellipsize;
- gboolean draw_background;
-
- ClutterActor *text_actor;
- ClutterActor *shadow;
- ClutterActor *background;
- guint redraw_id;
-};
+G_DEFINE_TYPE (ChamplainMarker, champlain_marker, CLUTTER_TYPE_GROUP);
-G_DEFINE_TYPE (ChamplainMarker, champlain_marker, CHAMPLAIN_TYPE_BASE_MARKER);
-
-#define GET_PRIVATE(obj) \
+#define CHAMPLAIN_MARKER_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), CHAMPLAIN_TYPE_MARKER, ChamplainMarkerPrivate))
-static void draw_marker (ChamplainMarker *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_marker_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.
- *
- * Returns: the highlight color. Should not be freed.
- *
- * Since: 0.4.1
- */
-const ClutterColor *
-champlain_marker_get_highlight_color ()
-{
- return &SELECTED_COLOR;
-}
-
-
-/**
- * champlain_marker_set_highlight_text_color:
- * @color: a #ClutterColor
- *
- * Changes the highlight text color, this is to ensure a better integration with
- * the desktop, this is automatically done by GtkChamplainEmbed.
- *
- * Since: 0.4
- */
-void
-champlain_marker_set_highlight_text_color (ClutterColor *color)
-{
- SELECTED_TEXT_COLOR.red = color->red;
- SELECTED_TEXT_COLOR.green = color->green;
- SELECTED_TEXT_COLOR.blue = color->blue;
- SELECTED_TEXT_COLOR.alpha = color->alpha;
-}
-
-
-/**
- * champlain_marker_get_highlight_text_color:
- *
- * Gets the highlight text color.
- *
- * Returns: the highlight text color. Should not be freed.
- *
- * Since: 0.4.1
- */
-const ClutterColor *
-champlain_marker_get_highlight_text_color ()
+struct _ChamplainMarkerPrivate
{
- return &SELECTED_TEXT_COLOR;
-}
-
+ gdouble lon;
+ gdouble lat;
+ gboolean highlighted;
+ gboolean selectable;
+ gboolean movable;
+
+ ChamplainFloatPoint click_coord;
+};
static void
champlain_marker_get_property (GObject *object,
@@ -189,58 +93,31 @@ champlain_marker_get_property (GObject *object,
GValue *value,
GParamSpec *pspec)
{
- ChamplainMarkerPrivate *priv = CHAMPLAIN_MARKER (object)->priv;
+ ChamplainMarker *marker = CHAMPLAIN_MARKER (object);
+ ChamplainMarkerPrivate *priv = marker->priv;
switch (prop_id)
{
- case PROP_TEXT:
- g_value_set_string (value, priv->text);
+ case PROP_LONGITUDE:
+ g_value_set_double (value, priv->lon);
break;
- case PROP_IMAGE:
- g_value_set_object (value, priv->image);
+ case PROP_LATITUDE:
+ g_value_set_double (value, priv->lat);
break;
- case PROP_USE_MARKUP:
- g_value_set_boolean (value, priv->use_markup);
+ case PROP_HIGHLIGHTED:
+ g_value_set_boolean (value, priv->highlighted);
break;
- case PROP_ALIGNMENT:
- g_value_set_enum (value, priv->alignment);
+ case PROP_SELECTABLE:
+ g_value_set_boolean (value, priv->selectable);
break;
-
- case PROP_COLOR:
- clutter_value_set_color (value, priv->color);
+
+ case PROP_MOVABLE:
+ g_value_set_boolean (value, priv->movable);
break;
-
- case PROP_TEXT_COLOR:
- clutter_value_set_color (value, priv->text_color);
- break;
-
- case PROP_FONT_NAME:
- g_value_set_string (value, priv->font_name);
- break;
-
- case PROP_WRAP:
- g_value_set_boolean (value, priv->wrap);
- break;
-
- case PROP_WRAP_MODE:
- g_value_set_enum (value, priv->wrap_mode);
- break;
-
- case PROP_DRAW_BACKGROUND:
- g_value_set_boolean (value, priv->draw_background);
- break;
-
- case PROP_ELLIPSIZE:
- g_value_set_enum (value, priv->ellipsize);
- break;
-
- case PROP_SINGLE_LINE_MODE:
- g_value_set_enum (value, priv->single_line_mode);
- break;
-
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@@ -254,56 +131,44 @@ champlain_marker_set_property (GObject *object,
GParamSpec *pspec)
{
ChamplainMarker *marker = CHAMPLAIN_MARKER (object);
+ ChamplainMarkerPrivate *priv = marker->priv;
switch (prop_id)
{
- case PROP_TEXT:
- champlain_marker_set_text (marker, g_value_get_string (value));
- break;
-
- case PROP_IMAGE:
- champlain_marker_set_image (marker, g_value_get_object (value));
- break;
-
- case PROP_USE_MARKUP:
- champlain_marker_set_use_markup (marker, g_value_get_boolean (value));
- break;
-
- case PROP_ALIGNMENT:
- champlain_marker_set_alignment (marker, g_value_get_enum (value));
- break;
-
- case PROP_COLOR:
- champlain_marker_set_color (marker, clutter_value_get_color (value));
- break;
-
- case PROP_TEXT_COLOR:
- champlain_marker_set_text_color (marker, clutter_value_get_color (value));
- break;
-
- case PROP_FONT_NAME:
- champlain_marker_set_font_name (marker, g_value_get_string (value));
- break;
-
- case PROP_WRAP:
- champlain_marker_set_wrap (marker, g_value_get_boolean (value));
+ case PROP_LONGITUDE:
+ {
+ gdouble lon = g_value_get_double (value);
+ champlain_marker_set_position (marker, priv->lat, lon);
break;
+ }
- case PROP_WRAP_MODE:
- champlain_marker_set_wrap_mode (marker, g_value_get_enum (value));
+ case PROP_LATITUDE:
+ {
+ gdouble lat = g_value_get_double (value);
+ champlain_marker_set_position (marker, lat, priv->lon);
break;
+ }
- case PROP_ELLIPSIZE:
- champlain_marker_set_ellipsize (marker, g_value_get_enum (value));
+ case PROP_HIGHLIGHTED:
+ {
+ gboolean bvalue = g_value_get_boolean (value);
+ champlain_marker_set_highlighted (marker, bvalue);
break;
+ }
- case PROP_DRAW_BACKGROUND:
- champlain_marker_set_draw_background (marker, g_value_get_boolean (value));
+ case PROP_SELECTABLE:
+ {
+ gboolean bvalue = g_value_get_boolean (value);
+ champlain_marker_set_selectable (marker, bvalue);
break;
+ }
- case PROP_SINGLE_LINE_MODE:
- champlain_marker_set_single_line_mode (marker, g_value_get_boolean (value));
+ case PROP_MOVABLE:
+ {
+ gboolean bvalue = g_value_get_boolean (value);
+ champlain_marker_set_movable (marker, bvalue);
break;
+ }
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -314,38 +179,6 @@ champlain_marker_set_property (GObject *object,
static void
champlain_marker_dispose (GObject *object)
{
- ChamplainMarkerPrivate *priv = CHAMPLAIN_MARKER (object)->priv;
-
- if (priv->background)
- {
- g_object_unref (priv->background);
- priv->background = NULL;
- }
-
- if (priv->shadow)
- {
- g_object_unref (priv->shadow);
- priv->shadow = NULL;
- }
-
- if (priv->text_actor)
- {
- g_object_unref (priv->text_actor);
- priv->text_actor = NULL;
- }
-
- if (priv->image)
- {
- g_object_unref (priv->image);
- priv->image = NULL;
- }
-
- if (priv->attributes)
- {
- pango_attr_list_unref (priv->attributes);
- priv->attributes = NULL;
- }
-
G_OBJECT_CLASS (champlain_marker_parent_class)->dispose (object);
}
@@ -353,518 +186,203 @@ champlain_marker_dispose (GObject *object)
static void
champlain_marker_finalize (GObject *object)
{
- ChamplainMarkerPrivate *priv = CHAMPLAIN_MARKER (object)->priv;
-
- if (priv->text)
- {
- g_free (priv->text);
- priv->text = NULL;
- }
-
- if (priv->font_name)
- {
- g_free (priv->font_name);
- priv->font_name = NULL;
- }
-
- if (priv->color)
- {
- clutter_color_free (priv->color);
- priv->color = NULL;
- }
-
- if (priv->text_color)
- {
- clutter_color_free (priv->text_color);
- priv->text_color = NULL;
- }
-
- if (priv->redraw_id)
- {
- g_source_remove (priv->redraw_id);
- priv->redraw_id = 0;
- }
-
G_OBJECT_CLASS (champlain_marker_parent_class)->finalize (object);
}
static void
-champlain_marker_class_init (ChamplainMarkerClass *markerClass)
+champlain_marker_class_init (ChamplainMarkerClass *marker_class)
{
- g_type_class_add_private (markerClass, sizeof (ChamplainMarkerPrivate));
+ g_type_class_add_private (marker_class, sizeof (ChamplainMarkerPrivate));
- GObjectClass *object_class = G_OBJECT_CLASS (markerClass);
+ GObjectClass *object_class = G_OBJECT_CLASS (marker_class);
object_class->finalize = champlain_marker_finalize;
object_class->dispose = champlain_marker_dispose;
object_class->get_property = champlain_marker_get_property;
object_class->set_property = champlain_marker_set_property;
- markerClass->draw_marker = draw_marker;
/**
- * ChamplainMarker:text:
+ * ChamplainMarker:longitude:
*
- * The text of the marker
+ * The longitude coordonate of the map
*
* Since: 0.4
*/
- g_object_class_install_property (object_class, PROP_TEXT,
- g_param_spec_string ("text", "Text", "The text of the marker",
- "", CHAMPLAIN_PARAM_READWRITE));
+ 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:image:
+ * ChamplainMarker:latitude:
*
- * The image of the marker
+ * The latitude coordonate of the map
*
* Since: 0.4
*/
- g_object_class_install_property (object_class, PROP_IMAGE,
- g_param_spec_object ("image", "Image", "The image of the marker",
- CLUTTER_TYPE_ACTOR, CHAMPLAIN_PARAM_READWRITE));
+ 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));
/**
- * ChamplainMarker:use-markup:
+ * ChamplainMarker:highlighted:
*
- * If the marker's text uses markup
+ * The highlighted state of the marker
*
* Since: 0.4
*/
- g_object_class_install_property (object_class, PROP_USE_MARKUP,
- g_param_spec_boolean ("use-markup", "Use Markup", "The text uses markup",
+ g_object_class_install_property (object_class, PROP_HIGHLIGHTED,
+ g_param_spec_boolean ("highlighted", "Highlighted",
+ "The highlighted stated of the marker",
FALSE, CHAMPLAIN_PARAM_READWRITE));
-
- /**
- * ChamplainMarker:alignment:
- *
- * The marker's alignment
- *
- * Since: 0.4
- */
- g_object_class_install_property (object_class, PROP_ALIGNMENT,
- g_param_spec_enum ("alignment", "Alignment", "The marker's alignment",
- PANGO_TYPE_ALIGNMENT, PANGO_ALIGN_LEFT, CHAMPLAIN_PARAM_READWRITE));
-
+
/**
- * ChamplainMarker:color:
+ * ChamplainMarker:selectable:
*
- * The marker's color
+ * The selectable state of the marker
*
- * Since: 0.4
+ * Since: 0.10
*/
- g_object_class_install_property (object_class, PROP_COLOR,
- clutter_param_spec_color ("color", "Color", "The marker's color",
- &DEFAULT_COLOR, CHAMPLAIN_PARAM_READWRITE));
-
- /**
- * ChamplainMarker:text-color:
- *
- * The marker's text color
- *
- * Since: 0.4
- */
- g_object_class_install_property (object_class, PROP_TEXT_COLOR,
- clutter_param_spec_color ("text-color", "Text Color", "The marker's text color",
- &DEFAULT_TEXT_COLOR, CHAMPLAIN_PARAM_READWRITE));
-
- /**
- * ChamplainMarker:font-name:
- *
- * The marker's text font name
- *
- * Since: 0.4
- */
- g_object_class_install_property (object_class, PROP_FONT_NAME,
- g_param_spec_string ("font-name", "Font Name", "The marker's text font name",
- "Sans 11", CHAMPLAIN_PARAM_READWRITE));
-
- /**
- * ChamplainMarker:wrap:
- *
- * If the marker's text wrap is set
- *
- * Since: 0.4
- */
- g_object_class_install_property (object_class, PROP_WRAP,
- g_param_spec_boolean ("wrap", "Wrap", "The marker's text wrap",
+ g_object_class_install_property (object_class, PROP_SELECTABLE,
+ g_param_spec_boolean ("selectable", "Selectable",
+ "The movable stated of the marker",
FALSE, CHAMPLAIN_PARAM_READWRITE));
/**
- * ChamplainMarker:wrap-mode:
- *
- * The marker's text wrap mode
- *
- * Since: 0.4
- */
- g_object_class_install_property (object_class, PROP_WRAP_MODE,
- g_param_spec_enum ("wrap-mode", "Wrap Mode", "The marker's text wrap mode",
- PANGO_TYPE_WRAP_MODE, PANGO_WRAP_WORD, CHAMPLAIN_PARAM_READWRITE));
-
- /**
- * ChamplainMarker:ellipsize:
- *
- * The marker's ellipsize mode
- *
- * Since: 0.4
- */
- g_object_class_install_property (object_class, PROP_ELLIPSIZE,
- g_param_spec_enum ("ellipsize", "Ellipsize Mode", "The marker's text ellipsize mode",
- PANGO_TYPE_ELLIPSIZE_MODE, PANGO_ELLIPSIZE_NONE, CHAMPLAIN_PARAM_READWRITE));
-
- /**
- * ChamplainMarker:draw-background:
- *
- * If the marker has a background
- *
- * Since: 0.4
- */
- g_object_class_install_property (object_class, PROP_DRAW_BACKGROUND,
- g_param_spec_boolean ("draw-background", "Draw Background", "The marker has a background",
- TRUE, CHAMPLAIN_PARAM_READWRITE));
-
- /**
- * ChamplainMarker:single-line-mode:
+ * ChamplainMarker:movable:
*
- * If the marker is in single line mode
+ * The movable state of the marker
*
- * Since: 0.4
+ * Since: 0.10
*/
- g_object_class_install_property (object_class, PROP_SINGLE_LINE_MODE,
- g_param_spec_boolean ("single-line-mode", "Single Line Mode", "The marker's single line mode",
- TRUE, CHAMPLAIN_PARAM_READWRITE));
-}
-
-
-#define RADIUS 10
-#define PADDING (RADIUS / 2)
+ g_object_class_install_property (object_class, PROP_MOVABLE,
+ g_param_spec_boolean ("movable", "Movable",
+ "The movable state of the marker",
+ FALSE, CHAMPLAIN_PARAM_READWRITE));
-static void
-draw_box (cairo_t *cr,
- gint width,
- gint height,
- gint point,
- gboolean mirror)
-{
- if (mirror)
- {
- cairo_move_to (cr, RADIUS, 0);
- cairo_line_to (cr, width - RADIUS, 0);
- cairo_arc (cr, width - RADIUS, RADIUS, RADIUS - 1, 3 * M_PI / 2.0, 0);
- cairo_line_to (cr, width, height - RADIUS);
- cairo_arc (cr, width - RADIUS, height - RADIUS, RADIUS - 1, 0, M_PI / 2.0);
- cairo_line_to (cr, point, height);
- cairo_line_to (cr, 0, height + point);
- cairo_arc (cr, RADIUS, RADIUS, RADIUS - 1, M_PI, 3 * M_PI / 2.0);
- cairo_close_path (cr);
- }
- else
- {
- cairo_move_to (cr, RADIUS, 0);
- cairo_line_to (cr, width - RADIUS, 0);
- cairo_arc (cr, width - RADIUS, RADIUS, RADIUS - 1, 3 * M_PI / 2.0, 0);
- cairo_line_to (cr, width, height + point);
- cairo_line_to (cr, width - point, height);
- cairo_line_to (cr, RADIUS, height);
- cairo_arc (cr, RADIUS, height - RADIUS, RADIUS - 1, M_PI / 2.0, M_PI);
- cairo_line_to (cr, 0, RADIUS);
- cairo_arc (cr, RADIUS, RADIUS, RADIUS - 1, M_PI, 3 * M_PI / 2.0);
- cairo_close_path (cr);
- }
+ 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);
}
-static void
-draw_shadow (ChamplainMarker *marker,
- gint width,
- gint height,
- gint point)
+static gboolean
+motion_event_cb (ClutterActor *stage,
+ ClutterMotionEvent *event,
+ ChamplainMarker *marker)
{
ChamplainMarkerPrivate *priv = marker->priv;
- ClutterActor *shadow = NULL;
- cairo_t *cr;
- gdouble slope;
- gdouble scaling;
- gint x;
- cairo_matrix_t matrix;
-
- slope = -0.3;
- scaling = 0.65;
- if (priv->alignment == PANGO_ALIGN_LEFT)
- x = -40 * slope;
- else
- x = -58 * slope;
-
- shadow = clutter_cairo_texture_new (width + x, (height + point));
- cr = clutter_cairo_texture_create (CLUTTER_CAIRO_TEXTURE (shadow));
-
- cairo_matrix_init (&matrix,
- 1, 0,
- slope, scaling,
- x, 0);
- cairo_set_matrix (cr, &matrix);
-
- draw_box (cr, width, height, point, priv->alignment == PANGO_ALIGN_LEFT);
+ ChamplainFloatPoint coord;
- cairo_set_source_rgba (cr, 0, 0, 0, 0.15);
- cairo_fill (cr);
+ if (event->type != CLUTTER_MOTION)
+ return FALSE;
- cairo_destroy (cr);
-
- clutter_actor_set_position (shadow, 0, height / 2.0);
-
- clutter_container_add_actor (CLUTTER_CONTAINER (marker), shadow);
-
- if (priv->shadow != NULL)
+ if (clutter_actor_transform_stage_point (CLUTTER_ACTOR (marker),
+ event->x,
+ event->y,
+ &coord.x, &coord.y))
{
- clutter_container_remove_actor (CLUTTER_CONTAINER (marker),
- priv->shadow);
- g_object_unref (priv->shadow);
+ gfloat dx = coord.x - priv->click_coord.x;
+ gfloat dy = coord.y - priv->click_coord.y;
+
+ g_signal_emit_by_name (marker, "move-by", dx, dy);
}
- priv->shadow = g_object_ref (shadow);
+ return TRUE;
}
-static void
-draw_background (ChamplainMarker *marker,
- gint width,
- gint height,
- gint point)
+static gboolean
+button_release_event_cb (ClutterActor *stage,
+ ClutterButtonEvent *event,
+ ChamplainMarker *marker)
{
- ChamplainMarkerPrivate *priv = marker->priv;
- ChamplainBaseMarker *base_marker = CHAMPLAIN_BASE_MARKER (marker);
- ClutterActor *bg = NULL;
- ClutterColor *color;
- ClutterColor darker_color;
- cairo_t *cr;
-
- bg = clutter_cairo_texture_new (width, height + point);
- cr = clutter_cairo_texture_create (CLUTTER_CAIRO_TEXTURE (bg));
-
- /* If selected, add the selection color to the marker's color */
- if (champlain_base_marker_get_highlighted (base_marker))
- color = &SELECTED_COLOR;
- else
- color = priv->color;
+ if ((event->type != CLUTTER_BUTTON_RELEASE) ||
+ (event->button != 1))
+ return FALSE;
+ g_signal_handlers_disconnect_by_func (stage,
+ motion_event_cb,
+ marker);
+ g_signal_handlers_disconnect_by_func (stage,
+ button_release_event_cb,
+ marker);
+
+ clutter_set_motion_events_enabled (TRUE);
- draw_box (cr, width, height, point, priv->alignment == PANGO_ALIGN_LEFT);
-
- clutter_color_darken (color, &darker_color);
-
- cairo_set_source_rgba (cr,
- color->red / 255.0,
- color->green / 255.0,
- color->blue / 255.0,
- color->alpha / 255.0);
- cairo_fill_preserve (cr);
-
- cairo_set_line_width (cr, 1.0);
- cairo_set_source_rgba (cr,
- darker_color.red / 255.0,
- darker_color.green / 255.0,
- darker_color.blue / 255.0,
- darker_color.alpha / 255.0);
- cairo_stroke (cr);
- cairo_destroy (cr);
-
- clutter_container_add_actor (CLUTTER_CONTAINER (marker), bg);
-
- if (priv->background != NULL)
- {
- clutter_container_remove_actor (CLUTTER_CONTAINER (marker),
- priv->background);
- g_object_unref (priv->background);
- }
-
- priv->background = g_object_ref (bg);
+ return TRUE;
}
-static void
-draw_marker (ChamplainMarker *marker)
+static gboolean
+button_press_event_cb (ClutterActor *actor,
+ ClutterEvent *event,
+ ChamplainMarker *marker)
{
ChamplainMarkerPrivate *priv = marker->priv;
- ChamplainBaseMarker *base_marker = CHAMPLAIN_BASE_MARKER (marker);
- guint height = 0, point = 0;
- guint total_width = 0, total_height = 0;
+ ClutterButtonEvent *bevent = (ClutterButtonEvent *)event;
+ ClutterActor *stage = clutter_actor_get_stage (actor);
+ gboolean swallow_event = FALSE;
- if (priv->image != NULL)
+ if (event->type != CLUTTER_BUTTON_PRESS ||
+ bevent->button != 1 ||
+ !stage)
{
- clutter_actor_set_position (priv->image, PADDING, PADDING);
- total_width = clutter_actor_get_width (priv->image) + 2 * PADDING;
- total_height = clutter_actor_get_height (priv->image) + 2 * PADDING;
- if (clutter_actor_get_parent (priv->image) == NULL)
- clutter_container_add_actor (CLUTTER_CONTAINER (marker), priv->image);
+ return FALSE;
}
- if (priv->text != NULL && strlen (priv->text) > 0)
+ if (priv->selectable)
{
- ClutterText *label;
- if (priv->text_actor == NULL)
- {
- priv->text_actor = clutter_text_new_with_text (priv->font_name, priv->text);
- g_object_ref (priv->text_actor);
- }
-
- label = CLUTTER_TEXT (priv->text_actor);
- clutter_text_set_font_name (label, priv->font_name);
- clutter_text_set_text (label, priv->text);
- clutter_text_set_line_alignment (label, priv->alignment);
- clutter_text_set_line_wrap (label, priv->wrap);
- clutter_text_set_line_wrap_mode (label, priv->wrap_mode);
- clutter_text_set_ellipsize (label, priv->ellipsize);
- clutter_text_set_attributes (label, priv->attributes);
- clutter_text_set_use_markup (label, priv->use_markup);
-
- height = clutter_actor_get_height (priv->text_actor);
- if (priv->image != NULL)
- {
- clutter_actor_set_position (priv->text_actor, total_width, (total_height - height) / 2.0);
- total_width += clutter_actor_get_width (priv->text_actor) + 2 * PADDING;
- }
- else
- {
- clutter_actor_set_position (priv->text_actor, 2 * PADDING, PADDING);
- total_width += clutter_actor_get_width (priv->text_actor) + 4 * PADDING;
- }
-
- height += 2 * PADDING;
- if (height > total_height)
- total_height = height;
-
- clutter_text_set_color (CLUTTER_TEXT (priv->text_actor),
- (champlain_base_marker_get_highlighted (base_marker) ? &SELECTED_TEXT_COLOR : priv->text_color));
- if (clutter_actor_get_parent (priv->text_actor) == NULL)
- clutter_container_add_actor (CLUTTER_CONTAINER (marker), priv->text_actor);
- }
-
- if (priv->text_actor == NULL && priv->image == NULL)
- {
- total_width = 6 * PADDING;
- total_height = 6 * PADDING;
+ champlain_marker_set_highlighted (marker, TRUE);
+ swallow_event = TRUE;
}
-
- point = (total_height + 2 * PADDING) / 4.0;
-
- if (priv->draw_background)
+
+ if (clutter_actor_transform_stage_point (actor, bevent->x, bevent->y,
+ &priv->click_coord.x, &priv->click_coord.y))
{
- draw_shadow (marker, total_width, total_height, point);
- draw_background (marker, total_width, total_height, point);
- }
- else
- {
- if (priv->background != NULL)
- {
- clutter_container_remove_actor (CLUTTER_CONTAINER (marker), priv->background);
- g_object_unref (G_OBJECT (priv->background));
- priv->background = NULL;
- }
-
- if (priv->shadow != NULL)
+ if (priv->movable)
{
- clutter_container_remove_actor (CLUTTER_CONTAINER (marker), priv->shadow);
- g_object_unref (G_OBJECT (priv->shadow));
- priv->shadow = NULL;
+ g_signal_connect (stage,
+ "captured-event",
+ G_CALLBACK (motion_event_cb),
+ marker);
+
+ g_signal_connect (stage,
+ "captured-event",
+ G_CALLBACK (button_release_event_cb),
+ marker);
+
+ clutter_set_motion_events_enabled (FALSE);
+
+ swallow_event = TRUE;
}
}
- if (priv->text_actor != NULL && priv->background != NULL)
- clutter_actor_raise (priv->text_actor, priv->background);
- if (priv->image != NULL && priv->background != NULL)
- clutter_actor_raise (priv->image, priv->background);
-
- if (priv->draw_background)
- {
- if (priv->alignment == PANGO_ALIGN_RIGHT)
- clutter_actor_set_anchor_point (CLUTTER_ACTOR (marker), total_width, total_height + point);
- else
- clutter_actor_set_anchor_point (CLUTTER_ACTOR (marker), 0, total_height + point);
- }
- else if (priv->image != NULL)
- clutter_actor_set_anchor_point (CLUTTER_ACTOR (marker),
- clutter_actor_get_width (priv->image) / 2.0 + PADDING,
- clutter_actor_get_height (priv->image) / 2.0 + PADDING);
- else if (priv->text_actor != NULL)
- clutter_actor_set_anchor_point (CLUTTER_ACTOR (marker),
- 0,
- clutter_actor_get_height (priv->text_actor) / 2.0);
-}
-
-
-static gboolean
-redraw_on_idle (gpointer gobject)
-{
- ChamplainMarker *marker = CHAMPLAIN_MARKER (gobject);
-
- CHAMPLAIN_MARKER_GET_CLASS (gobject)->draw_marker (marker);
- marker->priv->redraw_id = 0;
- return FALSE;
-}
-
-
-/**
- * champlain_marker_queue_redraw:
- * @marker: a #ChamplainMarker
- *
- * Queue a redraw of the marker as soon as possible. This function should not
- * be used unless you are subclassing ChamplainMarker and adding new properties
- * that affect the aspect of the marker. When they change, call this function
- * to update the marker.
- *
- * Since: 0.4.3
- */
-void
-champlain_marker_queue_redraw (ChamplainMarker *marker)
-{
- ChamplainMarkerPrivate *priv = marker->priv;
-
- if (!priv->redraw_id)
- {
- priv->redraw_id =
- g_idle_add_full (G_PRIORITY_DEFAULT,
- (GSourceFunc) redraw_on_idle,
- g_object_ref (marker),
- (GDestroyNotify) g_object_unref);
- }
-}
-
-
-static void
-notify_highlighted (GObject *gobject,
- G_GNUC_UNUSED GParamSpec *pspec,
- G_GNUC_UNUSED gpointer user_data)
-{
- champlain_marker_queue_redraw (CHAMPLAIN_MARKER (gobject));
+ return swallow_event;
}
static void
champlain_marker_init (ChamplainMarker *marker)
{
- ChamplainMarkerPrivate *priv = GET_PRIVATE (marker);
+ ChamplainMarkerPrivate *priv = CHAMPLAIN_MARKER_GET_PRIVATE (marker);
marker->priv = priv;
- priv->text = NULL;
- priv->image = NULL;
- priv->background = NULL;
- priv->use_markup = FALSE;
- priv->alignment = PANGO_ALIGN_LEFT;
- priv->attributes = NULL;
- priv->color = clutter_color_copy (&DEFAULT_COLOR);
- priv->text_color = clutter_color_copy (&DEFAULT_TEXT_COLOR);
- priv->font_name = g_strdup (DEFAULT_FONT_NAME);
- priv->wrap = FALSE;
- priv->wrap_mode = PANGO_WRAP_WORD;
- priv->single_line_mode = TRUE;
- priv->ellipsize = PANGO_ELLIPSIZE_NONE;
- priv->draw_background = TRUE;
- priv->redraw_id = 0;
- priv->shadow = NULL;
- priv->text_actor = NULL;
-
- g_signal_connect (marker, "notify::highlighted", G_CALLBACK (notify_highlighted), NULL);
+ priv->lat = 0;
+ priv->lon = 0;
+ priv->highlighted = FALSE;
+ priv->selectable = TRUE;
+ priv->movable = FALSE;
+
+ clutter_actor_set_reactive (CLUTTER_ACTOR (marker), TRUE);
+
+ g_signal_connect (marker,
+ "button-press-event",
+ G_CALLBACK (button_press_event_cb),
+ marker);
}
@@ -875,684 +393,319 @@ champlain_marker_init (ChamplainMarker *marker)
*
* Returns: a new #ChamplainMarker ready to be used as a #ClutterActor.
*
- * Since: 0.2
- */
-ClutterActor *
-champlain_marker_new (void)
-{
- return CLUTTER_ACTOR (g_object_new (CHAMPLAIN_TYPE_MARKER, NULL));
-}
-
-
-/**
- * champlain_marker_new_with_text:
- * @text: the text of the text
- * @font: (allow-none): the font to use to draw the text, for example "Courrier Bold 11", can be NULL
- * @text_color: (allow-none): a #ClutterColor, the color of the text, can be NULL
- * @marker_color: (allow-none): a #ClutterColor, the color of the marker, can be NULL
- *
- * Creates a new instance of #ChamplainMarker with text value.
- *
- * Returns: a new #ChamplainMarker with a drawn marker containing the given text.
- *
- * Since: 0.2
- */
-ClutterActor *
-champlain_marker_new_with_text (const gchar *text,
- const gchar *font,
- ClutterColor *text_color,
- ClutterColor *marker_color)
-{
- ChamplainMarker *marker = CHAMPLAIN_MARKER (champlain_marker_new ());
-
- champlain_marker_set_text (marker, text);
-
- if (font != NULL)
- champlain_marker_set_font_name (marker, font);
-
- if (text_color != NULL)
- champlain_marker_set_text_color (marker, text_color);
-
- if (marker_color != NULL)
- champlain_marker_set_color (marker, marker_color);
-
- return CLUTTER_ACTOR (marker);
-}
-
-
-/**
- * champlain_marker_new_with_image:
- * @actor: The actor of the image.
- *
- * Creates a new instance of #ChamplainMarker with image.
- *
- * Returns: a new #ChamplainMarker with a drawn marker containing the given
- * image.
- *
- * Since: 0.4
- */
-ClutterActor *
-champlain_marker_new_with_image (ClutterActor *actor)
-{
- ChamplainMarker *marker = CHAMPLAIN_MARKER (champlain_marker_new ());
-
- if (actor != NULL)
- {
- champlain_marker_set_image (marker, actor);
- }
-
- return CLUTTER_ACTOR (marker);
-}
-
-
-/**
- * champlain_marker_new_from_file:
- * @filename: The filename of the image.
- * @error: Return location for an error.
- *
- * Creates a new instance of #ChamplainMarker with image loaded from file.
- *
- * Returns: a new #ChamplainMarker with a drawn marker containing the given
- * image.
- *
- * Since: 0.4
- */
-ClutterActor *
-champlain_marker_new_from_file (const gchar *filename,
- GError **error)
-{
- if (filename == NULL)
- return NULL;
-
- ChamplainMarker *marker = CHAMPLAIN_MARKER (champlain_marker_new ());
- ClutterActor *actor = clutter_texture_new_from_file (filename, error);
-
- if (actor != NULL)
- {
- champlain_marker_set_image (marker, actor);
- }
-
- return CLUTTER_ACTOR (marker);
-}
-
-
-/**
- * champlain_marker_new_full:
- * @text: The text
- * @actor: The image
- *
- * 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_marker_new_full (const gchar *text,
- ClutterActor *actor)
+champlain_marker_new (void)
{
- ChamplainMarker *marker = CHAMPLAIN_MARKER (champlain_marker_new ());
+ ChamplainMarker *marker;
- if (actor != NULL)
- {
- champlain_marker_set_image (marker, actor);
- }
- champlain_marker_set_text (marker, text);
+ marker = CHAMPLAIN_MARKER (g_object_new (CHAMPLAIN_TYPE_MARKER, NULL));
return CLUTTER_ACTOR (marker);
}
/**
- * champlain_marker_set_text:
- * @marker: The marker
- * @text: The text
- *
- * Sets the marker's text.
- *
- * Since: 0.4
- */
-void
-champlain_marker_set_text (ChamplainMarker *marker,
- const gchar *text)
-{
- g_return_if_fail (CHAMPLAIN_IS_MARKER (marker));
-
- ChamplainMarkerPrivate *priv = marker->priv;
-
- if (priv->text != NULL)
- g_free (priv->text);
-
- priv->text = g_strdup (text);
- champlain_marker_queue_redraw (marker);
-}
-
-
-/**
- * champlain_marker_set_image:
- * @marker: The marker.
- * @image: (allow-none): The image as a @ClutterActor or NULL to remove the current image.
+ * champlain_marker_set_position:
+ * @marker: a #ChamplainMarker
+ * @latitude: the longitude to center the map at
+ * @longitude: the longitude to center the map at
*
- * Sets the marker's image.
+ * Positions the marker on the map at the coordinates
*
* Since: 0.4
*/
void
-champlain_marker_set_image (ChamplainMarker *marker,
- ClutterActor *image)
+champlain_marker_set_position (ChamplainMarker *marker,
+ gdouble latitude,
+ gdouble longitude)
{
g_return_if_fail (CHAMPLAIN_IS_MARKER (marker));
ChamplainMarkerPrivate *priv = marker->priv;
- if (priv->image != NULL)
- clutter_actor_destroy (priv->image);
-
- if (image != NULL)
- {
- g_return_if_fail (CLUTTER_IS_ACTOR (image));
- priv->image = g_object_ref (image);
- }
- else
- priv->image = image;
+ priv->lon = longitude;
+ priv->lat = latitude;
- g_object_notify (G_OBJECT (marker), "image");
- champlain_marker_queue_redraw (marker);
+ g_object_notify (G_OBJECT (marker), "latitude");
+ g_object_notify (G_OBJECT (marker), "longitude");
}
/**
- * champlain_marker_set_use_markup:
- * @marker: The marker
- * @use_markup: The value
+ * champlain_marker_get_latitude:
+ * @marker: a #ChamplainMarker
*
- * Sets if the marker's text uses markup.
+ * Gets the latitude of the marker.
*
- * Since: 0.4
- */
-void
-champlain_marker_set_use_markup (ChamplainMarker *marker,
- gboolean markup)
-{
- g_return_if_fail (CHAMPLAIN_IS_MARKER (marker));
-
- marker->priv->use_markup = markup;
- g_object_notify (G_OBJECT (marker), "use-markup");
- champlain_marker_queue_redraw (marker);
-}
-
-
-/**
- * champlain_marker_set_alignment:
- * @marker: The marker
- * @alignment: The marker's alignment
- *
- * Set the marker's text alignment.
+ * Returns: the latitude of the marker.
*
- * Since: 0.4
+ * Since: 0.6
*/
-void
-champlain_marker_set_alignment (ChamplainMarker *marker,
- PangoAlignment alignment)
+gdouble
+champlain_marker_get_latitude (ChamplainMarker *marker)
{
- g_return_if_fail (CHAMPLAIN_IS_MARKER (marker));
+ g_return_val_if_fail (CHAMPLAIN_IS_MARKER (marker), 0.0);
- marker->priv->alignment = alignment;
- g_object_notify (G_OBJECT (marker), "alignment");
- champlain_marker_queue_redraw (marker);
+ return marker->priv->lat;
}
/**
- * champlain_marker_set_color:
- * @marker: The marker
- * @color: (allow-none): The marker's background color or NULL to reset the background to the
- * default color. The color parameter is copied.
- *
- * Set the marker's background color.
+ * champlain_marker_get_longitude:
+ * @marker: a #ChamplainMarker
*
- * Since: 0.4
- */
-void
-champlain_marker_set_color (ChamplainMarker *marker,
- const ClutterColor *color)
-{
- g_return_if_fail (CHAMPLAIN_IS_MARKER (marker));
-
- ChamplainMarkerPrivate *priv = marker->priv;
-
- 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 (marker), "color");
- champlain_marker_queue_redraw (marker);
-}
-
-
-/**
- * champlain_marker_set_text_color:
- * @marker: The marker
- * @color: (allow-none): The marker's text color or NULL to reset the text to the default
- * color. The color parameter is copied.
+ * Gets the longitude of the marker.
*
- * Set the marker's text color.
+ * Returns: the longitude of the marker.
*
- * Since: 0.4
+ * Since: 0.6
*/
-void
-champlain_marker_set_text_color (ChamplainMarker *marker,
- const ClutterColor *color)
+gdouble
+champlain_marker_get_longitude (ChamplainMarker *marker)
{
- g_return_if_fail (CHAMPLAIN_IS_MARKER (marker));
-
- ChamplainMarkerPrivate *priv = marker->priv;
-
- if (priv->text_color != NULL)
- clutter_color_free (priv->text_color);
+ g_return_val_if_fail (CHAMPLAIN_IS_MARKER (marker), 0.0);
- if (color == NULL)
- color = &DEFAULT_TEXT_COLOR;
-
- priv->text_color = clutter_color_copy (color);
- g_object_notify (G_OBJECT (marker), "text-color");
- champlain_marker_queue_redraw (marker);
+ return marker->priv->lon;
}
/**
- * champlain_marker_set_font_name:
- * @marker: The marker
- * @font_name: (allow-none): The marker's font name or NULL to reset the font to the default
- * value.
+ * champlain_marker_set_highlighted:
+ * @marker: a #ChamplainMarker
+ * @value: the highlighted state
*
- * Set the marker's font name such as "Sans 12".
+ * Sets the marker as highlighted or not. This will affect the "Selected" look
+ * of the marker.
*
* Since: 0.4
*/
void
-champlain_marker_set_font_name (ChamplainMarker *marker,
- const gchar *font_name)
+champlain_marker_set_highlighted (ChamplainMarker *marker,
+ gboolean value)
{
g_return_if_fail (CHAMPLAIN_IS_MARKER (marker));
- ChamplainMarkerPrivate *priv = marker->priv;
-
- if (priv->font_name != NULL)
- g_free (priv->font_name);
-
- if (font_name == NULL)
- font_name = DEFAULT_FONT_NAME;
+ marker->priv->highlighted = value;
- priv->font_name = g_strdup (font_name);
- g_object_notify (G_OBJECT (marker), "font-name");
- champlain_marker_queue_redraw (marker);
+ g_object_notify (G_OBJECT (marker), "highlighted");
}
/**
- * champlain_marker_set_wrap:
- * @marker: The marker
- * @wrap: The marker's wrap.
- *
- * Set if the marker's text wrap.
+ * champlain_marker_get_highlighted:
+ * @marker: a #ChamplainMarker
*
- * Since: 0.4
- */
-void
-champlain_marker_set_wrap (ChamplainMarker *marker,
- gboolean wrap)
-{
- g_return_if_fail (CHAMPLAIN_IS_MARKER (marker));
-
- marker->priv->wrap = wrap;
- g_object_notify (G_OBJECT (marker), "wrap");
- champlain_marker_queue_redraw (marker);
-}
-
-
-/**
- * champlain_marker_set_wrap_mode:
- * @marker: The marker
- * @wrap_mode: The marker's wrap.
+ * Checks whether the marker is highlighted.
*
- * Set the marker's text color.
+ * Returns: the highlighted or not state of the marker.
*
* Since: 0.4
*/
-void
-champlain_marker_set_wrap_mode (ChamplainMarker *marker,
- PangoWrapMode wrap_mode)
+gboolean
+champlain_marker_get_highlighted (ChamplainMarker *marker)
{
- g_return_if_fail (CHAMPLAIN_IS_MARKER (marker));
+ g_return_val_if_fail (CHAMPLAIN_IS_MARKER (marker), FALSE);
- marker->priv->wrap_mode = wrap_mode;
- g_object_notify (G_OBJECT (marker), "wrap");
- champlain_marker_queue_redraw (marker);
+ return marker->priv->highlighted;
}
/**
- * champlain_marker_set_attributes:
- * @marker: The marker
- * @list: The marker's text attributes.
+ * champlain_marker_set_selectable:
+ * @marker: a #ChamplainMarker
+ * @value: the selectable state
*
- * Set the marker's text attribute.
+ * Sets the marker as selectable or not.
*
- * Since: 0.4
+ * Since: 0.10
*/
void
-champlain_marker_set_attributes (ChamplainMarker *marker,
- PangoAttrList *attributes)
+champlain_marker_set_selectable (ChamplainMarker *marker,
+ gboolean value)
{
g_return_if_fail (CHAMPLAIN_IS_MARKER (marker));
- ChamplainMarkerPrivate *priv = marker->priv;
-
- if (attributes)
- pango_attr_list_ref (attributes);
+ marker->priv->selectable = value;
- if (priv->attributes)
- pango_attr_list_unref (priv->attributes);
-
- priv->attributes = attributes;
-
- g_object_notify (G_OBJECT (marker), "attributes");
- champlain_marker_queue_redraw (marker);
+ g_object_notify (G_OBJECT (marker), "selectable");
}
/**
- * champlain_marker_set_ellipsize:
- * @marker: The marker
- * @mode: The marker's ellipsize mode.
+ * champlain_marker_get_selectable:
+ * @marker: a #ChamplainMarker
*
- * Set the marker's text ellipsize mode.
+ * Checks whether the marker is selectable.
*
- * Since: 0.4
- */
-void
-champlain_marker_set_ellipsize (ChamplainMarker *marker,
- PangoEllipsizeMode ellipsize)
-{
- g_return_if_fail (CHAMPLAIN_IS_MARKER (marker));
-
- marker->priv->ellipsize = ellipsize;
- g_object_notify (G_OBJECT (marker), "ellipsize");
- champlain_marker_queue_redraw (marker);
-}
-
-
-/**
- * champlain_marker_set_single_line_mode:
- * @marker: The marker
- * @mode: The marker's single line mode
- *
- * Set if the marker's text is on a single line.
+ * Returns: the selectable or not state of the marker.
*
- * Since: 0.4
+ * Since: 0.10
*/
-void
-champlain_marker_set_single_line_mode (ChamplainMarker *marker,
- gboolean mode)
+gboolean
+champlain_marker_get_selectable (ChamplainMarker *marker)
{
- g_return_if_fail (CHAMPLAIN_IS_MARKER (marker));
-
- marker->priv->single_line_mode = mode;
+ g_return_val_if_fail (CHAMPLAIN_IS_MARKER (marker), FALSE);
- g_object_notify (G_OBJECT (marker), "single-line-mode");
- champlain_marker_queue_redraw (marker);
+ return marker->priv->selectable;
}
-
/**
- * champlain_marker_set_draw_background:
- * @marker: The marker
- * @background: value.
+ * champlain_marker_set_movable:
+ * @marker: a #ChamplainMarker
+ * @value: the movable state
*
- * Set if the marker has a background.
+ * Sets the marker as movable or not.
*
- * Since: 0.4
+ * Since: 0.10
*/
void
-champlain_marker_set_draw_background (ChamplainMarker *marker,
- gboolean background)
+champlain_marker_set_movable (ChamplainMarker *marker,
+ gboolean value)
{
g_return_if_fail (CHAMPLAIN_IS_MARKER (marker));
- marker->priv->draw_background = background;
- g_object_notify (G_OBJECT (marker), "draw-background");
- champlain_marker_queue_redraw (marker);
-}
-
+ marker->priv->movable = value;
-/**
- * champlain_marker_get_image:
- * @marker: The marker
- *
- * Get the marker's image.
- *
- * Returns: (transfer none): the marker's image.
- *
- * Since: 0.4
- */
-ClutterActor *
-champlain_marker_get_image (ChamplainMarker *marker)
-{
- g_return_val_if_fail (CHAMPLAIN_IS_MARKER (marker), NULL);
-
- return marker->priv->image;
+ g_object_notify (G_OBJECT (marker), "movable");
}
/**
- * champlain_marker_get_use_markup:
- * @marker: The marker
+ * champlain_marker_get_movable:
+ * @marker: a #ChamplainMarker
*
- * Check whether the marker uses markup.
+ * Checks whether the marker is movable.
*
- * Returns: if the marker's text contains markup.
+ * Returns: the movable or not state of the marker.
*
- * Since: 0.4
+ * Since: 0.10
*/
gboolean
-champlain_marker_get_use_markup (ChamplainMarker *marker)
-{
- g_return_val_if_fail (CHAMPLAIN_IS_MARKER (marker), FALSE);
-
- return marker->priv->use_markup;
-}
-
-
-/**
- * champlain_marker_get_text:
- * @marker: The marker
- *
- * Get the marker's text.
- *
- * Returns: the marker's text.
- *
- * Since: 0.4
- */
-const gchar *
-champlain_marker_get_text (ChamplainMarker *marker)
-{
- g_return_val_if_fail (CHAMPLAIN_IS_MARKER (marker), FALSE);
-
- return marker->priv->text;
-}
-
-
-/**
- * champlain_marker_get_alignment:
- * @marker: The marker
- *
- * Get the marker's text alignment.
- *
- * Returns: the marker's text alignment.
- *
- * Since: 0.4
- */
-PangoAlignment
-champlain_marker_get_alignment (ChamplainMarker *marker)
+champlain_marker_get_movable (ChamplainMarker *marker)
{
g_return_val_if_fail (CHAMPLAIN_IS_MARKER (marker), FALSE);
- return marker->priv->alignment;
+ return marker->priv->movable;
}
-
/**
- * champlain_marker_get_color:
+ * champlain_marker_animate_in:
* @marker: The marker
*
- * Gets the marker's color.
- *
- * Returns: the marker's color.
+ * Animates the marker as if it were falling from the sky onto the map.
*
* Since: 0.4
*/
-ClutterColor *
-champlain_marker_get_color (ChamplainMarker *marker)
+void
+champlain_marker_animate_in (ChamplainMarker *marker)
{
- g_return_val_if_fail (CHAMPLAIN_IS_MARKER (marker), NULL);
-
- return marker->priv->color;
+ champlain_marker_animate_in_with_delay (marker, 0);
}
/**
- * champlain_marker_get_text_color:
+ * champlain_marker_animate_in_with_delay :
* @marker: The marker
+ * @delay: The delay in milliseconds
*
- * Gets the marker's text color.
- *
- * Returns: the marker's text color.
+ * Animates the marker as if it were falling from the sky onto the map after
+ * delay.
*
* Since: 0.4
*/
-ClutterColor *
-champlain_marker_get_text_color (ChamplainMarker *marker)
+void
+champlain_marker_animate_in_with_delay (ChamplainMarker *marker,
+ guint delay)
{
- g_return_val_if_fail (CHAMPLAIN_IS_MARKER (marker), NULL);
+ ClutterTimeline *timeline;
+ gfloat y;
- return marker->priv->text_color;
-}
+ g_return_if_fail (CHAMPLAIN_IS_MARKER (marker));
+ clutter_actor_show (CLUTTER_ACTOR (marker));
+ clutter_actor_set_opacity (CLUTTER_ACTOR (marker), 0);
+ clutter_actor_set_scale (CLUTTER_ACTOR (marker), 1.5, 1.5);
+ clutter_actor_get_position (CLUTTER_ACTOR (marker), NULL, &y);
+ clutter_actor_move_by (CLUTTER_ACTOR (marker), 0, -100);
-/**
- * champlain_marker_get_font_name:
- * @marker: The marker
- *
- * Gets the marker's font name.
- *
- * Returns: the marker's font name.
- *
- * Since: 0.4
- */
-const gchar *
-champlain_marker_get_font_name (ChamplainMarker *marker)
-{
- g_return_val_if_fail (CHAMPLAIN_IS_MARKER (marker), FALSE);
-
- return marker->priv->font_name;
+ timeline = clutter_timeline_new (1000);
+ clutter_timeline_set_delay (timeline, delay);
+ clutter_actor_animate_with_timeline (CLUTTER_ACTOR (marker),
+ CLUTTER_EASE_OUT_BOUNCE, timeline, "opacity", 255, "y", y,
+ "scale-x", 1.0, "scale-y", 1.0, NULL);
}
/**
- * champlain_marker_get_wrap:
+ * champlain_marker_animate_out:
* @marker: The marker
*
- * Check whether the marker text wraps.
- *
- * Returns: if the marker's text wraps.
+ * Animates the marker as if it were drawn through the sky.
*
* Since: 0.4
*/
-gboolean
-champlain_marker_get_wrap (ChamplainMarker *marker)
+void
+champlain_marker_animate_out (ChamplainMarker *marker)
{
- g_return_val_if_fail (CHAMPLAIN_IS_MARKER (marker), FALSE);
-
- return marker->priv->wrap;
+ champlain_marker_animate_out_with_delay (marker, 0);
}
-/**
- * champlain_marker_get_wrap_mode:
- * @marker: The marker
- *
- * Get the marker's text wrap mode.
- *
- * Returns: the marker's text wrap mode.
- *
- * Since: 0.4
- */
-PangoWrapMode
-champlain_marker_get_wrap_mode (ChamplainMarker *marker)
+static gboolean
+on_idle (ChamplainMarker *marker)
{
- g_return_val_if_fail (CHAMPLAIN_IS_MARKER (marker), FALSE);
+ /* Notify the view that the position changed so that the marker's
+ * position is reset, it has to happen on idle as Clutter seems to
+ * set actors position after calling animation_completed */
+ clutter_actor_hide (CLUTTER_ACTOR (marker));
- return marker->priv->wrap_mode;
+ g_object_notify (G_OBJECT (marker), "latitude");
+ g_object_notify (G_OBJECT (marker), "longitude");
+ return FALSE;
}
-/**
- * champlain_marker_get_ellipsize:
- * @marker: The marker
- *
- * Get the marker's text ellipsize mode.
- *
- * Returns: the marker's text ellipsize mode.
- *
- * Since: 0.4
- */
-PangoEllipsizeMode
-champlain_marker_get_ellipsize (ChamplainMarker *marker)
+static void
+on_animation_completed (G_GNUC_UNUSED ClutterAnimation *animation,
+ ChamplainMarker *marker)
{
- g_return_val_if_fail (CHAMPLAIN_IS_MARKER (marker), FALSE);
-
- return marker->priv->ellipsize;
+ g_idle_add_full (G_PRIORITY_DEFAULT,
+ (GSourceFunc) on_idle,
+ g_object_ref (marker),
+ (GDestroyNotify) g_object_unref);
}
/**
- * champlain_marker_get_single_line_mode:
+ * champlain_marker_animate_out_with_delay :
* @marker: The marker
+ * @delay: The delay in milliseconds
*
- * Checks the marker's single line mode.
- *
- * Returns: the marker's text single line mode.
+ * Animates the marker as if it were drawn through the sky after
+ * delay.
*
* Since: 0.4
*/
-gboolean
-champlain_marker_get_single_line_mode (ChamplainMarker *marker)
+void
+champlain_marker_animate_out_with_delay (ChamplainMarker *marker,
+ guint delay)
{
- g_return_val_if_fail (CHAMPLAIN_IS_MARKER (marker), FALSE);
-
- return marker->priv->single_line_mode;
-}
+ ClutterAnimation *animation;
+ ClutterTimeline *timeline;
+ gfloat y;
+ g_return_if_fail (CHAMPLAIN_IS_MARKER (marker));
-/**
- * champlain_marker_get_draw_background:
- * @marker: The marker
- *
- * Checks whether the marker has a background.
- *
- * Returns: if the marker's has a background.
- *
- * Since: 0.4
- */
-gboolean
-champlain_marker_get_draw_background (ChamplainMarker *marker)
-{
- g_return_val_if_fail (CHAMPLAIN_IS_MARKER (marker), FALSE);
+ clutter_actor_get_position (CLUTTER_ACTOR (marker), NULL, &y);
+ clutter_actor_set_opacity (CLUTTER_ACTOR (marker), 200);
- return marker->priv->draw_background;
+ timeline = clutter_timeline_new (750);
+ clutter_timeline_set_delay (timeline, delay);
+ animation = clutter_actor_animate_with_timeline (CLUTTER_ACTOR (marker),
+ CLUTTER_EASE_IN_BACK, timeline, "opacity", 0, "y", y - 100,
+ "scale-x", 2.0, "scale-y", 2.0, NULL);
+ g_signal_connect (animation, "completed",
+ G_CALLBACK (on_animation_completed), marker);
}
diff --git a/champlain/champlain-marker.h b/champlain/champlain-marker.h
index 6aa5d00..2590d3a 100644
--- a/champlain/champlain-marker.h
+++ b/champlain/champlain-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
@@ -23,7 +24,7 @@
#ifndef CHAMPLAIN_MARKER_H
#define CHAMPLAIN_MARKER_H
-#include <champlain/champlain-base-marker.h>
+#include <champlain/champlain-defines.h>
#include <glib-object.h>
#include <clutter/clutter.h>
@@ -52,84 +53,47 @@ typedef struct _ChamplainMarkerPrivate ChamplainMarkerPrivate;
typedef struct _ChamplainMarker ChamplainMarker;
typedef struct _ChamplainMarkerClass ChamplainMarkerClass;
+
struct _ChamplainMarker
{
- ChamplainBaseMarker base;
+ ClutterGroup group;
ChamplainMarkerPrivate *priv;
};
struct _ChamplainMarkerClass
{
- ChamplainBaseMarkerClass parent_class;
-
- void (*draw_marker)(ChamplainMarker *marker);
+ ClutterGroupClass parent_class;
};
GType champlain_marker_get_type (void);
ClutterActor *champlain_marker_new (void);
-ClutterActor *champlain_marker_new_with_text (const gchar *text,
- const gchar *font,
- ClutterColor *text_color,
- ClutterColor *marker_color);
-
-ClutterActor *champlain_marker_new_with_image (ClutterActor *actor);
-
-ClutterActor *champlain_marker_new_from_file (const gchar *filename,
- GError **error);
-
-ClutterActor *champlain_marker_new_full (const gchar *text,
- ClutterActor *actor);
-
-void champlain_marker_set_text (ChamplainMarker *marker,
- const gchar *text);
-void champlain_marker_set_image (ChamplainMarker *marker,
- ClutterActor *image);
-void champlain_marker_set_use_markup (ChamplainMarker *marker,
- gboolean use_markup);
-void champlain_marker_set_alignment (ChamplainMarker *marker,
- PangoAlignment alignment);
-void champlain_marker_set_color (ChamplainMarker *marker,
- const ClutterColor *color);
-void champlain_marker_set_text_color (ChamplainMarker *marker,
- const ClutterColor *color);
-void champlain_marker_set_font_name (ChamplainMarker *marker,
- const gchar *font_name);
-void champlain_marker_set_wrap (ChamplainMarker *marker,
- gboolean wrap);
-void champlain_marker_set_wrap_mode (ChamplainMarker *marker,
- PangoWrapMode wrap_mode);
-void champlain_marker_set_attributes (ChamplainMarker *marker,
- PangoAttrList *list);
-void champlain_marker_set_single_line_mode (ChamplainMarker *marker,
- gboolean mode);
-void champlain_marker_set_ellipsize (ChamplainMarker *marker,
- PangoEllipsizeMode mode);
-void champlain_marker_set_draw_background (ChamplainMarker *marker,
- gboolean background);
-
-gboolean champlain_marker_get_use_markup (ChamplainMarker *marker);
-const gchar *champlain_marker_get_text (ChamplainMarker *marker);
-ClutterActor *champlain_marker_get_image (ChamplainMarker *marker);
-PangoAlignment champlain_marker_get_alignment (ChamplainMarker *marker);
-ClutterColor *champlain_marker_get_color (ChamplainMarker *marker);
-ClutterColor *champlain_marker_get_text_color (ChamplainMarker *marker);
-const gchar *champlain_marker_get_font_name (ChamplainMarker *marker);
-gboolean champlain_marker_get_wrap (ChamplainMarker *marker);
-PangoWrapMode champlain_marker_get_wrap_mode (ChamplainMarker *marker);
-PangoEllipsizeMode champlain_marker_get_ellipsize (ChamplainMarker *marker);
-gboolean champlain_marker_get_single_line_mode (ChamplainMarker *marker);
-gboolean champlain_marker_get_draw_background (ChamplainMarker *marker);
-
-void champlain_marker_set_highlight_color (ClutterColor *color);
-const ClutterColor *champlain_marker_get_highlight_color (void);
-
-void champlain_marker_set_highlight_text_color (ClutterColor *color);
-const ClutterColor *champlain_marker_get_highlight_text_color (void);
-
-void champlain_marker_queue_redraw (ChamplainMarker *marker);
+void champlain_marker_set_position (ChamplainMarker *marker,
+ gdouble latitude,
+ gdouble longitude);
+gdouble champlain_marker_get_latitude (ChamplainMarker *marker);
+gdouble champlain_marker_get_longitude (ChamplainMarker *marker);
+
+void champlain_marker_set_selectable (ChamplainMarker *marker,
+ gboolean value);
+gboolean champlain_marker_get_selectable (ChamplainMarker *marker);
+
+void champlain_marker_set_movable (ChamplainMarker *marker,
+ gboolean value);
+gboolean champlain_marker_get_movable (ChamplainMarker *marker);
+
+void champlain_marker_set_highlighted (ChamplainMarker *marker,
+ gboolean value);
+gboolean champlain_marker_get_highlighted (ChamplainMarker *marker);
+
+void champlain_marker_animate_in (ChamplainMarker *marker);
+void champlain_marker_animate_in_with_delay (ChamplainMarker *marker,
+ guint delay);
+void champlain_marker_animate_out (ChamplainMarker *marker);
+void champlain_marker_animate_out_with_delay (ChamplainMarker *marker,
+ guint delay);
G_END_DECLS
diff --git a/champlain/champlain-point.c b/champlain/champlain-point.c
index 8f6aad7..e107fc3 100644
--- a/champlain/champlain-point.c
+++ b/champlain/champlain-point.c
@@ -1,5 +1,5 @@
/*
- * 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
@@ -16,28 +16,10 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-/**
- * 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"
@@ -69,7 +51,7 @@ enum
PROP_SIZE,
};
-/* static guint champlain_marker_signals[LAST_SIGNAL] = { 0, }; */
+/* static guint champlain_point_signals[LAST_SIGNAL] = { 0, }; */
struct _ChamplainPointPrivate
{
@@ -79,15 +61,15 @@ struct _ChamplainPointPrivate
guint redraw_id;
};
-G_DEFINE_TYPE (ChamplainPoint, champlain_point, CHAMPLAIN_TYPE_BASE_MARKER);
+G_DEFINE_TYPE (ChamplainPoint, champlain_point, CHAMPLAIN_TYPE_MARKER);
#define GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), CHAMPLAIN_TYPE_POINT, ChamplainPointPrivate))
-static void draw_marker (ChamplainPoint *marker);
+static void draw_point (ChamplainPoint *point);
/**
- * champlain_marker_set_highlight_color:
+ * champlain_point_set_highlight_color:
* @color: a #ClutterColor
*
* Changes the highlight color, this is to ensure a better integration with
@@ -106,7 +88,7 @@ champlain_point_set_highlight_color (ClutterColor *color)
/**
- * champlain_marker_get_highlight_color:
+ * champlain_point_get_highlight_color:
*
* Gets the highlight color.
*
@@ -152,16 +134,16 @@ champlain_point_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec)
{
- ChamplainPoint *marker = CHAMPLAIN_POINT (object);
+ ChamplainPoint *point = CHAMPLAIN_POINT (object);
switch (prop_id)
{
case PROP_COLOR:
- champlain_point_set_color (marker, clutter_value_get_color (value));
+ champlain_point_set_color (point, clutter_value_get_color (value));
break;
case PROP_SIZE:
- champlain_point_set_size (marker, g_value_get_double (value));
+ champlain_point_set_size (point, g_value_get_double (value));
break;
default:
@@ -195,30 +177,20 @@ champlain_point_finalize (GObject *object)
static void
-champlain_point_class_init (ChamplainPointClass *markerClass)
+champlain_point_class_init (ChamplainPointClass *pointClass)
{
- g_type_class_add_private (markerClass, sizeof (ChamplainPointPrivate));
+ g_type_class_add_private (pointClass, sizeof (ChamplainPointPrivate));
- GObjectClass *object_class = G_OBJECT_CLASS (markerClass);
+ GObjectClass *object_class = G_OBJECT_CLASS (pointClass);
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",
+ clutter_param_spec_color ("color", "Color", "The point'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));
@@ -226,23 +198,23 @@ champlain_point_class_init (ChamplainPointClass *markerClass)
static void
-draw_marker (ChamplainPoint *marker)
+draw_point (ChamplainPoint *point)
{
- ChamplainPointPrivate *priv = marker->priv;
+ ChamplainPointPrivate *priv = point->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));
+ clutter_group_remove_all (CLUTTER_GROUP (point));
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);
+ clutter_container_add_actor (CLUTTER_CONTAINER (point), cairo_texture);
+ clutter_actor_set_anchor_point (CLUTTER_ACTOR (point), radius, radius);
cr = clutter_cairo_texture_create (CLUTTER_CAIRO_TEXTURE (cairo_texture));
- if (champlain_base_marker_get_highlighted (CHAMPLAIN_BASE_MARKER (marker)))
+ if (champlain_marker_get_highlighted (CHAMPLAIN_MARKER (point)))
color = &SELECTED_COLOR;
else
color = priv->color;
@@ -270,36 +242,26 @@ notify_highlighted (GObject *gobject,
G_GNUC_UNUSED GParamSpec *pspec,
G_GNUC_UNUSED gpointer user_data)
{
- draw_marker (CHAMPLAIN_POINT (gobject));
+ draw_point (CHAMPLAIN_POINT (gobject));
}
-
static void
-champlain_point_init (ChamplainPoint *marker)
+champlain_point_init (ChamplainPoint *point)
{
- ChamplainPointPrivate *priv = GET_PRIVATE (marker);
+ ChamplainPointPrivate *priv = GET_PRIVATE (point);
- marker->priv = priv;
+ point->priv = priv;
priv->color = clutter_color_copy (&DEFAULT_COLOR);
priv->size = 12;
- draw_marker (marker);
+ draw_point (point);
- g_signal_connect (marker, "notify::highlighted", G_CALLBACK (notify_highlighted), NULL);
+ g_signal_connect (point, "notify::highlighted", G_CALLBACK (notify_highlighted), NULL);
}
-/**
- * champlain_marker_new:
- *
- * Creates a new instance of #ChamplainMarker.
- *
- * Returns: a new #ChamplainMarker ready to be used as a #ClutterActor.
- *
- * Since: 0.2
- */
ClutterActor *
champlain_point_new (void)
{
@@ -307,35 +269,19 @@ champlain_point_new (void)
}
-
-
-/**
- * champlain_marker_new_full:
- * @text: The text
- * @actor: The image
- *
- * 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 ());
+ ChamplainPoint *point = CHAMPLAIN_POINT (champlain_point_new ());
- champlain_point_set_size (marker, size);
- champlain_point_set_color (marker, color);
+ champlain_point_set_size (point, size);
+ champlain_point_set_color (point, color);
- return CLUTTER_ACTOR (marker);
+ return CLUTTER_ACTOR (point);
}
-/**
- */
void
champlain_point_set_size (ChamplainPoint *point,
gdouble size)
@@ -344,12 +290,10 @@ champlain_point_set_size (ChamplainPoint *point,
point->priv->size = size;
g_object_notify (G_OBJECT (point), "size");
- draw_marker (point);
+ draw_point (point);
}
-/**
- */
gdouble
champlain_point_get_size (ChamplainPoint *point)
{
@@ -359,16 +303,6 @@ champlain_point_get_size (ChamplainPoint *point)
}
-/**
- * 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.
- *
- * Set the point's background color.
- *
- * Since: 0.4
- */
void
champlain_point_set_color (ChamplainPoint *point,
const ClutterColor *color)
@@ -385,19 +319,10 @@ champlain_point_set_color (ChamplainPoint *point,
priv->color = clutter_color_copy (color);
g_object_notify (G_OBJECT (point), "color");
- draw_marker (point);
+ draw_point (point);
}
-/**
- * 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)
{
diff --git a/champlain/champlain-point.h b/champlain/champlain-point.h
index 24486af..a545f17 100644
--- a/champlain/champlain-point.h
+++ b/champlain/champlain-point.h
@@ -1,5 +1,5 @@
/*
- * 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
@@ -23,7 +23,7 @@
#ifndef CHAMPLAIN_POINT_H
#define CHAMPLAIN_POINT_H
-#include <champlain/champlain-base-marker.h>
+#include <champlain/champlain-marker.h>
#include <glib-object.h>
#include <clutter/clutter.h>
@@ -54,14 +54,14 @@ typedef struct _ChamplainPointClass ChamplainPointClass;
struct _ChamplainPoint
{
- ChamplainBaseMarker base;
+ ChamplainMarker parent;
ChamplainPointPrivate *priv;
};
struct _ChamplainPointClass
{
- ChamplainBaseMarkerClass parent_class;
+ ChamplainMarkerClass parent_class;
};
GType champlain_point_get_type (void);
@@ -71,10 +71,10 @@ ClutterActor *champlain_point_new (void);
ClutterActor *champlain_point_new_full (gdouble size,
const ClutterColor *color);
-void champlain_point_set_color (ChamplainPoint *marker,
+void champlain_point_set_color (ChamplainPoint *point,
const ClutterColor *color);
-ClutterColor *champlain_point_get_color (ChamplainPoint *marker);
+ClutterColor *champlain_point_get_color (ChamplainPoint *point);
void champlain_point_set_highlight_color (ClutterColor *color);
const ClutterColor *champlain_point_get_highlight_color (void);
diff --git a/champlain/champlain-view.h b/champlain/champlain-view.h
index 9baf324..b7affdb 100644
--- a/champlain/champlain-view.h
+++ b/champlain/champlain-view.h
@@ -25,7 +25,6 @@
#define CHAMPLAIN_VIEW_H
#include <champlain/champlain-defines.h>
-#include <champlain/champlain-base-marker.h>
#include <champlain/champlain-layer.h>
#include <champlain/champlain-map-source.h>
diff --git a/champlain/champlain.h b/champlain/champlain.h
index 4acc6f0..9525889 100644
--- a/champlain/champlain.h
+++ b/champlain/champlain.h
@@ -31,8 +31,8 @@
#include "champlain/champlain-layer.h"
#include "champlain/champlain-point.h"
-#include "champlain/champlain-base-marker.h"
#include "champlain/champlain-marker.h"
+#include "champlain/champlain-label.h"
#include "champlain/champlain-view.h"
#include "champlain/champlain-bounding-box.h"
diff --git a/demos/animated-marker.c b/demos/animated-marker.c
index a592bb0..7b71fc5 100644
--- a/demos/animated-marker.c
+++ b/demos/animated-marker.c
@@ -35,7 +35,7 @@ create_marker ()
cairo_t *cr;
/* Create the marker */
- marker = champlain_base_marker_new ();
+ marker = champlain_marker_new ();
/* Static filled circle ----------------------------------------------- */
bg = clutter_cairo_texture_new (MARKER_SIZE, MARKER_SIZE);
@@ -102,7 +102,7 @@ double lon = -73.75;
typedef struct
{
ChamplainView *view;
- ChamplainBaseMarker *marker;
+ ChamplainMarker *marker;
} GpsCallbackData;
static gboolean
@@ -111,7 +111,7 @@ gps_callback (GpsCallbackData *data)
lat += 0.005;
lon += 0.005;
champlain_view_center_on (data->view, lat, lon);
- champlain_base_marker_set_position (data->marker, lat, lon);
+ champlain_marker_set_position (data->marker, lat, lon);
return TRUE;
}
@@ -150,7 +150,7 @@ main (int argc, char *argv[])
/* Create callback that updates the map periodically */
callback_data.view = CHAMPLAIN_VIEW (actor);
- callback_data.marker = CHAMPLAIN_BASE_MARKER (marker);
+ callback_data.marker = CHAMPLAIN_MARKER (marker);
g_timeout_add (1000, (GSourceFunc) gps_callback, &callback_data);
diff --git a/demos/launcher-gtk.c b/demos/launcher-gtk.c
index 9d55b93..e19b1bb 100644
--- a/demos/launcher-gtk.c
+++ b/demos/launcher-gtk.c
@@ -207,8 +207,8 @@ append_point (ChamplainLayer *layer, gdouble lon, gdouble lat)
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));
+ champlain_marker_set_position (CHAMPLAIN_MARKER (point), lon, lat);
+ champlain_layer_add_marker (layer, CHAMPLAIN_MARKER (point));
}
diff --git a/demos/markers.c b/demos/markers.c
index 9fd8908..01851e5 100644
--- a/demos/markers.c
+++ b/demos/markers.c
@@ -51,15 +51,15 @@ create_marker_layer (G_GNUC_UNUSED ChamplainView *view)
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>",
+ marker = champlain_label_new_with_text ("Montréal\n<span size=\"xx-small\">Québec</span>",
"Serif 14", NULL, NULL);
- champlain_marker_set_use_markup (CHAMPLAIN_MARKER (marker), TRUE);
- champlain_marker_set_alignment (CHAMPLAIN_MARKER (marker), PANGO_ALIGN_RIGHT);
- champlain_marker_set_color (CHAMPLAIN_MARKER (marker), &orange);
+ champlain_label_set_use_markup (CHAMPLAIN_LABEL (marker), TRUE);
+ champlain_label_set_alignment (CHAMPLAIN_LABEL (marker), PANGO_ALIGN_RIGHT);
+ champlain_label_set_color (CHAMPLAIN_LABEL (marker), &orange);
- champlain_base_marker_set_position (CHAMPLAIN_BASE_MARKER (marker),
+ champlain_marker_set_position (CHAMPLAIN_MARKER (marker),
45.528178, -73.563788);
- champlain_layer_add_marker (layer, CHAMPLAIN_BASE_MARKER (marker));
+ champlain_layer_add_marker (layer, CHAMPLAIN_MARKER (marker));
/*
* This event handler will never be called anyway because this demo is using
* a ChamplainSelectionLayer but we leave it here in the demo so that you know
@@ -70,27 +70,26 @@ create_marker_layer (G_GNUC_UNUSED ChamplainView *view)
G_CALLBACK (marker_button_release_cb), 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_label_new_from_file ("/usr/share/icons/gnome/24x24/emblems/emblem-generic.png", NULL);
+ champlain_label_set_text (CHAMPLAIN_LABEL (marker), "New York");
+ champlain_marker_set_position (CHAMPLAIN_MARKER (marker), 40.77, -73.98);
+ champlain_layer_add_marker (layer, CHAMPLAIN_MARKER (marker));
- marker = champlain_marker_new_from_file ("/usr/share/icons/gnome/24x24/emblems/emblem-important.png", NULL);
- champlain_base_marker_set_position (CHAMPLAIN_BASE_MARKER (marker), 47.130885,
+ marker = champlain_label_new_from_file ("/usr/share/icons/gnome/24x24/emblems/emblem-important.png", NULL);
+ champlain_marker_set_position (CHAMPLAIN_MARKER (marker), 47.130885,
-70.764141);
- champlain_layer_add_marker (layer, CHAMPLAIN_BASE_MARKER (marker));
+ champlain_layer_add_marker (layer, CHAMPLAIN_MARKER (marker));
marker = champlain_point_new ();
- champlain_base_marker_set_position (CHAMPLAIN_BASE_MARKER (marker), 45.130885,
+ champlain_marker_set_position (CHAMPLAIN_MARKER (marker), 45.130885,
-65.764141);
- champlain_layer_add_marker (layer, CHAMPLAIN_BASE_MARKER (marker));
+ champlain_layer_add_marker (layer, CHAMPLAIN_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,
+ marker = champlain_label_new_from_file ("/usr/share/icons/gnome/24x24/emblems/emblem-favorite.png", NULL);
+ champlain_label_set_draw_background (CHAMPLAIN_LABEL (marker), FALSE);
+ champlain_marker_set_position (CHAMPLAIN_MARKER (marker), 45.41484,
-71.918907);
- champlain_layer_add_marker (layer, CHAMPLAIN_BASE_MARKER (marker));
+ champlain_layer_add_marker (layer, CHAMPLAIN_MARKER (marker));
champlain_layer_set_all_markers_movable (layer);
diff --git a/demos/polygons.c b/demos/polygons.c
index 8923e93..11b9382 100644
--- a/demos/polygons.c
+++ b/demos/polygons.c
@@ -73,8 +73,8 @@ append_point (ChamplainLayer *layer, gdouble lon, gdouble lat)
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));
+ champlain_marker_set_position (CHAMPLAIN_MARKER (point), lon, lat);
+ champlain_layer_add_marker (layer, CHAMPLAIN_MARKER (point));
}
diff --git a/demos/url-marker.c b/demos/url-marker.c
index 3440b10..e4b8227 100644
--- a/demos/url-marker.c
+++ b/demos/url-marker.c
@@ -188,9 +188,9 @@ image_downloaded_cb (SoupSession *session,
}
/* Finally create a marker with the texture */
- marker = champlain_marker_new_with_image (texture);
+ marker = champlain_label_new_with_image (texture);
texture = NULL;
- champlain_base_marker_set_position (CHAMPLAIN_BASE_MARKER (marker),
+ champlain_marker_set_position (CHAMPLAIN_MARKER (marker),
marker_data->latitude, marker_data->longitude);
clutter_container_add (CLUTTER_CONTAINER (marker_data->layer), marker, NULL);
clutter_actor_show_all (marker);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]