[libchamplain] Update most of libchamplain to Clutter API 1.12
- From: Jiří Techet <jiritechet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libchamplain] Update most of libchamplain to Clutter API 1.12
- Date: Fri, 12 Apr 2013 12:07:09 +0000 (UTC)
commit 392efa1037dd0d2f21d9bcbfd7f78a5a5268a1df
Author: Jiří Techet <techet gmail com>
Date: Thu Apr 11 14:08:20 2013 +0200
Update most of libchamplain to Clutter API 1.12
champlain-gtk/gtk-champlain-embed.c | 6 +-
champlain/Makefile.am | 3 -
champlain/champlain-0.12.vapi | 37 ++-
champlain/champlain-adjustment.c | 14 +-
champlain/champlain-custom-marker.c | 145 +--------
champlain/champlain-error-tile-renderer.c | 93 +++---
champlain/champlain-group.c | 507 -----------------------------
champlain/champlain-group.h | 108 ------
champlain/champlain-image-renderer.c | 32 ++-
champlain/champlain-kinetic-scroll-view.c | 231 +-------------
champlain/champlain-kinetic-scroll-view.h | 5 +-
champlain/champlain-label.c | 298 +++++++-----------
champlain/champlain-license.c | 113 +-------
champlain/champlain-marker-layer.c | 162 +---------
champlain/champlain-marker.c | 85 +++--
champlain/champlain-marker.h | 2 +
champlain/champlain-memphis-renderer.c | 30 ++-
champlain/champlain-path-layer.c | 218 +++----------
champlain/champlain-scale.c | 204 +++----------
champlain/champlain-tile.c | 155 +--------
champlain/champlain-view.c | 321 ++++++++-----------
champlain/champlain-viewport.c | 220 +------------
demos/Makefile.am | 2 +-
docs/reference/Makefile.am | 1 -
24 files changed, 577 insertions(+), 2415 deletions(-)
---
diff --git a/champlain-gtk/gtk-champlain-embed.c b/champlain-gtk/gtk-champlain-embed.c
index a1efe72..12ca17b 100644
--- a/champlain-gtk/gtk-champlain-embed.c
+++ b/champlain-gtk/gtk-champlain-embed.c
@@ -205,12 +205,12 @@ set_view (GtkChamplainEmbed *embed,
stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (priv->clutter_embed));
if (priv->view != NULL)
- clutter_container_remove_actor (CLUTTER_CONTAINER (stage), CLUTTER_ACTOR (priv->view));
+ clutter_actor_remove_child (stage, CLUTTER_ACTOR (priv->view));
priv->view = view;
clutter_actor_set_size (CLUTTER_ACTOR (priv->view), priv->width, priv->height);
- clutter_container_add_actor (CLUTTER_CONTAINER (stage), CLUTTER_ACTOR (priv->view));
+ clutter_actor_add_child (stage, CLUTTER_ACTOR (priv->view));
}
@@ -251,7 +251,7 @@ gtk_champlain_embed_init (GtkChamplainEmbed *embed)
/* Setup stage */
stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (priv->clutter_embed));
- clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);
+ clutter_actor_set_background_color (stage, &stage_color);
gtk_container_add (GTK_CONTAINER (embed), priv->clutter_embed);
}
diff --git a/champlain/Makefile.am b/champlain/Makefile.am
index 62f114c..7817db5 100644
--- a/champlain/Makefile.am
+++ b/champlain/Makefile.am
@@ -49,7 +49,6 @@ libchamplain_headers_public = \
libchamplain_headers_private = \
$(srcdir)/champlain-debug.h \
- $(srcdir)/champlain-group.h \
$(srcdir)/champlain-private.h
@@ -89,7 +88,6 @@ libchamplain_sources = \
$(srcdir)/champlain-file-tile-source.c \
$(srcdir)/champlain-null-tile-source.c \
$(srcdir)/champlain-network-bbox-tile-source.c \
- $(srcdir)/champlain-group.c \
$(srcdir)/champlain-adjustment.c \
$(srcdir)/champlain-kinetic-scroll-view.c \
$(srcdir)/champlain-viewport.c \
@@ -145,7 +143,6 @@ AM_CPPFLAGS = \
-DDATADIR=\""$(datadir)"\" \
-I$(top_srcdir) \
-DCHAMPLAIN_COMPILATION \
- -DCLUTTER_DISABLE_DEPRECATION_WARNINGS \
$(WARN_CFLAGS)
diff --git a/champlain/champlain-0.12.vapi b/champlain/champlain-0.12.vapi
index 7d9bcdf..ad1143d 100644
--- a/champlain/champlain-0.12.vapi
+++ b/champlain/champlain-0.12.vapi
@@ -106,7 +106,7 @@ namespace Champlain {
public signal void panning_completed ();
}
[CCode (cheader_filename = "champlain/champlain.h", type_id = "champlain_label_get_type ()")]
- public class Label : Champlain.Marker, Atk.Implementor, Champlain.Location, Clutter.Animatable,
Clutter.Scriptable {
+ public class Label : Champlain.Marker, Atk.Implementor, Champlain.Location, Clutter.Animatable,
Clutter.Container, Clutter.Scriptable {
[CCode (has_construct_function = false, type = "ClutterActor*")]
public Label ();
[CCode (has_construct_function = false, type = "ClutterActor*")]
@@ -157,14 +157,14 @@ namespace Champlain {
public Pango.WrapMode wrap_mode { get; set; }
}
[CCode (cheader_filename = "champlain/champlain.h", type_id = "champlain_layer_get_type ()")]
- public abstract class Layer : Clutter.Actor, Atk.Implementor, Clutter.Animatable, Clutter.Scriptable {
+ public abstract class Layer : Clutter.Actor, Atk.Implementor, Clutter.Animatable, Clutter.Container,
Clutter.Scriptable {
[CCode (has_construct_function = false)]
protected Layer ();
public virtual Champlain.BoundingBox get_bounding_box ();
public virtual void set_view (Champlain.View view);
}
[CCode (cheader_filename = "champlain/champlain.h", type_id = "champlain_license_get_type ()")]
- public class License : Clutter.Actor, Atk.Implementor, Clutter.Animatable, Clutter.Scriptable {
+ public class License : Clutter.Actor, Atk.Implementor, Clutter.Animatable, Clutter.Container,
Clutter.Scriptable {
[CCode (has_construct_function = false, type = "ClutterActor*")]
public License ();
public void connect_view (Champlain.View view);
@@ -248,7 +248,7 @@ namespace Champlain {
public bool register (Champlain.MapSourceDesc desc);
}
[CCode (cheader_filename = "champlain/champlain.h", type_id = "champlain_marker_get_type ()")]
- public abstract class Marker : Clutter.Actor, Atk.Implementor, Champlain.Location,
Clutter.Animatable, Clutter.Scriptable {
+ public abstract class Marker : Clutter.Actor, Atk.Implementor, Champlain.Location,
Clutter.Animatable, Clutter.Container, Clutter.Scriptable {
[CCode (has_construct_function = false)]
protected Marker ();
public void animate_in ();
@@ -268,13 +268,13 @@ namespace Champlain {
public bool draggable { get; set; }
public bool selectable { get; set; }
public bool selected { get; set; }
- public signal void button_press (Clutter.Event since);
- public signal void button_release (Clutter.Event since);
- public signal void drag_finish (Clutter.Event since);
- public signal void drag_motion (double dy, double event, Clutter.Event since);
+ public signal void button_press (Clutter.Event object);
+ public signal void button_release (Clutter.Event object);
+ public signal void drag_finish (Clutter.Event object);
+ public signal void drag_motion (double object, double p0, Clutter.Event p1);
}
[CCode (cheader_filename = "champlain/champlain.h", type_id = "champlain_marker_layer_get_type ()")]
- public class MarkerLayer : Champlain.Layer, Atk.Implementor, Clutter.Animatable, Clutter.Scriptable {
+ public class MarkerLayer : Champlain.Layer, Atk.Implementor, Clutter.Animatable, Clutter.Container,
Clutter.Scriptable {
[CCode (has_construct_function = false)]
public MarkerLayer ();
public void add_marker (Champlain.Marker marker);
@@ -362,7 +362,7 @@ namespace Champlain {
public NullTileSource.full (Champlain.Renderer renderer);
}
[CCode (cheader_filename = "champlain/champlain.h", type_id = "champlain_path_layer_get_type ()")]
- public class PathLayer : Champlain.Layer, Atk.Implementor, Clutter.Animatable, Clutter.Scriptable {
+ public class PathLayer : Champlain.Layer, Atk.Implementor, Clutter.Animatable, Clutter.Container,
Clutter.Scriptable {
[CCode (has_construct_function = false)]
public PathLayer ();
public void add_node (Champlain.Location location);
@@ -395,7 +395,7 @@ namespace Champlain {
public bool visible { get; set; }
}
[CCode (cheader_filename = "champlain/champlain.h", type_id = "champlain_point_get_type ()")]
- public class Point : Champlain.Marker, Atk.Implementor, Champlain.Location, Clutter.Animatable,
Clutter.Scriptable {
+ public class Point : Champlain.Marker, Atk.Implementor, Champlain.Location, Clutter.Animatable,
Clutter.Container, Clutter.Scriptable {
[CCode (has_construct_function = false, type = "ClutterActor*")]
public Point ();
[CCode (has_construct_function = false, type = "ClutterActor*")]
@@ -415,7 +415,7 @@ namespace Champlain {
public virtual void set_data (string data, uint size);
}
[CCode (cheader_filename = "champlain/champlain.h", type_id = "champlain_scale_get_type ()")]
- public class Scale : Clutter.Actor, Atk.Implementor, Clutter.Animatable, Clutter.Scriptable {
+ public class Scale : Clutter.Actor, Atk.Implementor, Clutter.Animatable, Clutter.Container,
Clutter.Scriptable {
[CCode (has_construct_function = false, type = "ClutterActor*")]
public Scale ();
public void connect_view (Champlain.View view);
@@ -427,7 +427,7 @@ namespace Champlain {
public uint max_width { get; set; }
}
[CCode (cheader_filename = "champlain/champlain.h", type_id = "champlain_tile_get_type ()")]
- public class Tile : Clutter.Actor, Atk.Implementor, Clutter.Animatable, Clutter.Scriptable {
+ public class Tile : Clutter.Actor, Atk.Implementor, Clutter.Animatable, Clutter.Container,
Clutter.Scriptable {
[CCode (has_construct_function = false)]
public Tile ();
public void display_content ();
@@ -499,7 +499,7 @@ namespace Champlain {
public uint tile_size { get; set construct; }
}
[CCode (cheader_filename = "champlain/champlain.h", type_id = "champlain_view_get_type ()")]
- public class View : Clutter.Actor, Atk.Implementor, Clutter.Animatable, Clutter.Scriptable {
+ public class View : Clutter.Actor, Atk.Implementor, Clutter.Animatable, Clutter.Container,
Clutter.Scriptable {
[CCode (has_construct_function = false, type = "ClutterActor*")]
public View ();
public void add_layer (Champlain.Layer layer);
@@ -508,6 +508,7 @@ namespace Champlain {
public void ensure_layers_visible (bool animate);
public void ensure_visible (Champlain.BoundingBox bbox, bool animate);
public bool get_animate_zoom ();
+ public unowned Clutter.Texture get_background_tile ();
public double get_center_latitude ();
public double get_center_longitude ();
public double get_deceleration ();
@@ -527,6 +528,7 @@ namespace Champlain {
public void reload_tiles ();
public void remove_layer (Champlain.Layer layer);
public void set_animate_zoom (bool value);
+ public void set_background_tile (Clutter.Texture background);
public void set_deceleration (double rate);
public void set_keep_center_on_resize (bool value);
public void set_kinetic_mode (bool kinetic);
@@ -541,6 +543,7 @@ namespace Champlain {
public void zoom_in ();
public void zoom_out ();
public bool animate_zoom { get; set; }
+ public Clutter.Actor background_tile { get; set; }
public double deceleration { get; set; }
public bool keep_center_on_resize { get; set; }
public bool kinetic_mode { get; set; }
@@ -557,7 +560,7 @@ namespace Champlain {
public signal void layer_relocated ();
}
[CCode (cheader_filename = "champlain/champlain.h", type_id = "champlain_viewport_get_type ()")]
- public class Viewport : Clutter.Actor, Atk.Implementor, Clutter.Animatable, Clutter.Scriptable {
+ public class Viewport : Clutter.Actor, Atk.Implementor, Clutter.Animatable, Clutter.Container,
Clutter.Scriptable {
[CCode (has_construct_function = false, type = "ClutterActor*")]
public Viewport ();
public void get_adjustments (Champlain.Adjustment hadjustment, Champlain.Adjustment
vadjustment);
@@ -646,6 +649,8 @@ namespace Champlain {
public const string MAP_SOURCE_MEMPHIS_NETWORK;
[CCode (cheader_filename = "champlain/champlain.h", cname = "CHAMPLAIN_MAP_SOURCE_MFF_RELIEF")]
public const string MAP_SOURCE_MFF_RELIEF;
+ [CCode (cheader_filename = "champlain/champlain.h", cname = "CHAMPLAIN_MAP_SOURCE_OSM_AERIAL_MAP")]
+ public const string MAP_SOURCE_OSM_AERIAL_MAP;
[CCode (cheader_filename = "champlain/champlain.h", cname = "CHAMPLAIN_MAP_SOURCE_OSM_CYCLE_MAP")]
public const string MAP_SOURCE_OSM_CYCLE_MAP;
[CCode (cheader_filename = "champlain/champlain.h", cname = "CHAMPLAIN_MAP_SOURCE_OSM_MAPNIK")]
@@ -656,8 +661,6 @@ namespace Champlain {
public const string MAP_SOURCE_OSM_OSMARENDER;
[CCode (cheader_filename = "champlain/champlain.h", cname = "CHAMPLAIN_MAP_SOURCE_OSM_TRANSPORT_MAP")]
public const string MAP_SOURCE_OSM_TRANSPORT_MAP;
- [CCode (cheader_filename = "champlain/champlain.h", cname = "CHAMPLAIN_MAP_SOURCE_OSM_AERIAL_MAP")]
- public const string MAP_SOURCE_OSM_AERIAL_MAP;
[CCode (cheader_filename = "champlain/champlain.h", cname = "CHAMPLAIN_MAX_LATITUDE")]
public const double MAX_LATITUDE;
[CCode (cheader_filename = "champlain/champlain.h", cname = "CHAMPLAIN_MAX_LONGITUDE")]
diff --git a/champlain/champlain-adjustment.c b/champlain/champlain-adjustment.c
index dce4b07..011ac1e 100644
--- a/champlain/champlain-adjustment.c
+++ b/champlain/champlain-adjustment.c
@@ -53,7 +53,6 @@ struct _ChamplainAdjustmentPrivate
/* For elasticity */
gboolean elastic;
- ClutterAlpha *bounce_alpha;
};
enum
@@ -190,12 +189,6 @@ stop_interpolation (ChamplainAdjustment *adjustment)
clutter_timeline_stop (priv->interpolation);
g_object_unref (priv->interpolation);
priv->interpolation = NULL;
-
- if (priv->bounce_alpha)
- {
- g_object_unref (priv->bounce_alpha);
- priv->bounce_alpha = NULL;
- }
}
}
@@ -532,9 +525,9 @@ interpolation_new_frame_cb (ClutterTimeline *timeline,
ChamplainAdjustmentPrivate *priv = adjustment->priv;
priv->interpolation = NULL;
- if (priv->elastic && priv->bounce_alpha)
+ if (priv->elastic)
{
- gdouble progress = clutter_alpha_get_alpha (priv->bounce_alpha) / 1;
+ gdouble progress = clutter_timeline_get_progress (timeline);
gdouble dx = priv->old_position +
(priv->new_position - priv->old_position) *
progress;
@@ -605,8 +598,7 @@ champlain_adjustment_interpolate (ChamplainAdjustment *adjustment,
priv->interpolation = clutter_timeline_new (((float) n_frames / fps) * 1000);
if (priv->elastic)
- priv->bounce_alpha = clutter_alpha_new_full (priv->interpolation,
- CLUTTER_EASE_OUT_SINE);
+ clutter_timeline_set_progress_mode (priv->interpolation, CLUTTER_EASE_OUT_SINE);
g_signal_connect (priv->interpolation,
"new-frame",
diff --git a/champlain/champlain-custom-marker.c b/champlain/champlain-custom-marker.c
index f8dcfce..57af9a9 100644
--- a/champlain/champlain-custom-marker.c
+++ b/champlain/champlain-custom-marker.c
@@ -53,7 +53,7 @@ enum
struct _ChamplainCustomMarkerPrivate
{
- ClutterContainer *content_group;
+ ClutterContainer *dummy;
};
static void clutter_container_iface_init (ClutterContainerIface *iface);
@@ -71,9 +71,7 @@ static void
add_actor (ClutterContainer *container,
ClutterActor *actor)
{
- ChamplainCustomMarkerPrivate *priv = GET_PRIVATE (container);
-
- clutter_container_add_actor (priv->content_group, actor);
+ clutter_actor_add_child (CLUTTER_ACTOR (container), actor);
}
@@ -81,9 +79,7 @@ static void
remove_actor (ClutterContainer *container,
ClutterActor *actor)
{
- ChamplainCustomMarkerPrivate *priv = GET_PRIVATE (container);
-
- clutter_container_remove_actor (priv->content_group, actor);
+ clutter_actor_remove_child (CLUTTER_ACTOR (container), actor);
}
@@ -92,9 +88,14 @@ foreach_actor (ClutterContainer *container,
ClutterCallback callback,
gpointer user_data)
{
- ChamplainCustomMarkerPrivate *priv = GET_PRIVATE (container);
+ ClutterActor *child;
- clutter_container_foreach (priv->content_group, callback, user_data);
+ for (child = clutter_actor_get_first_child (CLUTTER_ACTOR (container));
+ child != NULL;
+ child = clutter_actor_get_next_sibling (child))
+ {
+ callback (child, user_data);
+ }
}
@@ -103,9 +104,7 @@ raise_actor (ClutterContainer *container,
ClutterActor *actor,
ClutterActor *sibling)
{
- ChamplainCustomMarkerPrivate *priv = GET_PRIVATE (container);
-
- clutter_container_raise_child (priv->content_group, actor, sibling);
+ clutter_actor_set_child_above_sibling (CLUTTER_ACTOR (container), actor, sibling);
}
@@ -114,21 +113,16 @@ lower_actor (ClutterContainer *container,
ClutterActor *actor,
ClutterActor *sibling)
{
- ChamplainCustomMarkerPrivate *priv = GET_PRIVATE (container);
-
- clutter_container_lower_child (priv->content_group, actor, sibling);
+ clutter_actor_set_child_below_sibling (CLUTTER_ACTOR (container), actor, sibling);
}
static void
sort_depth_order (ClutterContainer *container)
{
- ChamplainCustomMarkerPrivate *priv = GET_PRIVATE (container);
-
- clutter_container_sort_depth_order (priv->content_group);
+ /* NOOP */
}
-
static void
clutter_container_iface_init (ClutterContainerIface *iface)
{
@@ -142,108 +136,9 @@ clutter_container_iface_init (ClutterContainerIface *iface)
static void
-paint (ClutterActor *actor)
-{
- ChamplainCustomMarkerPrivate *priv = GET_PRIVATE (actor);
-
- clutter_actor_paint (CLUTTER_ACTOR (priv->content_group));
-}
-
-
-static void
-pick (ClutterActor *actor,
- const ClutterColor *color)
-{
- ChamplainCustomMarkerPrivate *priv = GET_PRIVATE (actor);
-
- CLUTTER_ACTOR_CLASS (champlain_custom_marker_parent_class)->pick (actor, color);
-
- clutter_actor_paint (CLUTTER_ACTOR (priv->content_group));
-}
-
-
-static void
-get_preferred_width (ClutterActor *actor,
- gfloat for_height,
- gfloat *min_width,
- gfloat *natural_width)
-{
- ChamplainCustomMarkerPrivate *priv = GET_PRIVATE (actor);
-
- clutter_actor_get_preferred_width (CLUTTER_ACTOR (priv->content_group),
- for_height,
- min_width,
- natural_width);
-}
-
-
-static void
-get_preferred_height (ClutterActor *actor,
- gfloat for_width,
- gfloat *min_height,
- gfloat *natural_height)
-{
- ChamplainCustomMarkerPrivate *priv = GET_PRIVATE (actor);
-
- clutter_actor_get_preferred_height (CLUTTER_ACTOR (priv->content_group),
- for_width,
- min_height,
- natural_height);
-}
-
-
-static void
-allocate (ClutterActor *actor,
- const ClutterActorBox *box,
- ClutterAllocationFlags flags)
-{
- ClutterActorBox child_box;
-
- ChamplainCustomMarkerPrivate *priv = GET_PRIVATE (actor);
-
- CLUTTER_ACTOR_CLASS (champlain_custom_marker_parent_class)->allocate (actor, box, flags);
-
- child_box.x1 = 0;
- child_box.x2 = box->x2 - box->x1;
- child_box.y1 = 0;
- child_box.y2 = box->y2 - box->y1;
-
- clutter_actor_allocate (CLUTTER_ACTOR (priv->content_group), &child_box, flags);
-}
-
-
-static void
-map (ClutterActor *self)
-{
- ChamplainCustomMarkerPrivate *priv = GET_PRIVATE (self);
-
- CLUTTER_ACTOR_CLASS (champlain_custom_marker_parent_class)->map (self);
-
- clutter_actor_map (CLUTTER_ACTOR (priv->content_group));
-}
-
-
-static void
-unmap (ClutterActor *self)
-{
- ChamplainCustomMarkerPrivate *priv = GET_PRIVATE (self);
-
- CLUTTER_ACTOR_CLASS (champlain_custom_marker_parent_class)->unmap (self);
-
- clutter_actor_unmap (CLUTTER_ACTOR (priv->content_group));
-}
-
-
-static void
champlain_custom_marker_dispose (GObject *object)
{
- ChamplainCustomMarkerPrivate *priv = CHAMPLAIN_CUSTOM_MARKER (object)->priv;
-
- if (priv->content_group)
- {
- clutter_actor_unparent (CLUTTER_ACTOR (priv->content_group));
- priv->content_group = NULL;
- }
+/* ChamplainCustomMarkerPrivate *priv = CHAMPLAIN_CUSTOM_MARKER (object)->priv; */
G_OBJECT_CLASS (champlain_custom_marker_parent_class)->dispose (object);
}
@@ -261,21 +156,12 @@ champlain_custom_marker_finalize (GObject *object)
static void
champlain_custom_marker_class_init (ChamplainCustomMarkerClass *klass)
{
- ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
g_type_class_add_private (klass, sizeof (ChamplainCustomMarkerPrivate));
object_class->finalize = champlain_custom_marker_finalize;
object_class->dispose = champlain_custom_marker_dispose;
-
- actor_class->get_preferred_width = get_preferred_width;
- actor_class->get_preferred_height = get_preferred_height;
- actor_class->allocate = allocate;
- actor_class->paint = paint;
- actor_class->pick = pick;
- actor_class->map = map;
- actor_class->unmap = unmap;
}
@@ -285,9 +171,6 @@ champlain_custom_marker_init (ChamplainCustomMarker *custom_marker)
ChamplainCustomMarkerPrivate *priv = GET_PRIVATE (custom_marker);
custom_marker->priv = priv;
- priv->content_group = CLUTTER_CONTAINER (clutter_group_new ());
- clutter_actor_set_parent (CLUTTER_ACTOR (priv->content_group), CLUTTER_ACTOR (custom_marker));
- clutter_actor_queue_relayout (CLUTTER_ACTOR (custom_marker));
}
diff --git a/champlain/champlain-error-tile-renderer.c b/champlain/champlain-error-tile-renderer.c
index 28657cb..8f2b789 100644
--- a/champlain/champlain-error-tile-renderer.c
+++ b/champlain/champlain-error-tile-renderer.c
@@ -34,7 +34,7 @@ G_DEFINE_TYPE (ChamplainErrorTileRenderer, champlain_error_tile_renderer, CHAMPL
struct _ChamplainErrorTileRendererPrivate
{
- CoglHandle error_tex;
+ ClutterContent *error_canvas;
guint tile_size;
};
@@ -97,10 +97,10 @@ champlain_error_tile_renderer_dispose (GObject *object)
{
ChamplainErrorTileRendererPrivate *priv = CHAMPLAIN_ERROR_TILE_RENDERER (object)->priv;
- if (priv->error_tex)
+ if (priv->error_canvas)
{
- cogl_handle_unref (priv->error_tex);
- priv->error_tex = NULL;
+ g_object_unref (priv->error_canvas);
+ priv->error_canvas = NULL;
}
G_OBJECT_CLASS (champlain_error_tile_renderer_parent_class)->dispose (object);
@@ -156,7 +156,7 @@ champlain_error_tile_renderer_init (ChamplainErrorTileRenderer *self)
self->priv = priv;
- priv->error_tex = NULL;
+ priv->error_canvas = NULL;
}
@@ -186,6 +186,39 @@ set_data (ChamplainRenderer *renderer, const gchar *data, guint size)
}
+static gboolean
+redraw_tile (ClutterCanvas *canvas,
+ cairo_t *cr,
+ gint w,
+ gint h)
+{
+ cairo_pattern_t *pat;
+ gint size = w;
+
+ /* draw a linear gray to white pattern */
+ pat = cairo_pattern_create_linear (size / 2.0, 0.0, size, size / 2.0);
+ cairo_pattern_add_color_stop_rgb (pat, 0, 0.686, 0.686, 0.686);
+ cairo_pattern_add_color_stop_rgb (pat, 1, 0.925, 0.925, 0.925);
+ cairo_set_source (cr, pat);
+ cairo_rectangle (cr, 0, 0, size, size);
+ cairo_fill (cr);
+
+ cairo_pattern_destroy (pat);
+
+ /* draw the red cross */
+ cairo_set_source_rgb (cr, 0.424, 0.078, 0.078);
+ cairo_set_line_width (cr, 14.0);
+ cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
+ cairo_move_to (cr, 24, 24);
+ cairo_line_to (cr, 50, 50);
+ cairo_move_to (cr, 50, 24);
+ cairo_line_to (cr, 24, 50);
+ cairo_stroke (cr);
+
+ return TRUE;
+}
+
+
static void
render (ChamplainRenderer *renderer, ChamplainTile *tile)
{
@@ -194,7 +227,7 @@ render (ChamplainRenderer *renderer, ChamplainTile *tile)
ChamplainErrorTileRenderer *error_renderer = CHAMPLAIN_ERROR_TILE_RENDERER (renderer);
ChamplainErrorTileRendererPrivate *priv = error_renderer->priv;
- ClutterActor *clone;
+ ClutterActor *actor;
gpointer data = NULL;
guint size = 0;
gboolean error = FALSE;
@@ -208,47 +241,19 @@ render (ChamplainRenderer *renderer, ChamplainTile *tile)
size = champlain_error_tile_renderer_get_tile_size (error_renderer);
- if (!priv->error_tex)
+ if (!priv->error_canvas)
{
- cairo_t *cr;
- cairo_pattern_t *pat;
- ClutterActor *tmp_actor;
-
- tmp_actor = clutter_cairo_texture_new (size, size);
- cr = clutter_cairo_texture_create (CLUTTER_CAIRO_TEXTURE (tmp_actor));
-
- /* draw a linear gray to white pattern */
- pat = cairo_pattern_create_linear (size / 2.0, 0.0, size, size / 2.0);
- cairo_pattern_add_color_stop_rgb (pat, 0, 0.686, 0.686, 0.686);
- cairo_pattern_add_color_stop_rgb (pat, 1, 0.925, 0.925, 0.925);
- cairo_set_source (cr, pat);
- cairo_rectangle (cr, 0, 0, size, size);
- cairo_fill (cr);
-
- cairo_pattern_destroy (pat);
-
- /* draw the red cross */
- cairo_set_source_rgb (cr, 0.424, 0.078, 0.078);
- cairo_set_line_width (cr, 14.0);
- cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
- cairo_move_to (cr, 24, 24);
- cairo_line_to (cr, 50, 50);
- cairo_move_to (cr, 50, 24);
- cairo_line_to (cr, 24, 50);
- cairo_stroke (cr);
-
- cairo_destroy (cr);
-
- priv->error_tex = clutter_texture_get_cogl_texture (CLUTTER_TEXTURE (tmp_actor));
- cogl_handle_ref (priv->error_tex);
-
- g_object_ref_sink (tmp_actor);
- g_object_unref (tmp_actor);
+ priv->error_canvas = clutter_canvas_new ();
+ clutter_canvas_set_size (CLUTTER_CANVAS (priv->error_canvas), size, size);
+ g_signal_connect (priv->error_canvas, "draw", G_CALLBACK (redraw_tile), NULL);
+ clutter_content_invalidate (priv->error_canvas);
}
- clone = clutter_texture_new ();
- clutter_texture_set_cogl_texture (CLUTTER_TEXTURE (clone), priv->error_tex);
- champlain_tile_set_content (tile, clone);
+ actor = clutter_actor_new ();
+ clutter_actor_set_size (actor, size, size);
+ clutter_actor_set_content (actor, priv->error_canvas);
+
+ champlain_tile_set_content (tile, actor);
g_signal_emit_by_name (tile, "render-complete", data, size, error);
}
diff --git a/champlain/champlain-image-renderer.c b/champlain/champlain-image-renderer.c
index 661a75a..3fae505 100644
--- a/champlain/champlain-image-renderer.c
+++ b/champlain/champlain-image-renderer.c
@@ -129,6 +129,8 @@ render (ChamplainRenderer *renderer, ChamplainTile *tile)
GError *gerror = NULL;
ClutterActor *actor = NULL;
GdkPixbuf *pixbuf;
+ ClutterContent *content;
+ gfloat width, height;
if (!priv->data || priv->size == 0)
goto finish;
@@ -157,16 +159,22 @@ render (ChamplainRenderer *renderer, ChamplainTile *tile)
/* Load the image into clutter */
pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
- actor = clutter_texture_new ();
- if (!clutter_texture_set_from_rgb_data (CLUTTER_TEXTURE (actor),
+ if (!pixbuf)
+ {
+ g_warning ("NULL pixbuf");
+ goto finish;
+ }
+
+ content = clutter_image_new ();
+ if (!clutter_image_set_data (CLUTTER_IMAGE (content),
gdk_pixbuf_get_pixels (pixbuf),
- gdk_pixbuf_get_has_alpha (pixbuf),
+ gdk_pixbuf_get_has_alpha (pixbuf)
+ ? COGL_PIXEL_FORMAT_RGBA_8888
+ : COGL_PIXEL_FORMAT_RGB_888,
gdk_pixbuf_get_width (pixbuf),
gdk_pixbuf_get_height (pixbuf),
gdk_pixbuf_get_rowstride (pixbuf),
- gdk_pixbuf_get_bits_per_sample (pixbuf) *
- gdk_pixbuf_get_n_channels (pixbuf) / 8,
- 0, &gerror))
+ &gerror))
{
if (gerror)
{
@@ -174,11 +182,19 @@ render (ChamplainRenderer *renderer, ChamplainTile *tile)
g_error_free (gerror);
}
- g_object_unref (actor);
- actor = NULL;
+ g_object_unref (content);
goto finish;
}
+ clutter_content_get_preferred_size (content, &width, &height);
+ actor = clutter_actor_new ();
+ clutter_actor_set_size (actor, width, height);
+ clutter_actor_set_content (actor, content);
+ clutter_content_invalidate (content);
+ g_object_unref (content);
+ /* has to be set for proper opacity */
+ clutter_actor_set_offscreen_redirect (actor, CLUTTER_OFFSCREEN_REDIRECT_AUTOMATIC_FOR_OPACITY);
+
error = FALSE;
finish:
diff --git a/champlain/champlain-kinetic-scroll-view.c b/champlain/champlain-kinetic-scroll-view.c
index 57c60c6..a5f0307 100644
--- a/champlain/champlain-kinetic-scroll-view.c
+++ b/champlain/champlain-kinetic-scroll-view.c
@@ -28,11 +28,7 @@
#include <clutter/clutter.h>
#include <math.h>
-static void clutter_container_iface_init (ClutterContainerIface *iface);
-
-G_DEFINE_TYPE_WITH_CODE (ChamplainKineticScrollView, champlain_kinetic_scroll_view, CLUTTER_TYPE_ACTOR,
- G_IMPLEMENT_INTERFACE (CLUTTER_TYPE_CONTAINER, clutter_container_iface_init))
-
+G_DEFINE_TYPE (ChamplainKineticScrollView, champlain_kinetic_scroll_view, CLUTTER_TYPE_ACTOR)
#define GET_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE ((o), CHAMPLAIN_TYPE_KINETIC_SCROLL_VIEW, ChamplainKineticScrollViewPrivate))
@@ -141,7 +137,7 @@ champlain_kinetic_scroll_view_dispose (GObject *object)
if (priv->child)
{
- clutter_container_remove_actor (CLUTTER_CONTAINER (object), priv->child);
+ clutter_actor_remove_all_children (CLUTTER_ACTOR (object));
priv->child = NULL;
}
@@ -168,102 +164,9 @@ champlain_kinetic_scroll_view_finalize (GObject *object)
static void
-champlain_kinetic_scroll_view_paint (ClutterActor *actor)
-{
- ChamplainKineticScrollViewPrivate *priv = CHAMPLAIN_KINETIC_SCROLL_VIEW (actor)->priv;
-
- if (priv->child)
- clutter_actor_paint (priv->child);
-}
-
-
-static void
-champlain_kinetic_scroll_view_pick (ClutterActor *actor, const ClutterColor *color)
-{
- /* Chain up so we get a bounding box pained (if we are reactive) */
- CLUTTER_ACTOR_CLASS (champlain_kinetic_scroll_view_parent_class)->pick (actor, color);
-
- /* Trigger pick on children */
- champlain_kinetic_scroll_view_paint (actor);
-}
-
-
-static void
-champlain_kinetic_scroll_view_get_preferred_width (ClutterActor *actor,
- gfloat for_height,
- gfloat *min_width_p,
- gfloat *natural_width_p)
-{
- ChamplainKineticScrollViewPrivate *priv = CHAMPLAIN_KINETIC_SCROLL_VIEW (actor)->priv;
-
- if (!priv->child)
- return;
-
-
- /* Our natural width is the natural width of the child */
- clutter_actor_get_preferred_width (priv->child,
- for_height,
- NULL,
- natural_width_p);
-}
-
-
-static void
-champlain_kinetic_scroll_view_get_preferred_height (ClutterActor *actor,
- gfloat for_width,
- gfloat *min_height_p,
- gfloat *natural_height_p)
-{
- ChamplainKineticScrollViewPrivate *priv = CHAMPLAIN_KINETIC_SCROLL_VIEW (actor)->priv;
-
- if (!priv->child)
- return;
-
-
- /* Our natural height is the natural height of the child */
- clutter_actor_get_preferred_height (priv->child,
- for_width,
- NULL,
- natural_height_p);
-}
-
-
-static void
-champlain_kinetic_scroll_view_allocate (ClutterActor *actor,
- const ClutterActorBox *box,
- ClutterAllocationFlags flags)
-{
- ClutterActorBox child_box;
-
- ChamplainKineticScrollViewPrivate *priv = CHAMPLAIN_KINETIC_SCROLL_VIEW (actor)->priv;
-
- /* Chain up */
- CLUTTER_ACTOR_CLASS (champlain_kinetic_scroll_view_parent_class)->
- allocate (actor, box, flags);
-
- /* Child */
- child_box.x1 = 0;
- child_box.x2 = box->x2 - box->x1;
- child_box.y1 = 0;
- child_box.y2 = box->y2 - box->y1;
-
- if (priv->child)
- {
- clutter_actor_allocate (priv->child, &child_box, flags);
- clutter_actor_set_clip (priv->child,
- child_box.x1,
- child_box.y1,
- child_box.x2 - child_box.x1,
- child_box.y2 - child_box.y1);
- }
-}
-
-
-static void
champlain_kinetic_scroll_view_class_init (ChamplainKineticScrollViewClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
g_type_class_add_private (klass, sizeof (ChamplainKineticScrollViewPrivate));
@@ -272,12 +175,6 @@ champlain_kinetic_scroll_view_class_init (ChamplainKineticScrollViewClass *klass
object_class->dispose = champlain_kinetic_scroll_view_dispose;
object_class->finalize = champlain_kinetic_scroll_view_finalize;
- actor_class->paint = champlain_kinetic_scroll_view_paint;
- actor_class->pick = champlain_kinetic_scroll_view_pick;
- actor_class->get_preferred_width = champlain_kinetic_scroll_view_get_preferred_width;
- actor_class->get_preferred_height = champlain_kinetic_scroll_view_get_preferred_height;
- actor_class->allocate = champlain_kinetic_scroll_view_allocate;
-
g_object_class_install_property (object_class,
PROP_MODE,
g_param_spec_boolean ("mode",
@@ -316,115 +213,6 @@ champlain_kinetic_scroll_view_class_init (ChamplainKineticScrollViewClass *klass
}
-static void
-champlain_kinetic_scroll_view_add_actor (ClutterContainer *container,
- ClutterActor *actor)
-{
- ChamplainKineticScrollView *self = CHAMPLAIN_KINETIC_SCROLL_VIEW (container);
- ChamplainKineticScrollViewPrivate *priv = self->priv;
-
- if (priv->child)
- {
- g_warning ("Attempting to add an actor of type %s to "
- "a ChamplainKineticScrollView that already contains "
- "an actor of type %s.",
- g_type_name (G_OBJECT_TYPE (actor)),
- g_type_name (G_OBJECT_TYPE (priv->child)));
- }
- else
- {
- if (CHAMPLAIN_IS_VIEWPORT (actor))
- {
- priv->child = actor;
- clutter_actor_set_parent (actor, CLUTTER_ACTOR (container));
-
- /* Notify that child has been set */
- g_signal_emit_by_name (container, "actor-added", priv->child);
-
- clutter_actor_queue_relayout (CLUTTER_ACTOR (container));
- }
- else
- {
- g_warning ("Attempting to add an actor to "
- "a ChamplainKineticScrollView, but the actor does "
- "not implement ChamplainViewport.");
- }
- }
-}
-
-
-static void
-champlain_kinetic_scroll_view_remove_actor (ClutterContainer *container,
- ClutterActor *actor)
-{
- ChamplainKineticScrollViewPrivate *priv = CHAMPLAIN_KINETIC_SCROLL_VIEW (container)->priv;
-
- if (actor == priv->child)
- {
- g_object_ref (priv->child);
-
- clutter_actor_unparent (priv->child);
-
- g_signal_emit_by_name (container, "actor-removed", priv->child);
-
- g_object_unref (priv->child);
- priv->child = NULL;
-
- if (CLUTTER_ACTOR_IS_VISIBLE (container))
- clutter_actor_queue_relayout (CLUTTER_ACTOR (container));
- }
-}
-
-
-static void
-champlain_kinetic_scroll_view_foreach (ClutterContainer *container,
- ClutterCallback callback,
- gpointer callback_data)
-{
- ChamplainKineticScrollViewPrivate *priv = CHAMPLAIN_KINETIC_SCROLL_VIEW (container)->priv;
-
- if (priv->child)
- callback (priv->child, callback_data);
-}
-
-
-static void
-champlain_kinetic_scroll_view_lower (ClutterContainer *container,
- ClutterActor *actor,
- ClutterActor *sibling)
-{
- /* single child */
-}
-
-
-static void
-champlain_kinetic_scroll_view_raise (ClutterContainer *container,
- ClutterActor *actor,
- ClutterActor *sibling)
-{
- /* single child */
-}
-
-
-static void
-champlain_kinetic_scroll_view_sort_depth_order (ClutterContainer *container)
-{
- /* single child */
-}
-
-
-static void
-clutter_container_iface_init (ClutterContainerIface *iface)
-{
- iface->add = champlain_kinetic_scroll_view_add_actor;
- iface->remove = champlain_kinetic_scroll_view_remove_actor;
- iface->foreach = champlain_kinetic_scroll_view_foreach;
- iface->lower = champlain_kinetic_scroll_view_lower;
- iface->raise = champlain_kinetic_scroll_view_raise;
- iface->sort_depth_order = champlain_kinetic_scroll_view_sort_depth_order;
-}
-
-
static gboolean
motion_event_cb (ClutterActor *stage,
ClutterMotionEvent *event,
@@ -454,7 +242,7 @@ motion_event_cb (ClutterActor *stage,
if ((ABS (motion->x - x) >= threshold) ||
(ABS (motion->y - y) >= threshold))
{
- clutter_set_motion_events_enabled (TRUE);
+ clutter_stage_set_motion_events_enabled (CLUTTER_STAGE (stage), TRUE);
priv->in_drag = TRUE;
}
else
@@ -649,7 +437,7 @@ button_release_event_cb (ClutterActor *stage,
if (!priv->in_drag)
return FALSE;
- clutter_set_motion_events_enabled (TRUE);
+ clutter_stage_set_motion_events_enabled (CLUTTER_STAGE (stage), TRUE);
if (priv->kinetic && priv->child)
{
@@ -898,10 +686,17 @@ champlain_kinetic_scroll_view_init (ChamplainKineticScrollView *self)
ClutterActor *
-champlain_kinetic_scroll_view_new (gboolean kinetic)
+champlain_kinetic_scroll_view_new (gboolean kinetic,
+ ClutterActor *viewport)
{
- return CLUTTER_ACTOR (g_object_new (CHAMPLAIN_TYPE_KINETIC_SCROLL_VIEW,
+ ClutterActor *scroll_view;
+
+ scroll_view = CLUTTER_ACTOR (g_object_new (CHAMPLAIN_TYPE_KINETIC_SCROLL_VIEW,
"mode", kinetic, NULL));
+ CHAMPLAIN_KINETIC_SCROLL_VIEW (scroll_view)->priv->child = viewport;
+ clutter_actor_add_child (CLUTTER_ACTOR (scroll_view), viewport);
+
+ return scroll_view;
}
diff --git a/champlain/champlain-kinetic-scroll-view.h b/champlain/champlain-kinetic-scroll-view.h
index 6c82fd6..2045888 100644
--- a/champlain/champlain-kinetic-scroll-view.h
+++ b/champlain/champlain-kinetic-scroll-view.h
@@ -64,9 +64,10 @@ struct _ChamplainKineticScrollViewClass
GType champlain_kinetic_scroll_view_get_type (void) G_GNUC_CONST;
-ClutterActor *champlain_kinetic_scroll_view_new (gboolean kinetic);
+ClutterActor *champlain_kinetic_scroll_view_new (gboolean kinetic,
+ ClutterActor *viewport);
-void champlain_kinetic_scroll_view_stop (ChamplainKineticScrollView *scroll);
+void champlain_kinetic_scroll_view_stop (ChamplainKineticScrollView *self);
G_END_DECLS
diff --git a/champlain/champlain-label.c b/champlain/champlain-label.c
index b2127cf..01c2802 100644
--- a/champlain/champlain-label.c
+++ b/champlain/champlain-label.c
@@ -44,6 +44,7 @@
#include "champlain-tile.h"
#include <clutter/clutter.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
#include <glib.h>
#include <glib-object.h>
#include <cairo.h>
@@ -51,6 +52,8 @@
#include <string.h>
#define DEFAULT_FONT_NAME "Sans 11"
+#define SLOPE -0.3
+#define SCALING 0.65
static ClutterColor DEFAULT_COLOR = { 0x33, 0x33, 0x33, 0xff };
static ClutterColor DEFAULT_TEXT_COLOR = { 0xee, 0xee, 0xee, 0xff };
@@ -103,8 +106,7 @@ struct _ChamplainLabelPrivate
guint redraw_id;
guint total_width;
guint total_height;
-
- ClutterGroup *content_group;
+ guint point;
};
G_DEFINE_TYPE (ChamplainLabel, champlain_label, CHAMPLAIN_TYPE_MARKER);
@@ -243,16 +245,6 @@ champlain_label_set_property (GObject *object,
}
-
-static void
-paint (ClutterActor *self)
-{
- ChamplainLabelPrivate *priv = GET_PRIVATE (self);
-
- clutter_actor_paint (CLUTTER_ACTOR (priv->content_group));
-}
-
-
#define RADIUS 10
#define PADDING (RADIUS / 2)
@@ -291,78 +283,6 @@ pick (ClutterActor *self,
static void
-get_preferred_width (ClutterActor *self,
- gfloat for_height,
- gfloat *min_width_p,
- gfloat *natural_width_p)
-{
- ChamplainLabelPrivate *priv = GET_PRIVATE (self);
-
- clutter_actor_get_preferred_width (CLUTTER_ACTOR (priv->content_group),
- for_height,
- min_width_p,
- natural_width_p);
-}
-
-
-static void
-get_preferred_height (ClutterActor *self,
- gfloat for_width,
- gfloat *min_height_p,
- gfloat *natural_height_p)
-{
- ChamplainLabelPrivate *priv = GET_PRIVATE (self);
-
- clutter_actor_get_preferred_height (CLUTTER_ACTOR (priv->content_group),
- for_width,
- min_height_p,
- natural_height_p);
-}
-
-
-static void
-allocate (ClutterActor *self,
- const ClutterActorBox *box,
- ClutterAllocationFlags flags)
-{
- ClutterActorBox child_box;
-
- ChamplainLabelPrivate *priv = GET_PRIVATE (self);
-
- CLUTTER_ACTOR_CLASS (champlain_label_parent_class)->allocate (self, box, flags);
-
- child_box.x1 = 0;
- child_box.x2 = box->x2 - box->x1;
- child_box.y1 = 0;
- child_box.y2 = box->y2 - box->y1;
-
- clutter_actor_allocate (CLUTTER_ACTOR (priv->content_group), &child_box, flags);
-}
-
-
-static void
-map (ClutterActor *self)
-{
- ChamplainLabelPrivate *priv = GET_PRIVATE (self);
-
- CLUTTER_ACTOR_CLASS (champlain_label_parent_class)->map (self);
-
- clutter_actor_map (CLUTTER_ACTOR (priv->content_group));
-}
-
-
-static void
-unmap (ClutterActor *self)
-{
- ChamplainLabelPrivate *priv = GET_PRIVATE (self);
-
- CLUTTER_ACTOR_CLASS (champlain_label_parent_class)->unmap (self);
-
- clutter_actor_unmap (CLUTTER_ACTOR (priv->content_group));
-}
-
-
-static void
champlain_label_dispose (GObject *object)
{
ChamplainLabelPrivate *priv = CHAMPLAIN_LABEL (object)->priv;
@@ -383,12 +303,6 @@ champlain_label_dispose (GObject *object)
priv->attributes = NULL;
}
- if (priv->content_group)
- {
- clutter_actor_unparent (CLUTTER_ACTOR (priv->content_group));
- priv->content_group = NULL;
- }
-
G_OBJECT_CLASS (champlain_label_parent_class)->dispose (object);
}
@@ -445,13 +359,7 @@ champlain_label_class_init (ChamplainLabelClass *klass)
object_class->get_property = champlain_label_get_property;
object_class->set_property = champlain_label_set_property;
- actor_class->get_preferred_width = get_preferred_width;
- actor_class->get_preferred_height = get_preferred_height;
- actor_class->allocate = allocate;
- actor_class->paint = paint;
actor_class->pick = pick;
- actor_class->map = map;
- actor_class->unmap = unmap;
/**
* ChamplainLabel:text:
@@ -661,29 +569,33 @@ draw_box (cairo_t *cr,
}
-static void
-draw_shadow (ChamplainLabel *label,
- gint width,
- gint height,
- gint point)
+static gint
+get_shadow_slope_width (ChamplainLabel *label)
{
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;
+ x = -40 * SLOPE;
else
- x = -58 * slope;
+ x = -58 * SLOPE;
+
+ return x;
+}
+
+
+static gboolean
+draw_shadow (ClutterCanvas *canvas,
+ cairo_t *cr,
+ int width,
+ int height,
+ ChamplainLabel *label)
+{
+ ChamplainLabelPrivate *priv = label->priv;
+ gint x;
+ cairo_matrix_t matrix;
- shadow = clutter_cairo_texture_new (width + x, (height + point));
- cr = clutter_cairo_texture_create (CLUTTER_CAIRO_TEXTURE (shadow));
+ x = get_shadow_slope_width (label);
cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
cairo_paint (cr);
@@ -691,46 +603,30 @@ draw_shadow (ChamplainLabel *label,
cairo_matrix_init (&matrix,
1, 0,
- slope, scaling,
+ SLOPE, SCALING,
x, 0);
cairo_set_matrix (cr, &matrix);
- draw_box (cr, width, height, point, priv->alignment == PANGO_ALIGN_LEFT);
+ draw_box (cr, width - x, height - priv->point, priv->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 (priv->content_group), shadow);
-
- if (priv->shadow != NULL)
- {
- clutter_container_remove_actor (CLUTTER_CONTAINER (priv->content_group),
- priv->shadow);
- }
-
- priv->shadow = shadow;
+ return TRUE;
}
-static void
-draw_background (ChamplainLabel *label,
- gint width,
- gint height,
- gint point)
+static gboolean
+draw_background (ClutterCanvas *canvas,
+ cairo_t *cr,
+ int width,
+ int height,
+ ChamplainLabel *label)
{
ChamplainLabelPrivate *priv = label->priv;
ChamplainMarker *marker = CHAMPLAIN_MARKER (label);
- ClutterActor *bg = NULL;
const 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));
cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
cairo_paint (cr);
@@ -742,8 +638,7 @@ draw_background (ChamplainLabel *label,
else
color = priv->color;
-
- draw_box (cr, width, height, point, priv->alignment == PANGO_ALIGN_LEFT);
+ draw_box (cr, width, height - priv->point, priv->point, priv->alignment == PANGO_ALIGN_LEFT);
clutter_color_darken (color, &darker_color);
@@ -761,17 +656,8 @@ draw_background (ChamplainLabel *label,
darker_color.blue / 255.0,
darker_color.alpha / 255.0);
cairo_stroke (cr);
- cairo_destroy (cr);
-
- clutter_container_add_actor (CLUTTER_CONTAINER (priv->content_group), bg);
-
- if (priv->background != NULL)
- {
- clutter_container_remove_actor (CLUTTER_CONTAINER (priv->content_group),
- priv->background);
- }
-
- priv->background = bg;
+
+ return TRUE;
}
@@ -780,19 +666,16 @@ draw_label (ChamplainLabel *label)
{
ChamplainLabelPrivate *priv = label->priv;
ChamplainMarker *marker = CHAMPLAIN_MARKER (label);
- guint height = 0, point = 0;
+ guint height = 0;
guint total_width = 0, total_height = 0;
- if (!priv->content_group)
- return;
-
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 (priv->content_group), priv->image);
+ clutter_actor_add_child (CLUTTER_ACTOR (label), priv->image);
}
if (priv->text != NULL && strlen (priv->text) > 0)
@@ -832,7 +715,7 @@ draw_label (ChamplainLabel *label)
clutter_text_set_color (CLUTTER_TEXT (priv->text_actor),
(champlain_marker_get_selected (marker) ? champlain_marker_get_selection_text_color () :
priv->text_color));
if (clutter_actor_get_parent (priv->text_actor) == NULL)
- clutter_container_add_actor (CLUTTER_CONTAINER (priv->content_group), priv->text_actor);
+ clutter_actor_add_child (CLUTTER_ACTOR (label), priv->text_actor);
}
if (priv->text_actor == NULL && priv->image == NULL)
@@ -841,41 +724,61 @@ draw_label (ChamplainLabel *label)
total_height = 6 * PADDING;
}
- point = (total_height + 2 * PADDING) / 4.0;
+ priv->point = (total_height + 2 * PADDING) / 4.0;
priv->total_width = total_width;
priv->total_height = total_height;
- if (priv->draw_background)
+ if (priv->background != NULL)
{
- draw_shadow (label, total_width, total_height, point);
- draw_background (label, total_width, total_height, point);
+ clutter_actor_remove_child (CLUTTER_ACTOR (label), priv->background);
+ priv->background = NULL;
}
- else
- {
- if (priv->background != NULL)
- {
- clutter_container_remove_actor (CLUTTER_CONTAINER (priv->content_group), priv->background);
- priv->background = NULL;
- }
- if (priv->shadow != NULL)
- {
- clutter_container_remove_actor (CLUTTER_CONTAINER (priv->content_group), priv->shadow);
- priv->shadow = NULL;
- }
+ if (priv->shadow != NULL)
+ {
+ clutter_actor_remove_child (CLUTTER_ACTOR (label), priv->shadow);
+ priv->shadow = NULL;
}
+ if (priv->draw_background)
+ {
+ ClutterContent *canvas;
+
+ canvas = clutter_canvas_new ();
+ clutter_canvas_set_size (CLUTTER_CANVAS (canvas), total_width, total_height + priv->point);
+ g_signal_connect (canvas, "draw", G_CALLBACK (draw_background), label);
+
+ priv->background = clutter_actor_new ();
+ clutter_actor_set_size (priv->background, total_width, total_height + priv->point);
+ clutter_actor_set_content (priv->background, canvas);
+ clutter_actor_add_child (CLUTTER_ACTOR (label), priv->background);
+ clutter_content_invalidate (canvas);
+ g_object_unref (canvas);
+
+ canvas = clutter_canvas_new ();
+ clutter_canvas_set_size (CLUTTER_CANVAS (canvas), total_width + get_shadow_slope_width (label),
total_height + priv->point);
+ g_signal_connect (canvas, "draw", G_CALLBACK (draw_shadow), label);
+
+ priv->shadow = clutter_actor_new ();
+ clutter_actor_set_size (priv->shadow, total_width + get_shadow_slope_width (label), total_height +
priv->point);
+ clutter_actor_set_content (priv->shadow, canvas);
+ clutter_actor_add_child (CLUTTER_ACTOR (label), priv->shadow);
+ clutter_actor_set_position (priv->shadow, 0, total_height / 2.0);
+ clutter_content_invalidate (canvas);
+ g_object_unref (canvas);
+ }
+
if (priv->text_actor != NULL && priv->background != NULL)
- clutter_actor_raise (priv->text_actor, priv->background);
+ clutter_actor_set_child_above_sibling (CLUTTER_ACTOR (label), priv->text_actor, priv->background);
if (priv->image != NULL && priv->background != NULL)
- clutter_actor_raise (priv->image, priv->background);
+ clutter_actor_set_child_above_sibling (CLUTTER_ACTOR (label), 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);
+ clutter_actor_set_anchor_point (CLUTTER_ACTOR (label), total_width, total_height + priv->point);
else
- clutter_actor_set_anchor_point (CLUTTER_ACTOR (label), 0, total_height + point);
+ clutter_actor_set_anchor_point (CLUTTER_ACTOR (label), 0, total_height + priv->point);
}
else if (priv->image != NULL)
clutter_actor_set_anchor_point (CLUTTER_ACTOR (label),
@@ -959,9 +862,6 @@ champlain_label_init (ChamplainLabel *label)
priv->redraw_id = 0;
priv->shadow = NULL;
priv->text_actor = NULL;
- priv->content_group = CLUTTER_GROUP (clutter_group_new ());
- clutter_actor_set_parent (CLUTTER_ACTOR (priv->content_group), CLUTTER_ACTOR (label));
- clutter_actor_queue_relayout (CLUTTER_ACTOR (label));
priv->total_width = 0;
priv->total_height = 0;
@@ -1060,16 +960,40 @@ ClutterActor *
champlain_label_new_from_file (const gchar *filename,
GError **error)
{
+ ChamplainLabel *label = CHAMPLAIN_LABEL (champlain_label_new ());
+
+ ClutterActor *actor;
+ GdkPixbuf *pixbuf;
+ ClutterContent *content;
+ gfloat width, height;
+
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);
- }
+ pixbuf = gdk_pixbuf_new_from_file (filename, error);
+ if (pixbuf == NULL)
+ return NULL;
+
+ content = clutter_image_new ();
+ clutter_image_set_data (CLUTTER_IMAGE (content),
+ gdk_pixbuf_get_pixels (pixbuf),
+ gdk_pixbuf_get_has_alpha (pixbuf)
+ ? COGL_PIXEL_FORMAT_RGBA_8888
+ : COGL_PIXEL_FORMAT_RGB_888,
+ gdk_pixbuf_get_width (pixbuf),
+ gdk_pixbuf_get_height (pixbuf),
+ gdk_pixbuf_get_rowstride (pixbuf),
+ error);
+ g_object_unref (pixbuf);
+
+ actor = clutter_actor_new ();
+ clutter_content_get_preferred_size (content, &width, &height);
+ clutter_actor_set_size (actor, width, height);
+ clutter_actor_set_content (actor, content);
+ clutter_content_invalidate (content);
+ g_object_unref (content);
+
+ champlain_label_set_image (label, actor);
return CLUTTER_ACTOR (label);
}
diff --git a/champlain/champlain-license.c b/champlain/champlain-license.c
index c4ffbb7..2a6de63 100644
--- a/champlain/champlain-license.c
+++ b/champlain/champlain-license.c
@@ -59,7 +59,6 @@ struct _ChamplainLicensePrivate
{
gchar *extra_text; /* Extra license text */
ClutterActor *license_actor;
- ClutterGroup *content_group;
PangoAlignment alignment;
ChamplainView *view;
@@ -123,99 +122,6 @@ champlain_license_set_property (GObject *object,
static void
-paint (ClutterActor *self)
-{
- ChamplainLicensePrivate *priv = GET_PRIVATE (self);
-
- clutter_actor_paint (CLUTTER_ACTOR (priv->content_group));
-}
-
-
-static void
-pick (ClutterActor *self,
- const ClutterColor *color)
-{
- ChamplainLicensePrivate *priv = GET_PRIVATE (self);
-
- CLUTTER_ACTOR_CLASS (champlain_license_parent_class)->pick (self, color);
-
- clutter_actor_paint (CLUTTER_ACTOR (priv->content_group));
-}
-
-
-static void
-get_preferred_width (ClutterActor *self,
- gfloat for_height,
- gfloat *min_width_p,
- gfloat *natural_width_p)
-{
- ChamplainLicensePrivate *priv = GET_PRIVATE (self);
-
- clutter_actor_get_preferred_width (CLUTTER_ACTOR (priv->content_group),
- for_height,
- min_width_p,
- natural_width_p);
-}
-
-
-static void
-get_preferred_height (ClutterActor *self,
- gfloat for_width,
- gfloat *min_height_p,
- gfloat *natural_height_p)
-{
- ChamplainLicensePrivate *priv = GET_PRIVATE (self);
-
- clutter_actor_get_preferred_height (CLUTTER_ACTOR (priv->content_group),
- for_width,
- min_height_p,
- natural_height_p);
-}
-
-
-static void
-allocate (ClutterActor *self,
- const ClutterActorBox *box,
- ClutterAllocationFlags flags)
-{
- ClutterActorBox child_box;
-
- ChamplainLicensePrivate *priv = GET_PRIVATE (self);
-
- CLUTTER_ACTOR_CLASS (champlain_license_parent_class)->allocate (self, box, flags);
-
- child_box.x1 = 0;
- child_box.x2 = box->x2 - box->x1;
- child_box.y1 = 0;
- child_box.y2 = box->y2 - box->y1;
-
- clutter_actor_allocate (CLUTTER_ACTOR (priv->content_group), &child_box, flags);
-}
-
-
-static void
-map (ClutterActor *self)
-{
- ChamplainLicensePrivate *priv = GET_PRIVATE (self);
-
- CLUTTER_ACTOR_CLASS (champlain_license_parent_class)->map (self);
-
- clutter_actor_map (CLUTTER_ACTOR (priv->content_group));
-}
-
-
-static void
-unmap (ClutterActor *self)
-{
- ChamplainLicensePrivate *priv = GET_PRIVATE (self);
-
- CLUTTER_ACTOR_CLASS (champlain_license_parent_class)->unmap (self);
-
- clutter_actor_unmap (CLUTTER_ACTOR (priv->content_group));
-}
-
-
-static void
redraw_license (ChamplainLicense *license)
{
ChamplainLicensePrivate *priv = license->priv;
@@ -262,12 +168,6 @@ champlain_license_dispose (GObject *object)
{
ChamplainLicensePrivate *priv = CHAMPLAIN_LICENSE (object)->priv;
- if (priv->content_group)
- {
- clutter_actor_unparent (CLUTTER_ACTOR (priv->content_group));
- priv->content_group = NULL;
- }
-
priv->license_actor = NULL;
if (priv->view)
@@ -294,7 +194,6 @@ champlain_license_finalize (GObject *object)
static void
champlain_license_class_init (ChamplainLicenseClass *klass)
{
- ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
g_type_class_add_private (klass, sizeof (ChamplainLicensePrivate));
@@ -304,14 +203,6 @@ champlain_license_class_init (ChamplainLicenseClass *klass)
object_class->get_property = champlain_license_get_property;
object_class->set_property = champlain_license_set_property;
- actor_class->get_preferred_width = get_preferred_width;
- actor_class->get_preferred_height = get_preferred_height;
- actor_class->allocate = allocate;
- actor_class->paint = paint;
- actor_class->pick = pick;
- actor_class->map = map;
- actor_class->unmap = unmap;
-
/**
* ChamplainLicense:extra-text:
*
@@ -356,14 +247,12 @@ champlain_license_init (ChamplainLicense *license)
priv->extra_text = NULL;
priv->view = NULL;
priv->alignment = PANGO_ALIGN_RIGHT;
- priv->content_group = CLUTTER_GROUP (clutter_group_new ());
- clutter_actor_set_parent (CLUTTER_ACTOR (priv->content_group), CLUTTER_ACTOR (license));
priv->license_actor = clutter_text_new ();
clutter_text_set_font_name (CLUTTER_TEXT (priv->license_actor), "sans 8");
clutter_text_set_line_alignment (CLUTTER_TEXT (priv->license_actor), priv->alignment);
clutter_actor_set_opacity (priv->license_actor, 128);
- clutter_container_add_actor (CLUTTER_CONTAINER (priv->content_group), priv->license_actor);
+ clutter_actor_add_child (CLUTTER_ACTOR (license), priv->license_actor);
clutter_actor_queue_relayout (CLUTTER_ACTOR (license));
}
diff --git a/champlain/champlain-marker-layer.c b/champlain/champlain-marker-layer.c
index 750b7cb..562008c 100644
--- a/champlain/champlain-marker-layer.c
+++ b/champlain/champlain-marker-layer.c
@@ -33,7 +33,6 @@
#include "champlain-enum-types.h"
#include "champlain-private.h"
#include "champlain-view.h"
-#include "champlain-group.h"
#include <clutter/clutter.h>
#include <glib.h>
@@ -60,8 +59,6 @@ struct _ChamplainMarkerLayerPrivate
{
ChamplainSelectionMode mode;
ChamplainView *view;
-
- ChamplainGroup *content_group;
};
@@ -117,99 +114,6 @@ champlain_marker_layer_set_property (GObject *object,
static void
-paint (ClutterActor *self)
-{
- ChamplainMarkerLayerPrivate *priv = GET_PRIVATE (self);
-
- clutter_actor_paint (CLUTTER_ACTOR (priv->content_group));
-}
-
-
-static void
-pick (ClutterActor *self,
- const ClutterColor *color)
-{
- ChamplainMarkerLayerPrivate *priv = GET_PRIVATE (self);
-
- CLUTTER_ACTOR_CLASS (champlain_marker_layer_parent_class)->pick (self, color);
-
- clutter_actor_paint (CLUTTER_ACTOR (priv->content_group));
-}
-
-
-static void
-get_preferred_width (ClutterActor *self,
- gfloat for_height,
- gfloat *min_width_p,
- gfloat *natural_width_p)
-{
- ChamplainMarkerLayerPrivate *priv = GET_PRIVATE (self);
-
- clutter_actor_get_preferred_width (CLUTTER_ACTOR (priv->content_group),
- for_height,
- min_width_p,
- natural_width_p);
-}
-
-
-static void
-get_preferred_height (ClutterActor *self,
- gfloat for_width,
- gfloat *min_height_p,
- gfloat *natural_height_p)
-{
- ChamplainMarkerLayerPrivate *priv = GET_PRIVATE (self);
-
- clutter_actor_get_preferred_height (CLUTTER_ACTOR (priv->content_group),
- for_width,
- min_height_p,
- natural_height_p);
-}
-
-
-static void
-allocate (ClutterActor *self,
- const ClutterActorBox *box,
- ClutterAllocationFlags flags)
-{
- ClutterActorBox child_box;
-
- ChamplainMarkerLayerPrivate *priv = GET_PRIVATE (self);
-
- CLUTTER_ACTOR_CLASS (champlain_marker_layer_parent_class)->allocate (self, box, flags);
-
- child_box.x1 = 0;
- child_box.x2 = box->x2 - box->x1;
- child_box.y1 = 0;
- child_box.y2 = box->y2 - box->y1;
-
- clutter_actor_allocate (CLUTTER_ACTOR (priv->content_group), &child_box, flags);
-}
-
-
-static void
-map (ClutterActor *self)
-{
- ChamplainMarkerLayerPrivate *priv = GET_PRIVATE (self);
-
- CLUTTER_ACTOR_CLASS (champlain_marker_layer_parent_class)->map (self);
-
- clutter_actor_map (CLUTTER_ACTOR (priv->content_group));
-}
-
-
-static void
-unmap (ClutterActor *self)
-{
- ChamplainMarkerLayerPrivate *priv = GET_PRIVATE (self);
-
- CLUTTER_ACTOR_CLASS (champlain_marker_layer_parent_class)->unmap (self);
-
- clutter_actor_unmap (CLUTTER_ACTOR (priv->content_group));
-}
-
-
-static void
champlain_marker_layer_dispose (GObject *object)
{
ChamplainMarkerLayer *self = CHAMPLAIN_MARKER_LAYER (object);
@@ -218,13 +122,6 @@ champlain_marker_layer_dispose (GObject *object)
if (priv->view != NULL)
set_view (CHAMPLAIN_LAYER (self), NULL);
- if (priv->content_group)
- {
- champlain_marker_layer_remove_all (CHAMPLAIN_MARKER_LAYER (object));
- clutter_actor_unparent (CLUTTER_ACTOR (priv->content_group));
- priv->content_group = NULL;
- }
-
G_OBJECT_CLASS (champlain_marker_layer_parent_class)->dispose (object);
}
@@ -239,7 +136,6 @@ champlain_marker_layer_finalize (GObject *object)
static void
champlain_marker_layer_class_init (ChamplainMarkerLayerClass *klass)
{
- ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
ChamplainLayerClass *layer_class = CHAMPLAIN_LAYER_CLASS (klass);
@@ -250,14 +146,6 @@ champlain_marker_layer_class_init (ChamplainMarkerLayerClass *klass)
object_class->get_property = champlain_marker_layer_get_property;
object_class->set_property = champlain_marker_layer_set_property;
- actor_class->get_preferred_width = get_preferred_width;
- actor_class->get_preferred_height = get_preferred_height;
- actor_class->allocate = allocate;
- actor_class->paint = paint;
- actor_class->pick = pick;
- actor_class->map = map;
- actor_class->unmap = unmap;
-
layer_class->set_view = set_view;
layer_class->get_bounding_box = get_bounding_box;
@@ -288,10 +176,6 @@ champlain_marker_layer_init (ChamplainMarkerLayer *self)
priv = self->priv;
priv->mode = CHAMPLAIN_SELECTION_NONE;
priv->view = NULL;
-
- priv->content_group = CHAMPLAIN_GROUP (champlain_group_new ());
- clutter_actor_set_parent (CLUTTER_ACTOR (priv->content_group), CLUTTER_ACTOR (self));
- clutter_actor_queue_relayout (CLUTTER_ACTOR (self));
}
@@ -333,11 +217,10 @@ set_selected_all_but_one (ChamplainMarkerLayer *layer,
ChamplainMarker *not_selected,
gboolean select)
{
- ChamplainMarkerLayerPrivate *priv = layer->priv;
GList *elem;
GList *markers;
- markers = clutter_container_get_children (CLUTTER_CONTAINER (priv->content_group));
+ markers = clutter_actor_get_children (CLUTTER_ACTOR (layer));
for (elem = markers; elem != NULL; elem = elem->next)
{
@@ -438,8 +321,6 @@ void
champlain_marker_layer_add_marker (ChamplainMarkerLayer *layer,
ChamplainMarker *marker)
{
- ChamplainMarkerLayerPrivate *priv = layer->priv;
-
g_return_if_fail (CHAMPLAIN_IS_MARKER_LAYER (layer));
g_return_if_fail (CHAMPLAIN_IS_MARKER (marker));
@@ -454,7 +335,7 @@ champlain_marker_layer_add_marker (ChamplainMarkerLayer *layer,
g_signal_connect (G_OBJECT (marker), "drag-motion",
G_CALLBACK (marker_move_by_cb), layer);
- clutter_container_add_actor (CLUTTER_CONTAINER (priv->content_group), CLUTTER_ACTOR (marker));
+ clutter_actor_add_child (CLUTTER_ACTOR (layer), CLUTTER_ACTOR (marker));
set_marker_position (layer, marker);
}
@@ -470,13 +351,12 @@ champlain_marker_layer_add_marker (ChamplainMarkerLayer *layer,
void
champlain_marker_layer_remove_all (ChamplainMarkerLayer *layer)
{
- ChamplainMarkerLayerPrivate *priv = layer->priv;
GList *elem;
GList *markers;
g_return_if_fail (CHAMPLAIN_IS_MARKER_LAYER (layer));
- markers = clutter_container_get_children (CLUTTER_CONTAINER (priv->content_group));
+ markers = clutter_actor_get_children (CLUTTER_ACTOR (layer));
for (elem = markers; elem != NULL; elem = elem->next)
{
@@ -492,7 +372,7 @@ champlain_marker_layer_remove_all (ChamplainMarkerLayer *layer)
G_CALLBACK (marker_move_by_cb), layer);
}
- champlain_group_remove_all (CHAMPLAIN_GROUP (priv->content_group));
+ clutter_actor_remove_all_children (CLUTTER_ACTOR (layer));
g_list_free (markers);
}
@@ -511,10 +391,9 @@ champlain_marker_layer_remove_all (ChamplainMarkerLayer *layer)
GList *
champlain_marker_layer_get_markers (ChamplainMarkerLayer *layer)
{
- ChamplainMarkerLayerPrivate *priv = layer->priv;
GList *lst;
- lst = clutter_container_get_children (CLUTTER_CONTAINER (priv->content_group));
+ lst = clutter_actor_get_children (CLUTTER_ACTOR (layer));
return g_list_reverse (lst);
}
@@ -532,14 +411,13 @@ champlain_marker_layer_get_markers (ChamplainMarkerLayer *layer)
GList *
champlain_marker_layer_get_selected (ChamplainMarkerLayer *layer)
{
- ChamplainMarkerLayerPrivate *priv = layer->priv;
GList *elem;
GList *markers;
GList *selected = NULL;
g_return_val_if_fail (CHAMPLAIN_IS_MARKER_LAYER (layer), NULL);
- markers = clutter_container_get_children (CLUTTER_CONTAINER (priv->content_group));
+ markers = clutter_actor_get_children (CLUTTER_ACTOR (layer));
for (elem = markers; elem != NULL; elem = elem->next)
{
@@ -568,8 +446,6 @@ void
champlain_marker_layer_remove_marker (ChamplainMarkerLayer *layer,
ChamplainMarker *marker)
{
- ChamplainMarkerLayerPrivate *priv = layer->priv;
-
g_return_if_fail (CHAMPLAIN_IS_MARKER_LAYER (layer));
g_return_if_fail (CHAMPLAIN_IS_MARKER (marker));
@@ -582,7 +458,7 @@ champlain_marker_layer_remove_marker (ChamplainMarkerLayer *layer,
g_signal_handlers_disconnect_by_func (marker,
G_CALLBACK (marker_move_by_cb), layer);
- clutter_container_remove_actor (CLUTTER_CONTAINER (priv->content_group), CLUTTER_ACTOR (marker));
+ clutter_actor_remove_child (CLUTTER_ACTOR (layer), CLUTTER_ACTOR (marker));
}
@@ -597,14 +473,13 @@ champlain_marker_layer_remove_marker (ChamplainMarkerLayer *layer,
void
champlain_marker_layer_animate_in_all_markers (ChamplainMarkerLayer *layer)
{
- ChamplainMarkerLayerPrivate *priv = layer->priv;
GList *elem;
guint delay = 0;
GList *markers;
g_return_if_fail (CHAMPLAIN_IS_MARKER_LAYER (layer));
- markers = clutter_container_get_children (CLUTTER_CONTAINER (priv->content_group));
+ markers = clutter_actor_get_children (CLUTTER_ACTOR (layer));
for (elem = markers; elem != NULL; elem = elem->next)
{
@@ -629,14 +504,13 @@ champlain_marker_layer_animate_in_all_markers (ChamplainMarkerLayer *layer)
void
champlain_marker_layer_animate_out_all_markers (ChamplainMarkerLayer *layer)
{
- ChamplainMarkerLayerPrivate *priv = layer->priv;
GList *elem;
guint delay = 0;
GList *markers;
g_return_if_fail (CHAMPLAIN_IS_MARKER_LAYER (layer));
- markers = clutter_container_get_children (CLUTTER_CONTAINER (priv->content_group));
+ markers = clutter_actor_get_children (CLUTTER_ACTOR (layer));
for (elem = markers; elem != NULL; elem = elem->next)
{
@@ -661,13 +535,12 @@ champlain_marker_layer_animate_out_all_markers (ChamplainMarkerLayer *layer)
void
champlain_marker_layer_show_all_markers (ChamplainMarkerLayer *layer)
{
- ChamplainMarkerLayerPrivate *priv = layer->priv;
GList *elem;
GList *markers;
g_return_if_fail (CHAMPLAIN_IS_MARKER_LAYER (layer));
- markers = clutter_container_get_children (CLUTTER_CONTAINER (priv->content_group));
+ markers = clutter_actor_get_children (CLUTTER_ACTOR (layer));
for (elem = markers; elem != NULL; elem = elem->next)
{
@@ -691,13 +564,12 @@ champlain_marker_layer_show_all_markers (ChamplainMarkerLayer *layer)
void
champlain_marker_layer_hide_all_markers (ChamplainMarkerLayer *layer)
{
- ChamplainMarkerLayerPrivate *priv = layer->priv;
GList *elem;
GList *markers;
g_return_if_fail (CHAMPLAIN_IS_MARKER_LAYER (layer));
- markers = clutter_container_get_children (CLUTTER_CONTAINER (priv->content_group));
+ markers = clutter_actor_get_children (CLUTTER_ACTOR (layer));
for (elem = markers; elem != NULL; elem = elem->next)
{
@@ -721,13 +593,12 @@ champlain_marker_layer_hide_all_markers (ChamplainMarkerLayer *layer)
void
champlain_marker_layer_set_all_markers_draggable (ChamplainMarkerLayer *layer)
{
- ChamplainMarkerLayerPrivate *priv = layer->priv;
GList *elem;
GList *markers;
g_return_if_fail (CHAMPLAIN_IS_MARKER_LAYER (layer));
- markers = clutter_container_get_children (CLUTTER_CONTAINER (priv->content_group));
+ markers = clutter_actor_get_children (CLUTTER_ACTOR (layer));
for (elem = markers; elem != NULL; elem = elem->next)
{
@@ -751,13 +622,12 @@ champlain_marker_layer_set_all_markers_draggable (ChamplainMarkerLayer *layer)
void
champlain_marker_layer_set_all_markers_undraggable (ChamplainMarkerLayer *layer)
{
- ChamplainMarkerLayerPrivate *priv = layer->priv;
GList *elem;
GList *markers;
g_return_if_fail (CHAMPLAIN_IS_MARKER_LAYER (layer));
- markers = clutter_container_get_children (CLUTTER_CONTAINER (priv->content_group));
+ markers = clutter_actor_get_children (CLUTTER_ACTOR (layer));
for (elem = markers; elem != NULL; elem = elem->next)
{
@@ -856,13 +726,12 @@ relocate (ChamplainMarkerLayer *layer)
{
g_return_if_fail (CHAMPLAIN_IS_MARKER_LAYER (layer));
- ChamplainMarkerLayerPrivate *priv = layer->priv;
GList *elem;
GList *markers;
g_return_if_fail (CHAMPLAIN_IS_MARKER_LAYER (layer));
- markers = clutter_container_get_children (CLUTTER_CONTAINER (priv->content_group));
+ markers = clutter_actor_get_children (CLUTTER_ACTOR (layer));
for (elem = markers; elem != NULL; elem = elem->next)
{
@@ -917,7 +786,6 @@ set_view (ChamplainLayer *layer,
static ChamplainBoundingBox *
get_bounding_box (ChamplainLayer *layer)
{
- ChamplainMarkerLayerPrivate *priv = GET_PRIVATE (layer);
GList *elem;
ChamplainBoundingBox *bbox;
GList *markers;
@@ -926,7 +794,7 @@ get_bounding_box (ChamplainLayer *layer)
bbox = champlain_bounding_box_new ();
- markers = clutter_container_get_children (CLUTTER_CONTAINER (priv->content_group));
+ markers = clutter_actor_get_children (CLUTTER_ACTOR (layer));
for (elem = markers; elem != NULL; elem = elem->next)
{
diff --git a/champlain/champlain-marker.c b/champlain/champlain-marker.c
index ec69989..01ed53b 100644
--- a/champlain/champlain-marker.c
+++ b/champlain/champlain-marker.c
@@ -29,7 +29,7 @@
* it what ever you want. Set the markers position
* on the map using #champlain_location_set_location.
*
- * This is a base abstract class of all markers. libchamplain has a more evoluted
+ * This is a base class of all markers. libchamplain has a more evoluted
* type of markers with text and image support. See #ChamplainLabel for more details.
*/
@@ -84,7 +84,7 @@ static gdouble get_longitude (ChamplainLocation *location);
static void location_interface_init (ChamplainLocationIface *iface);
-G_DEFINE_ABSTRACT_TYPE_WITH_CODE (ChamplainMarker, champlain_marker, CLUTTER_TYPE_ACTOR,
+G_DEFINE_TYPE_WITH_CODE (ChamplainMarker, champlain_marker, CLUTTER_TYPE_ACTOR,
G_IMPLEMENT_INTERFACE (CHAMPLAIN_TYPE_LOCATION, location_interface_init));
#define GET_PRIVATE(obj) \
@@ -465,6 +465,22 @@ champlain_marker_class_init (ChamplainMarkerClass *marker_class)
}
+/**
+ * champlain_marker_new:
+ *
+ * Creates an instance of #ChamplainMarker.
+ *
+ * Returns: a new #ChamplainMarker.
+ *
+ * Since: 0.12.4
+ */
+ClutterActor *
+champlain_marker_new (void)
+{
+ return CLUTTER_ACTOR (g_object_new (CHAMPLAIN_TYPE_MARKER, NULL));
+}
+
+
static gboolean
motion_event_cb (ClutterActor *stage,
ClutterMotionEvent *event,
@@ -581,7 +597,12 @@ button_press_event_cb (ClutterActor *actor,
champlain_marker_set_selected (marker, TRUE);
if (priv->selectable || priv->draggable)
- clutter_actor_raise (CLUTTER_ACTOR (marker), NULL);
+ {
+ ClutterActor *parent;
+
+ parent = clutter_actor_get_parent (CLUTTER_ACTOR (marker));
+ clutter_actor_set_child_above_sibling (parent, CLUTTER_ACTOR (marker), NULL);
+ }
g_signal_emit_by_name (marker, "button-press", event);
@@ -761,7 +782,6 @@ void
champlain_marker_animate_in_with_delay (ChamplainMarker *marker,
guint delay)
{
- ClutterTimeline *timeline;
gfloat y;
g_return_if_fail (CHAMPLAIN_IS_MARKER (marker));
@@ -771,17 +791,15 @@ champlain_marker_animate_in_with_delay (ChamplainMarker *marker,
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);
-
- 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);
+
+ clutter_actor_save_easing_state (CLUTTER_ACTOR (marker));
+ clutter_actor_set_easing_delay (CLUTTER_ACTOR (marker), delay);
+ clutter_actor_set_easing_mode (CLUTTER_ACTOR (marker), CLUTTER_EASE_OUT_BOUNCE);
+ clutter_actor_set_easing_duration (CLUTTER_ACTOR (marker), 1000);
+ clutter_actor_set_opacity (CLUTTER_ACTOR (marker), 255);
+ clutter_actor_set_scale (CLUTTER_ACTOR (marker), 1.0, 1.0);
+ clutter_actor_set_y (CLUTTER_ACTOR (marker), y);
+ clutter_actor_restore_easing_state (CLUTTER_ACTOR (marker));
}
@@ -801,12 +819,14 @@ champlain_marker_animate_out (ChamplainMarker *marker)
static void
-on_animation_completed (G_GNUC_UNUSED ClutterAnimation *animation,
- ChamplainMarker *marker)
+on_transition_stopped (ClutterActor *marker,
+ const gchar *transition_name,
+ gboolean is_finished)
{
- clutter_actor_hide (CLUTTER_ACTOR (marker));
+ clutter_actor_hide (marker);
- clutter_actor_move_by (CLUTTER_ACTOR (marker), 0, 100);
+ clutter_actor_move_by (marker, 0, 100);
+ g_signal_handlers_disconnect_by_func (marker, on_transition_stopped, NULL);
}
@@ -824,8 +844,6 @@ void
champlain_marker_animate_out_with_delay (ChamplainMarker *marker,
guint delay)
{
- ClutterAnimation *animation;
- ClutterTimeline *timeline;
gfloat y;
g_return_if_fail (CHAMPLAIN_IS_MARKER (marker));
@@ -833,16 +851,17 @@ champlain_marker_animate_out_with_delay (ChamplainMarker *marker,
clutter_actor_get_position (CLUTTER_ACTOR (marker), NULL, &y);
clutter_actor_set_opacity (CLUTTER_ACTOR (marker), 200);
- 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_after (animation, "completed",
- G_CALLBACK (on_animation_completed), marker);
+ clutter_actor_save_easing_state (CLUTTER_ACTOR (marker));
+ clutter_actor_set_easing_delay (CLUTTER_ACTOR (marker), delay);
+ clutter_actor_set_easing_mode (CLUTTER_ACTOR (marker), CLUTTER_EASE_IN_BACK);
+ clutter_actor_set_easing_duration (CLUTTER_ACTOR (marker), 750);
+ clutter_actor_set_opacity (CLUTTER_ACTOR (marker), 0);
+ clutter_actor_set_scale (CLUTTER_ACTOR (marker), 2.0, 2.0);
+ clutter_actor_set_y (CLUTTER_ACTOR (marker), y - 100);
+ clutter_actor_restore_easing_state (CLUTTER_ACTOR (marker));
+
+ g_signal_connect (CLUTTER_ACTOR (marker),
+ "transition-stopped::opacity",
+ G_CALLBACK (on_transition_stopped),
+ NULL);
}
diff --git a/champlain/champlain-marker.h b/champlain/champlain-marker.h
index 6cca8d1..204d286 100644
--- a/champlain/champlain-marker.h
+++ b/champlain/champlain-marker.h
@@ -78,6 +78,8 @@ struct _ChamplainMarkerClass
GType champlain_marker_get_type (void);
+ClutterActor *champlain_marker_new (void);
+
void champlain_marker_set_selectable (ChamplainMarker *marker,
gboolean value);
gboolean champlain_marker_get_selectable (ChamplainMarker *marker);
diff --git a/champlain/champlain-memphis-renderer.c b/champlain/champlain-memphis-renderer.c
index 15ed6d0..0e7e40e 100644
--- a/champlain/champlain-memphis-renderer.c
+++ b/champlain/champlain-memphis-renderer.c
@@ -312,12 +312,12 @@ tile_loaded_cb (gpointer worker_data)
gpointer ret_data = NULL;
guint ret_size = 0;
gboolean ret_error = TRUE;
- cairo_t *cr_clutter;
ClutterActor *actor;
guint size = data->size;
GdkPixbuf *pixbuf = NULL;
gchar *buffer = NULL;
gsize buffer_size;
+ ClutterContent *content;
g_slice_free (WorkerThreadData, data);
@@ -330,14 +330,6 @@ tile_loaded_cb (gpointer worker_data)
if (!cst)
goto finish;
- /* draw the clutter texture */
- actor = clutter_cairo_texture_new (size, size);
-
- cr_clutter = clutter_cairo_texture_create (CLUTTER_CAIRO_TEXTURE (actor));
- cairo_set_source_surface (cr_clutter, cst, 0, 0);
- cairo_paint (cr_clutter);
- cairo_destroy (cr_clutter);
-
/* modify directly the buffer of cairo surface - we don't use it any more
and we close the surface anyway */
argb_to_rgba (cairo_image_surface_get_data (cst),
@@ -349,6 +341,26 @@ tile_loaded_cb (gpointer worker_data)
if (!gdk_pixbuf_save_to_buffer (pixbuf, &buffer, &buffer_size, "png", NULL, NULL))
goto finish;
+
+ content = clutter_image_new ();
+ if (!clutter_image_set_data (CLUTTER_IMAGE (content),
+ gdk_pixbuf_get_pixels (pixbuf),
+ gdk_pixbuf_get_has_alpha (pixbuf)
+ ? COGL_PIXEL_FORMAT_RGBA_8888
+ : COGL_PIXEL_FORMAT_RGB_888,
+ gdk_pixbuf_get_width (pixbuf),
+ gdk_pixbuf_get_height (pixbuf),
+ gdk_pixbuf_get_rowstride (pixbuf),
+ NULL))
+ {
+ g_object_unref (content);
+ goto finish;
+ }
+
+ actor = clutter_actor_new ();
+ clutter_actor_set_size (actor, size, size);
+ clutter_actor_set_content (actor, content);
+ g_object_unref (content);
champlain_tile_set_content (tile, actor);
diff --git a/champlain/champlain-path-layer.c b/champlain/champlain-path-layer.c
index fe62ea2..4984ceb 100644
--- a/champlain/champlain-path-layer.c
+++ b/champlain/champlain-path-layer.c
@@ -37,7 +37,6 @@
#include "champlain-enum-types.h"
#include "champlain-private.h"
#include "champlain-view.h"
-#include "champlain-group.h"
#include <clutter/clutter.h>
#include <glib.h>
@@ -83,16 +82,18 @@ struct _ChamplainPathLayerPrivate
gboolean visible;
gdouble *dash;
guint num_dashes;
-
- ClutterGroup *content_group;
+
+ ClutterContent *canvas;
ClutterActor *path_actor;
GList *nodes;
- gboolean redraw_scheduled;
};
-static gboolean redraw_path (ChamplainPathLayer *layer);
-static void schedule_redraw (ChamplainPathLayer *layer);
+static gboolean redraw_path (ClutterCanvas *canvas,
+ cairo_t *cr,
+ int w,
+ int h,
+ ChamplainPathLayer *layer);
static void set_view (ChamplainLayer *layer,
ChamplainView *view);
@@ -195,99 +196,6 @@ champlain_path_layer_set_property (GObject *object,
static void
-paint (ClutterActor *self)
-{
- ChamplainPathLayerPrivate *priv = GET_PRIVATE (self);
-
- clutter_actor_paint (CLUTTER_ACTOR (priv->content_group));
-}
-
-
-static void
-pick (ClutterActor *self,
- const ClutterColor *color)
-{
- ChamplainPathLayerPrivate *priv = GET_PRIVATE (self);
-
- CLUTTER_ACTOR_CLASS (champlain_path_layer_parent_class)->pick (self, color);
-
- clutter_actor_paint (CLUTTER_ACTOR (priv->content_group));
-}
-
-
-static void
-get_preferred_width (ClutterActor *self,
- gfloat for_height,
- gfloat *min_width_p,
- gfloat *natural_width_p)
-{
- ChamplainPathLayerPrivate *priv = GET_PRIVATE (self);
-
- clutter_actor_get_preferred_width (CLUTTER_ACTOR (priv->content_group),
- for_height,
- min_width_p,
- natural_width_p);
-}
-
-
-static void
-get_preferred_height (ClutterActor *self,
- gfloat for_width,
- gfloat *min_height_p,
- gfloat *natural_height_p)
-{
- ChamplainPathLayerPrivate *priv = GET_PRIVATE (self);
-
- clutter_actor_get_preferred_height (CLUTTER_ACTOR (priv->content_group),
- for_width,
- min_height_p,
- natural_height_p);
-}
-
-
-static void
-allocate (ClutterActor *self,
- const ClutterActorBox *box,
- ClutterAllocationFlags flags)
-{
- ClutterActorBox child_box;
-
- ChamplainPathLayerPrivate *priv = GET_PRIVATE (self);
-
- CLUTTER_ACTOR_CLASS (champlain_path_layer_parent_class)->allocate (self, box, flags);
-
- child_box.x1 = 0;
- child_box.x2 = box->x2 - box->x1;
- child_box.y1 = 0;
- child_box.y2 = box->y2 - box->y1;
-
- clutter_actor_allocate (CLUTTER_ACTOR (priv->content_group), &child_box, flags);
-}
-
-
-static void
-map (ClutterActor *self)
-{
- ChamplainPathLayerPrivate *priv = GET_PRIVATE (self);
-
- CLUTTER_ACTOR_CLASS (champlain_path_layer_parent_class)->map (self);
-
- clutter_actor_map (CLUTTER_ACTOR (priv->content_group));
-}
-
-
-static void
-unmap (ClutterActor *self)
-{
- ChamplainPathLayerPrivate *priv = GET_PRIVATE (self);
-
- CLUTTER_ACTOR_CLASS (champlain_path_layer_parent_class)->unmap (self);
-
- clutter_actor_unmap (CLUTTER_ACTOR (priv->content_group));
-}
-
-
-static void
champlain_path_layer_dispose (GObject *object)
{
ChamplainPathLayer *self = CHAMPLAIN_PATH_LAYER (object);
@@ -299,10 +207,10 @@ champlain_path_layer_dispose (GObject *object)
if (priv->view != NULL)
set_view (CHAMPLAIN_LAYER (self), NULL);
- if (priv->content_group)
+ if (priv->canvas)
{
- clutter_actor_unparent (CLUTTER_ACTOR (priv->content_group));
- priv->content_group = NULL;
+ g_object_unref (priv->canvas);
+ priv->canvas = NULL;
}
G_OBJECT_CLASS (champlain_path_layer_parent_class)->dispose (object);
@@ -326,7 +234,6 @@ champlain_path_layer_finalize (GObject *object)
static void
champlain_path_layer_class_init (ChamplainPathLayerClass *klass)
{
- ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
ChamplainLayerClass *layer_class = CHAMPLAIN_LAYER_CLASS (klass);
@@ -337,14 +244,6 @@ champlain_path_layer_class_init (ChamplainPathLayerClass *klass)
object_class->get_property = champlain_path_layer_get_property;
object_class->set_property = champlain_path_layer_set_property;
- actor_class->get_preferred_width = get_preferred_width;
- actor_class->get_preferred_height = get_preferred_height;
- actor_class->allocate = allocate;
- actor_class->paint = paint;
- actor_class->pick = pick;
- actor_class->map = map;
- actor_class->unmap = unmap;
-
layer_class->set_view = set_view;
layer_class->get_bounding_box = get_bounding_box;
@@ -471,20 +370,20 @@ champlain_path_layer_init (ChamplainPathLayer *self)
priv->stroke = TRUE;
priv->stroke_width = 2.0;
priv->nodes = NULL;
- priv->redraw_scheduled = FALSE;
priv->dash = NULL;
priv->num_dashes = 0;
priv->fill_color = clutter_color_copy (&DEFAULT_FILL_COLOR);
priv->stroke_color = clutter_color_copy (&DEFAULT_STROKE_COLOR);
- priv->content_group = CLUTTER_GROUP (clutter_group_new ());
- clutter_actor_set_parent (CLUTTER_ACTOR (priv->content_group), CLUTTER_ACTOR (self));
-
- priv->path_actor = clutter_cairo_texture_new (256, 256);
- clutter_container_add_actor (CLUTTER_CONTAINER (priv->content_group), priv->path_actor);
+ priv->canvas = clutter_canvas_new ();
+ clutter_canvas_set_size (CLUTTER_CANVAS (priv->canvas), 255, 255);
+ g_signal_connect (priv->canvas, "draw", G_CALLBACK (redraw_path), self);
- clutter_actor_queue_relayout (CLUTTER_ACTOR (self));
+ priv->path_actor = clutter_actor_new ();
+ clutter_actor_set_size (priv->path_actor, 255, 255);
+ clutter_actor_set_content (priv->path_actor, priv->canvas);
+ clutter_actor_add_child (CLUTTER_ACTOR (self), priv->path_actor);
}
@@ -505,11 +404,28 @@ champlain_path_layer_new ()
static void
+invalidate_canvas (ChamplainPathLayer *layer)
+{
+ ChamplainPathLayerPrivate *priv = layer->priv;
+ gfloat width, height;
+
+ width = 256;
+ height = 256;
+ if (priv->view != NULL)
+ clutter_actor_get_size (CLUTTER_ACTOR (priv->view), &width, &height);
+
+ clutter_canvas_set_size (CLUTTER_CANVAS (priv->canvas), width, height);
+ clutter_actor_set_size (priv->path_actor, width, height);
+ clutter_content_invalidate (priv->canvas);
+}
+
+
+static void
position_notify (ChamplainLocation *location,
G_GNUC_UNUSED GParamSpec *pspec,
ChamplainPathLayer *layer)
{
- schedule_redraw (layer);
+ invalidate_canvas (layer);
}
@@ -530,7 +446,7 @@ add_node (ChamplainPathLayer *layer,
priv->nodes = g_list_prepend (priv->nodes, location);
else
priv->nodes = g_list_insert (priv->nodes, location, position);
- schedule_redraw (layer);
+ invalidate_canvas (layer);
}
@@ -583,7 +499,7 @@ champlain_path_layer_remove_all (ChamplainPathLayer *layer)
g_list_free (priv->nodes);
priv->nodes = NULL;
- schedule_redraw (layer);
+ invalidate_canvas (layer);
}
@@ -631,7 +547,7 @@ champlain_path_layer_remove_node (ChamplainPathLayer *layer,
priv->nodes = g_list_remove (priv->nodes, location);
g_object_unref (location);
- schedule_redraw (layer);
+ invalidate_canvas (layer);
}
@@ -663,42 +579,32 @@ relocate_cb (G_GNUC_UNUSED GObject *gobject,
{
g_return_if_fail (CHAMPLAIN_IS_PATH_LAYER (layer));
- schedule_redraw (layer);
+ invalidate_canvas (layer);
}
static gboolean
-redraw_path (ChamplainPathLayer *layer)
+redraw_path (ClutterCanvas *canvas,
+ cairo_t *cr,
+ int width,
+ int height,
+ ChamplainPathLayer *layer)
{
ChamplainPathLayerPrivate *priv = layer->priv;
- cairo_t *cr;
- gfloat width, height;
GList *elem;
ChamplainView *view = priv->view;
gint x, y;
- guint last_width, last_height;
-
- priv->redraw_scheduled = FALSE;
-
+
/* layer not yet added to the view */
- if (view == NULL || !priv->content_group)
+ if (view == NULL)
return FALSE;
- clutter_actor_get_size (CLUTTER_ACTOR (view), &width, &height);
-
if (!priv->visible || width == 0.0 || height == 0.0)
return FALSE;
- clutter_cairo_texture_get_surface_size (CLUTTER_CAIRO_TEXTURE (priv->path_actor), &last_width,
&last_height);
-
- if ((guint) width != last_width || (guint) height != last_height)
- clutter_cairo_texture_set_surface_size (CLUTTER_CAIRO_TEXTURE (priv->path_actor), width, height);
-
champlain_view_get_viewport_origin (priv->view, &x, &y);
clutter_actor_set_position (priv->path_actor, x, y);
- cr = clutter_cairo_texture_create (CLUTTER_CAIRO_TEXTURE (priv->path_actor));
-
/* Clear the drawing area */
cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
cairo_paint (cr);
@@ -739,32 +645,16 @@ redraw_path (ChamplainPathLayer *layer)
if (priv->stroke)
cairo_stroke (cr);
- cairo_destroy (cr);
-
return FALSE;
}
static void
-schedule_redraw (ChamplainPathLayer *layer)
-{
- if (!layer->priv->redraw_scheduled)
- {
- layer->priv->redraw_scheduled = TRUE;
- g_idle_add_full (CLUTTER_PRIORITY_REDRAW,
- (GSourceFunc) redraw_path,
- g_object_ref (layer),
- (GDestroyNotify) g_object_unref);
- }
-}
-
-
-static void
redraw_path_cb (G_GNUC_UNUSED GObject *gobject,
G_GNUC_UNUSED GParamSpec *arg1,
ChamplainPathLayer *layer)
{
- schedule_redraw (layer);
+ invalidate_canvas (layer);
}
@@ -799,7 +689,7 @@ set_view (ChamplainLayer *layer,
g_signal_connect (view, "notify::latitude",
G_CALLBACK (redraw_path_cb), layer);
- schedule_redraw (path_layer);
+ invalidate_canvas (path_layer);
}
}
@@ -867,7 +757,7 @@ champlain_path_layer_set_fill_color (ChamplainPathLayer *layer,
priv->fill_color = clutter_color_copy (color);
g_object_notify (G_OBJECT (layer), "fill-color");
- schedule_redraw (layer);
+ invalidate_canvas (layer);
}
@@ -917,7 +807,7 @@ champlain_path_layer_set_stroke_color (ChamplainPathLayer *layer,
priv->stroke_color = clutter_color_copy (color);
g_object_notify (G_OBJECT (layer), "stroke-color");
- schedule_redraw (layer);
+ invalidate_canvas (layer);
}
@@ -958,7 +848,7 @@ champlain_path_layer_set_stroke (ChamplainPathLayer *layer,
layer->priv->stroke = value;
g_object_notify (G_OBJECT (layer), "stroke");
- schedule_redraw (layer);
+ invalidate_canvas (layer);
}
@@ -999,7 +889,7 @@ champlain_path_layer_set_fill (ChamplainPathLayer *layer,
layer->priv->fill = value;
g_object_notify (G_OBJECT (layer), "fill");
- schedule_redraw (layer);
+ invalidate_canvas (layer);
}
@@ -1040,7 +930,7 @@ champlain_path_layer_set_stroke_width (ChamplainPathLayer *layer,
layer->priv->stroke_width = value;
g_object_notify (G_OBJECT (layer), "stroke-width");
- schedule_redraw (layer);
+ invalidate_canvas (layer);
}
@@ -1124,7 +1014,7 @@ champlain_path_layer_set_closed (ChamplainPathLayer *layer,
layer->priv->closed_path = value;
g_object_notify (G_OBJECT (layer), "closed");
- schedule_redraw (layer);
+ invalidate_canvas (layer);
}
diff --git a/champlain/champlain-scale.c b/champlain/champlain-scale.c
index 1bc415e..45cea86 100644
--- a/champlain/champlain-scale.c
+++ b/champlain/champlain-scale.c
@@ -60,8 +60,7 @@ struct _ChamplainScalePrivate
ChamplainUnit scale_unit;
guint max_scale_width;
gfloat text_height;
- ClutterGroup *content_group;
- gboolean redraw_scheduled;
+ ClutterContent *canvas;
ChamplainView *view;
};
@@ -127,114 +126,21 @@ champlain_scale_set_property (GObject *object,
static void
-paint (ClutterActor *self)
-{
- ChamplainScalePrivate *priv = GET_PRIVATE (self);
-
- clutter_actor_paint (CLUTTER_ACTOR (priv->content_group));
-}
-
-
-static void
-pick (ClutterActor *self,
- const ClutterColor *color)
-{
- ChamplainScalePrivate *priv = GET_PRIVATE (self);
-
- CLUTTER_ACTOR_CLASS (champlain_scale_parent_class)->pick (self, color);
-
- clutter_actor_paint (CLUTTER_ACTOR (priv->content_group));
-}
-
-
-static void
-get_preferred_width (ClutterActor *self,
- gfloat for_height,
- gfloat *min_width_p,
- gfloat *natural_width_p)
-{
- ChamplainScalePrivate *priv = GET_PRIVATE (self);
-
- clutter_actor_get_preferred_width (CLUTTER_ACTOR (priv->content_group),
- for_height,
- min_width_p,
- natural_width_p);
-}
-
-
-static void
-get_preferred_height (ClutterActor *self,
- gfloat for_width,
- gfloat *min_height_p,
- gfloat *natural_height_p)
-{
- ChamplainScalePrivate *priv = GET_PRIVATE (self);
-
- clutter_actor_get_preferred_height (CLUTTER_ACTOR (priv->content_group),
- for_width,
- min_height_p,
- natural_height_p);
-}
-
-
-static void
-allocate (ClutterActor *self,
- const ClutterActorBox *box,
- ClutterAllocationFlags flags)
-{
- ClutterActorBox child_box;
-
- ChamplainScalePrivate *priv = GET_PRIVATE (self);
-
- CLUTTER_ACTOR_CLASS (champlain_scale_parent_class)->allocate (self, box, flags);
-
- child_box.x1 = 0;
- child_box.x2 = box->x2 - box->x1;
- child_box.y1 = 0;
- child_box.y2 = box->y2 - box->y1;
-
- clutter_actor_allocate (CLUTTER_ACTOR (priv->content_group), &child_box, flags);
-}
-
-
-static void
-map (ClutterActor *self)
-{
- ChamplainScalePrivate *priv = GET_PRIVATE (self);
-
- CLUTTER_ACTOR_CLASS (champlain_scale_parent_class)->map (self);
-
- clutter_actor_map (CLUTTER_ACTOR (priv->content_group));
-}
-
-
-static void
-unmap (ClutterActor *self)
-{
- ChamplainScalePrivate *priv = GET_PRIVATE (self);
-
- CLUTTER_ACTOR_CLASS (champlain_scale_parent_class)->unmap (self);
-
- clutter_actor_unmap (CLUTTER_ACTOR (priv->content_group));
-}
-
-
-static void
champlain_scale_dispose (GObject *object)
{
ChamplainScalePrivate *priv = CHAMPLAIN_SCALE (object)->priv;
- if (priv->content_group)
- {
- clutter_actor_unparent (CLUTTER_ACTOR (priv->content_group));
- priv->content_group = NULL;
- }
-
if (priv->view)
{
champlain_scale_disconnect_view (CHAMPLAIN_SCALE (object));
priv->view = NULL;
}
+
+ if (priv->canvas)
+ {
+ g_object_unref (priv->canvas);
+ priv->canvas = NULL;
+ }
G_OBJECT_CLASS (champlain_scale_parent_class)->dispose (object);
}
@@ -252,7 +158,6 @@ champlain_scale_finalize (GObject *object)
static void
champlain_scale_class_init (ChamplainScaleClass *klass)
{
- ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
g_type_class_add_private (klass, sizeof (ChamplainScalePrivate));
@@ -262,14 +167,6 @@ champlain_scale_class_init (ChamplainScaleClass *klass)
object_class->get_property = champlain_scale_get_property;
object_class->set_property = champlain_scale_set_property;
- actor_class->get_preferred_width = get_preferred_width;
- actor_class->get_preferred_height = get_preferred_height;
- actor_class->allocate = allocate;
- actor_class->paint = paint;
- actor_class->pick = pick;
- actor_class->map = map;
- actor_class->unmap = unmap;
-
/**
* ChamplainScale:max-width:
*
@@ -307,19 +204,19 @@ champlain_scale_class_init (ChamplainScaleClass *klass)
static gboolean
-redraw_scale (ChamplainScale *scale)
+redraw_scale (ClutterCanvas *canvas,
+ cairo_t *cr,
+ int w,
+ int h,
+ ChamplainScale *scale)
{
- static gfloat previous_m_per_pixel = 0.0;
- static gint previous_zoom_level = 0.0;
-
gboolean is_small_unit = TRUE; /* indicates if using meters */
- ClutterActor *text, *line;
+ ClutterActor *text;
gfloat width, height;
ChamplainScalePrivate *priv = scale->priv;
gfloat m_per_pixel;
gfloat scale_width = priv->max_scale_width;
gchar *label;
- cairo_t *cr;
gfloat base;
gfloat factor;
gboolean final_unit = FALSE;
@@ -328,9 +225,7 @@ redraw_scale (ChamplainScale *scale)
gfloat offset;
ChamplainMapSource *map_source;
- priv->redraw_scheduled = FALSE;
-
- if (!priv->view || !priv->content_group)
+ if (!priv->view)
return FALSE;
zoom_level = champlain_view_get_zoom_level (priv->view);
@@ -340,15 +235,6 @@ redraw_scale (ChamplainScale *scale)
m_per_pixel = champlain_map_source_get_meters_per_pixel (map_source,
zoom_level, lat, lon);
- /* Don't redraw too often, 1 meters difference is a good value
- * since at low levels the value changes alot, and not at high levels */
- if (fabs (m_per_pixel - previous_m_per_pixel) < 10 &&
- previous_zoom_level == zoom_level)
- return FALSE;
-
- previous_m_per_pixel = m_per_pixel;
- previous_zoom_level = zoom_level;
-
if (priv->scale_unit == CHAMPLAIN_UNIT_MILES)
m_per_pixel *= 3.28; /* m_per_pixel is now in ft */
@@ -393,7 +279,7 @@ redraw_scale (ChamplainScale *scale)
}
} while (!final_unit);
- text = clutter_container_find_child_by_name (CLUTTER_CONTAINER (priv->content_group), "scale-far-label");
+ text = clutter_container_find_child_by_name (CLUTTER_CONTAINER (scale), "scale-far-label");
label = g_strdup_printf ("%g", base);
/* Get only digits width for centering */
clutter_text_set_text (CLUTTER_TEXT (text), label);
@@ -408,7 +294,7 @@ redraw_scale (ChamplainScale *scale)
g_free (label);
clutter_actor_set_position (text, (scale_width - width / 2) + SCALE_INSIDE_PADDING, SCALE_INSIDE_PADDING);
- text = clutter_container_find_child_by_name (CLUTTER_CONTAINER (priv->content_group), "scale-mid-label");
+ text = clutter_container_find_child_by_name (CLUTTER_CONTAINER (scale), "scale-mid-label");
label = g_strdup_printf ("%g", base / 2.0);
clutter_text_set_text (CLUTTER_TEXT (text), label);
clutter_actor_get_size (text, &width, &height);
@@ -416,9 +302,6 @@ redraw_scale (ChamplainScale *scale)
g_free (label);
/* Draw the line */
- line = clutter_container_find_child_by_name (CLUTTER_CONTAINER (priv->content_group), "scale-line");
- cr = clutter_cairo_texture_create (CLUTTER_CAIRO_TEXTURE (line));
-
cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
cairo_paint (cr);
cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
@@ -449,53 +332,47 @@ redraw_scale (ChamplainScale *scale)
cairo_line_to (cr, scale_width + SCALE_INSIDE_PADDING, offset + SCALE_HEIGHT);
cairo_stroke (cr);
- cairo_destroy (cr);
-
return FALSE;
}
static void
-schedule_redraw (ChamplainScale *scale)
-{
- if (!scale->priv->redraw_scheduled)
- {
- scale->priv->redraw_scheduled = TRUE;
- g_idle_add_full (CLUTTER_PRIORITY_REDRAW,
- (GSourceFunc) redraw_scale,
- g_object_ref (scale),
- (GDestroyNotify) g_object_unref);
- }
-}
-
-
-static void
create_scale (ChamplainScale *scale)
{
- ClutterActor *scale_actor, *text;
- gfloat width;
+ ClutterActor *text, *scale_actor;
+ gfloat width, height;
ChamplainScalePrivate *priv = scale->priv;
- clutter_group_remove_all (priv->content_group);
+ clutter_actor_destroy_all_children (CLUTTER_ACTOR (scale));
text = clutter_text_new_with_text ("Sans 9", "X km");
clutter_actor_set_name (text, "scale-far-label");
- clutter_container_add_actor (CLUTTER_CONTAINER (priv->content_group), text);
+ clutter_actor_add_child (CLUTTER_ACTOR (scale), text);
text = clutter_text_new_with_text ("Sans 9", "X");
clutter_actor_set_name (text, "scale-mid-label");
- clutter_container_add_actor (CLUTTER_CONTAINER (priv->content_group), text);
+ clutter_actor_add_child (CLUTTER_ACTOR (scale), text);
text = clutter_text_new_with_text ("Sans 9", "0");
- clutter_container_add_actor (CLUTTER_CONTAINER (priv->content_group), text);
+ clutter_actor_add_child (CLUTTER_ACTOR (scale), text);
clutter_actor_get_size (text, &width, &priv->text_height);
clutter_actor_set_position (text, SCALE_INSIDE_PADDING - width / 2, SCALE_INSIDE_PADDING);
- scale_actor = clutter_cairo_texture_new (priv->max_scale_width + 2 * SCALE_INSIDE_PADDING, SCALE_HEIGHT +
priv->text_height + GAP_SIZE + 2 * SCALE_INSIDE_PADDING);
- clutter_actor_set_name (scale_actor, "scale-line");
- clutter_container_add_actor (CLUTTER_CONTAINER (priv->content_group), scale_actor);
+ width = priv->max_scale_width + 2 * SCALE_INSIDE_PADDING;
+ height = SCALE_HEIGHT + priv->text_height + GAP_SIZE + 2 * SCALE_INSIDE_PADDING;
+
+ priv->canvas = clutter_canvas_new ();
+ clutter_canvas_set_size (CLUTTER_CANVAS (priv->canvas), width, height);
+ g_signal_connect (priv->canvas, "draw", G_CALLBACK (redraw_scale), scale);
+
+ scale_actor = clutter_actor_new ();
+ clutter_actor_set_size (scale_actor, width, height);
+ clutter_actor_set_content (scale_actor, priv->canvas);
+ clutter_actor_add_child (CLUTTER_ACTOR (scale), scale_actor);
clutter_actor_set_opacity (CLUTTER_ACTOR (scale), 200);
+
+ clutter_content_invalidate (priv->canvas);
}
@@ -509,10 +386,6 @@ champlain_scale_init (ChamplainScale *scale)
priv->scale_unit = CHAMPLAIN_UNIT_KM;
priv->max_scale_width = 100;
priv->view = NULL;
- priv->redraw_scheduled = FALSE;
- priv->content_group = CLUTTER_GROUP (clutter_group_new ());
- clutter_actor_set_parent (CLUTTER_ACTOR (priv->content_group), CLUTTER_ACTOR (scale));
- clutter_actor_queue_relayout (CLUTTER_ACTOR (scale));
create_scale (scale);
}
@@ -552,7 +425,6 @@ champlain_scale_set_max_width (ChamplainScale *scale,
scale->priv->max_scale_width = value;
create_scale (scale);
g_object_notify (G_OBJECT (scale), "max-width");
- schedule_redraw (scale);
}
@@ -573,7 +445,7 @@ champlain_scale_set_unit (ChamplainScale *scale,
scale->priv->scale_unit = unit;
g_object_notify (G_OBJECT (scale), "unit");
- schedule_redraw (scale);
+ clutter_content_invalidate (scale->priv->canvas);
}
@@ -620,7 +492,7 @@ redraw_scale_cb (G_GNUC_UNUSED GObject *gobject,
G_GNUC_UNUSED GParamSpec *arg1,
ChamplainScale *scale)
{
- schedule_redraw (scale);
+ clutter_content_invalidate (scale->priv->canvas);
}
@@ -643,7 +515,7 @@ champlain_scale_connect_view (ChamplainScale *scale,
scale->priv->view = g_object_ref (view);
g_signal_connect (view, "notify::latitude",
G_CALLBACK (redraw_scale_cb), scale);
- schedule_redraw (scale);
+ clutter_content_invalidate (scale->priv->canvas);
}
diff --git a/champlain/champlain-tile.c b/champlain/champlain-tile.c
index 83a00e7..e4cf570 100644
--- a/champlain/champlain-tile.c
+++ b/champlain/champlain-tile.c
@@ -74,7 +74,6 @@ struct _ChamplainTilePrivate
ChamplainState state; /* The tile state: loading, validation, done */
/* The tile actor that will be displayed after champlain_tile_display_content () */
ClutterActor *content_actor;
- ClutterGroup *content_group; /* A group used for the fade in effect */
gboolean fade_in;
GTimeVal *modified_time; /* The last modified time of the cache */
@@ -179,99 +178,6 @@ champlain_tile_set_property (GObject *object,
static void
-paint (ClutterActor *self)
-{
- ChamplainTilePrivate *priv = GET_PRIVATE (self);
-
- clutter_actor_paint (CLUTTER_ACTOR (priv->content_group));
-}
-
-
-static void
-pick (ClutterActor *self,
- const ClutterColor *color)
-{
- ChamplainTilePrivate *priv = GET_PRIVATE (self);
-
- CLUTTER_ACTOR_CLASS (champlain_tile_parent_class)->pick (self, color);
-
- clutter_actor_paint (CLUTTER_ACTOR (priv->content_group));
-}
-
-
-static void
-get_preferred_width (ClutterActor *self,
- gfloat for_height,
- gfloat *min_width_p,
- gfloat *natural_width_p)
-{
- ChamplainTilePrivate *priv = GET_PRIVATE (self);
-
- clutter_actor_get_preferred_width (CLUTTER_ACTOR (priv->content_group),
- for_height,
- min_width_p,
- natural_width_p);
-}
-
-
-static void
-get_preferred_height (ClutterActor *self,
- gfloat for_width,
- gfloat *min_height_p,
- gfloat *natural_height_p)
-{
- ChamplainTilePrivate *priv = GET_PRIVATE (self);
-
- clutter_actor_get_preferred_height (CLUTTER_ACTOR (priv->content_group),
- for_width,
- min_height_p,
- natural_height_p);
-}
-
-
-static void
-allocate (ClutterActor *self,
- const ClutterActorBox *box,
- ClutterAllocationFlags flags)
-{
- ClutterActorBox child_box;
-
- ChamplainTilePrivate *priv = GET_PRIVATE (self);
-
- CLUTTER_ACTOR_CLASS (champlain_tile_parent_class)->allocate (self, box, flags);
-
- child_box.x1 = 0;
- child_box.x2 = box->x2 - box->x1;
- child_box.y1 = 0;
- child_box.y2 = box->y2 - box->y1;
-
- clutter_actor_allocate (CLUTTER_ACTOR (priv->content_group), &child_box, flags);
-}
-
-
-static void
-map (ClutterActor *self)
-{
- ChamplainTilePrivate *priv = GET_PRIVATE (self);
-
- CLUTTER_ACTOR_CLASS (champlain_tile_parent_class)->map (self);
-
- clutter_actor_map (CLUTTER_ACTOR (priv->content_group));
-}
-
-
-static void
-unmap (ClutterActor *self)
-{
- ChamplainTilePrivate *priv = GET_PRIVATE (self);
-
- CLUTTER_ACTOR_CLASS (champlain_tile_parent_class)->unmap (self);
-
- clutter_actor_unmap (CLUTTER_ACTOR (priv->content_group));
-}
-
-
-static void
champlain_tile_dispose (GObject *object)
{
ChamplainTilePrivate *priv = CHAMPLAIN_TILE (object)->priv;
@@ -282,12 +188,6 @@ champlain_tile_dispose (GObject *object)
priv->content_actor = NULL;
}
- if (priv->content_group)
- {
- clutter_actor_unparent (CLUTTER_ACTOR (priv->content_group));
- priv->content_group = NULL;
- }
-
G_OBJECT_CLASS (champlain_tile_parent_class)->dispose (object);
}
@@ -308,7 +208,6 @@ static void
champlain_tile_class_init (ChamplainTileClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
g_type_class_add_private (klass, sizeof (ChamplainTilePrivate));
@@ -317,14 +216,6 @@ champlain_tile_class_init (ChamplainTileClass *klass)
object_class->dispose = champlain_tile_dispose;
object_class->finalize = champlain_tile_finalize;
- actor_class->get_preferred_width = get_preferred_width;
- actor_class->get_preferred_height = get_preferred_height;
- actor_class->allocate = allocate;
- actor_class->paint = paint;
- actor_class->pick = pick;
- actor_class->map = map;
- actor_class->unmap = unmap;
-
/**
* ChamplainTile:x:
*
@@ -501,9 +392,6 @@ champlain_tile_init (ChamplainTile *self)
priv->content_displayed = FALSE;
priv->content_actor = NULL;
- priv->content_group = CLUTTER_GROUP (clutter_group_new ());
- clutter_actor_set_parent (CLUTTER_ACTOR (priv->content_group), CLUTTER_ACTOR (self));
- clutter_actor_queue_relayout (CLUTTER_ACTOR (self));
}
@@ -858,9 +746,6 @@ champlain_tile_set_content (ChamplainTile *self,
ChamplainTilePrivate *priv = self->priv;
- if (!priv->content_group)
- return;
-
if (!priv->content_displayed && priv->content_actor)
clutter_actor_destroy (priv->content_actor);
@@ -872,15 +757,15 @@ champlain_tile_set_content (ChamplainTile *self,
static void
-fade_in_completed (G_GNUC_UNUSED ClutterAnimation *animation, ChamplainTile *self)
+fade_in_completed (ClutterActor *actor,
+ const gchar *transition_name,
+ gboolean is_finished,
+ ChamplainTile *self)
{
- ChamplainTilePrivate *priv = self->priv;
-
- if (!priv->content_group)
- return;
+ if (clutter_actor_get_n_children (CLUTTER_ACTOR (self)) > 1)
+ clutter_actor_destroy (clutter_actor_get_first_child (CLUTTER_ACTOR (self)));
- if (clutter_group_get_n_children (CLUTTER_GROUP (priv->content_group)) > 1)
- clutter_actor_destroy (clutter_group_get_nth_child (CLUTTER_GROUP (priv->content_group), 0));
+ g_signal_handlers_disconnect_by_func (actor, fade_in_completed, self);
}
@@ -898,34 +783,30 @@ champlain_tile_display_content (ChamplainTile *self)
g_return_if_fail (CHAMPLAIN_TILE (self));
ChamplainTilePrivate *priv = self->priv;
- ClutterAnimation *animation;
- if (!priv->content_actor || priv->content_displayed || !priv->content_group)
+ if (!priv->content_actor || priv->content_displayed)
return;
- clutter_container_add_actor (CLUTTER_CONTAINER (priv->content_group), priv->content_actor);
+ clutter_actor_add_child (CLUTTER_ACTOR (self), priv->content_actor);
g_object_unref (priv->content_actor);
priv->content_displayed = TRUE;
- clutter_actor_set_opacity (CLUTTER_ACTOR (priv->content_actor), 0);
+ clutter_actor_set_opacity (priv->content_actor, 0);
+ clutter_actor_save_easing_state (priv->content_actor);
if (priv->fade_in)
{
- animation = clutter_actor_animate (CLUTTER_ACTOR (priv->content_actor),
- CLUTTER_EASE_IN_CUBIC,
- 500,
- "opacity", 255,
- NULL);
+ clutter_actor_set_easing_mode (priv->content_actor, CLUTTER_EASE_IN_CUBIC);
+ clutter_actor_set_easing_duration (priv->content_actor, 500);
}
else
{
- animation = clutter_actor_animate (CLUTTER_ACTOR (priv->content_actor),
- CLUTTER_LINEAR,
- 150,
- "opacity", 255,
- NULL);
+ clutter_actor_set_easing_mode (priv->content_actor, CLUTTER_LINEAR);
+ clutter_actor_set_easing_duration (priv->content_actor, 150);
}
+ clutter_actor_set_opacity (priv->content_actor, 255);
+ clutter_actor_restore_easing_state (priv->content_actor);
- g_signal_connect (animation, "completed", G_CALLBACK (fade_in_completed), self);
+ g_signal_connect (priv->content_actor, "transition-stopped::opacity", G_CALLBACK (fade_in_completed),
self);
}
diff --git a/champlain/champlain-view.c b/champlain/champlain-view.c
index 95e2e2c..4627efd 100644
--- a/champlain/champlain-view.c
+++ b/champlain/champlain-view.c
@@ -62,7 +62,6 @@
#include "champlain-private.h"
#include "champlain-tile.h"
#include "champlain-license.h"
-#include "champlain-group.h"
#include <clutter/clutter.h>
#include <glib.h>
@@ -121,7 +120,6 @@ static guint signals[LAST_SIGNAL] = { 0, };
typedef struct
{
ChamplainView *view;
- ClutterAlpha *alpha;
ClutterTimeline *timeline;
gdouble to_latitude;
gdouble to_longitude;
@@ -138,7 +136,6 @@ typedef struct
struct _ChamplainViewPrivate
{
- ClutterActor *view_box;
ClutterActor *kinetic_scroll; /* Contains the viewport */
ClutterActor *viewport; /* Contains the map_layer, license and markers */
ClutterActor *map_layer; /* Contains tiles actors (grouped by zoom level) */
@@ -149,8 +146,6 @@ struct _ChamplainViewPrivate
ClutterTexture *background_tile_actor;
- ClutterLayoutManager *layout_manager;
-
ChamplainMapSource *map_source; /* Current map tile source */
gboolean kinetic_mode;
guint zoom_level; /* Holds the current zoom level number */
@@ -188,7 +183,7 @@ struct _ChamplainViewPrivate
gint tiles_loading;
ClutterActor *zoom_overlay_actor;
- ClutterAnimation *zoom_animation;
+ gboolean animating_zoom;
guint anim_start_zoom_level;
gdouble zoom_actor_longitude;
gdouble zoom_actor_latitude;
@@ -568,12 +563,6 @@ champlain_view_dispose (GObject *object)
priv->map_source = NULL;
}
- if (priv->view_box != NULL)
- {
- clutter_actor_unparent (CLUTTER_ACTOR (priv->view_box));
- priv->view_box = NULL;
- }
-
if (priv->background_tile_actor)
{
clutter_actor_destroy (CLUTTER_ACTOR (priv->background_tile_actor));
@@ -584,7 +573,6 @@ champlain_view_dispose (GObject *object)
priv->license_actor = NULL;
priv->user_layers = NULL;
priv->zoom_layer = NULL;
- priv->layout_manager = NULL;
G_OBJECT_CLASS (champlain_view_parent_class)->dispose (object);
}
@@ -627,44 +615,6 @@ _update_idle_cb (ChamplainView *view)
static void
-champlain_view_allocate (ClutterActor *actor,
- const ClutterActorBox *box,
- ClutterAllocationFlags flags)
-{
- DEBUG_LOG ()
-
- ChamplainView *view = CHAMPLAIN_VIEW (actor);
- ChamplainViewPrivate *priv = view->priv;
- ClutterActorBox child_box;
- gint width, height;
-
- /* Chain up */
- CLUTTER_ACTOR_CLASS (champlain_view_parent_class)->allocate (actor, box, flags);
-
- width = box->x2 - box->x1;
- height = box->y2 - box->y1;
-
- if (priv->viewport_width != width || priv->viewport_height != height)
- {
- g_idle_add_full (CLUTTER_PRIORITY_REDRAW,
- (GSourceFunc) _update_idle_cb,
- g_object_ref (view),
- (GDestroyNotify) g_object_unref);
- }
-
- child_box.x1 = 0;
- child_box.x2 = width;
- child_box.y1 = 0;
- child_box.y2 = height;
-
- priv->viewport_width = width;
- priv->viewport_height = height;
-
- clutter_actor_allocate (CLUTTER_ACTOR (priv->view_box), &child_box, flags);
-}
-
-
-static void
champlain_view_realize (ClutterActor *actor)
{
DEBUG_LOG ()
@@ -736,49 +686,6 @@ champlain_view_get_preferred_height (ClutterActor *actor,
static void
-paint (ClutterActor *self)
-{
- ChamplainViewPrivate *priv = GET_PRIVATE (self);
-
- clutter_actor_paint (CLUTTER_ACTOR (priv->view_box));
-}
-
-
-static void
-pick (ClutterActor *self,
- const ClutterColor *color)
-{
- ChamplainViewPrivate *priv = GET_PRIVATE (self);
-
- CLUTTER_ACTOR_CLASS (champlain_view_parent_class)->pick (self, color);
-
- clutter_actor_paint (CLUTTER_ACTOR (priv->view_box));
-}
-
-
-static void
-map (ClutterActor *self)
-{
- ChamplainViewPrivate *priv = GET_PRIVATE (self);
-
- CLUTTER_ACTOR_CLASS (champlain_view_parent_class)->map (self);
-
- clutter_actor_map (CLUTTER_ACTOR (priv->view_box));
-}
-
-
-static void
-unmap (ClutterActor *self)
-{
- ChamplainViewPrivate *priv = GET_PRIVATE (self);
-
- CLUTTER_ACTOR_CLASS (champlain_view_parent_class)->unmap (self);
-
- clutter_actor_unmap (CLUTTER_ACTOR (priv->view_box));
-}
-
-
-static void
champlain_view_class_init (ChamplainViewClass *champlainViewClass)
{
DEBUG_LOG ()
@@ -792,14 +699,9 @@ champlain_view_class_init (ChamplainViewClass *champlainViewClass)
object_class->set_property = champlain_view_set_property;
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (champlainViewClass);
- actor_class->allocate = champlain_view_allocate;
actor_class->get_preferred_width = champlain_view_get_preferred_width;
actor_class->get_preferred_height = champlain_view_get_preferred_height;
actor_class->realize = champlain_view_realize;
- actor_class->paint = paint;
- actor_class->pick = pick;
- actor_class->map = map;
- actor_class->unmap = unmap;
/**
* ChamplainView:longitude:
@@ -1051,6 +953,29 @@ champlain_view_class_init (ChamplainViewClass *champlainViewClass)
static void
+view_size_changed_cb (ChamplainView *view,
+ G_GNUC_UNUSED GParamSpec *pspec)
+{
+ ChamplainViewPrivate *priv = GET_PRIVATE (view);
+ gint width, height;
+
+ width = clutter_actor_get_width (CLUTTER_ACTOR (view));
+ height = clutter_actor_get_height (CLUTTER_ACTOR (view));
+
+ if (priv->viewport_width != width || priv->viewport_height != height)
+ {
+ g_idle_add_full (CLUTTER_PRIORITY_REDRAW,
+ (GSourceFunc) _update_idle_cb,
+ g_object_ref (view),
+ (GDestroyNotify) g_object_unref);
+ }
+
+ priv->viewport_width = width;
+ priv->viewport_height = height;
+}
+
+
+static void
champlain_view_init (ChamplainView *view)
{
DEBUG_LOG ()
@@ -1059,6 +984,7 @@ champlain_view_init (ChamplainView *view)
ChamplainMapSourceFactory *factory;
ChamplainMapSource *source;
ClutterActor *viewport_container;
+ ClutterLayoutManager *layout;
champlain_debug_set_flags (g_getenv ("CHAMPLAIN_DEBUG"));
@@ -1076,7 +1002,6 @@ champlain_view_init (ChamplainView *view)
priv->zoom_on_double_click = TRUE;
priv->animate_zoom = TRUE;
priv->license_actor = NULL;
- priv->view_box = NULL;
priv->kinetic_mode = FALSE;
priv->viewport_x = 0;
priv->viewport_y = 0;
@@ -1091,33 +1016,36 @@ champlain_view_init (ChamplainView *view)
priv->goto_context = NULL;
priv->tiles_loading = 0;
priv->update_viewport_timer = g_timer_new ();
- priv->zoom_animation = NULL;
+ priv->animating_zoom = FALSE;
priv->background_tile_actor = NULL;
+ g_signal_connect (view, "notify::width", G_CALLBACK (view_size_changed_cb), NULL);
+ g_signal_connect (view, "notify::height", G_CALLBACK (view_size_changed_cb), NULL);
+
+ layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER,
+ CLUTTER_BIN_ALIGNMENT_CENTER);
+ clutter_actor_set_layout_manager (CLUTTER_ACTOR (view), layout);
+
/* Setup map layer */
- priv->map_layer = champlain_group_new ();
+ priv->map_layer = clutter_actor_new ();
clutter_actor_show (priv->map_layer);
/* Setup user_layers */
- priv->user_layers = clutter_group_new ();
+ priv->user_layers = clutter_actor_new ();
clutter_actor_show (priv->user_layers);
- priv->zoom_layer = clutter_group_new ();
+ priv->zoom_layer = clutter_actor_new ();
clutter_actor_show (priv->zoom_layer);
- priv->background_layer = clutter_group_new ();
+ priv->background_layer = clutter_actor_new ();
clutter_actor_show (priv->background_layer);
- viewport_container = clutter_group_new ();
+ viewport_container = clutter_actor_new ();
- clutter_container_add_actor (CLUTTER_CONTAINER (viewport_container),
- priv->background_layer);
- clutter_container_add_actor (CLUTTER_CONTAINER (viewport_container),
- priv->zoom_layer);
- clutter_container_add_actor (CLUTTER_CONTAINER (viewport_container),
- priv->map_layer);
- clutter_container_add_actor (CLUTTER_CONTAINER (viewport_container),
- priv->user_layers);
+ clutter_actor_add_child (viewport_container, priv->background_layer);
+ clutter_actor_add_child (viewport_container, priv->zoom_layer);
+ clutter_actor_add_child (viewport_container, priv->map_layer);
+ clutter_actor_add_child (viewport_container, priv->user_layers);
clutter_actor_show (viewport_container);
@@ -1125,17 +1053,15 @@ champlain_view_init (ChamplainView *view)
priv->viewport = champlain_viewport_new ();
champlain_viewport_set_child (CHAMPLAIN_VIEWPORT (priv->viewport), viewport_container);
- g_object_set (G_OBJECT (priv->viewport), "sync-adjustments", FALSE, NULL);
-
g_signal_connect (priv->viewport, "notify::x-origin",
G_CALLBACK (viewport_pos_changed_cb), view);
g_signal_connect (priv->viewport, "notify::y-origin",
G_CALLBACK (viewport_pos_changed_cb), view);
- clutter_actor_raise (priv->user_layers, priv->map_layer);
+ clutter_actor_set_child_above_sibling (viewport_container, priv->user_layers, priv->map_layer);
/* Setup kinetic scroll */
- priv->kinetic_scroll = champlain_kinetic_scroll_view_new (FALSE);
+ priv->kinetic_scroll = champlain_kinetic_scroll_view_new (FALSE, priv->viewport);
g_signal_connect (priv->kinetic_scroll, "scroll-event",
G_CALLBACK (scroll_event), view);
@@ -1143,28 +1069,15 @@ champlain_view_init (ChamplainView *view)
G_CALLBACK (panning_completed), view);
g_signal_connect (priv->kinetic_scroll, "button-press-event",
G_CALLBACK (kinetic_scroll_button_press_cb), view);
-
g_signal_connect (priv->kinetic_scroll, "key-press-event",
G_CALLBACK (kinetic_scroll_key_press_cb), view);
- clutter_container_add_actor (CLUTTER_CONTAINER (priv->kinetic_scroll),
- priv->viewport);
-
/* Setup stage */
- priv->layout_manager = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER,
- CLUTTER_BIN_ALIGNMENT_CENTER);
- priv->view_box = clutter_box_new (priv->layout_manager);
-
- clutter_bin_layout_add (CLUTTER_BIN_LAYOUT (priv->layout_manager), priv->kinetic_scroll,
- CLUTTER_BIN_ALIGNMENT_FILL,
- CLUTTER_BIN_ALIGNMENT_FILL);
+ clutter_actor_add_child (CLUTTER_ACTOR (view), priv->kinetic_scroll);
- priv->zoom_overlay_actor = clutter_group_new ();
- clutter_bin_layout_add (CLUTTER_BIN_LAYOUT (priv->layout_manager), priv->zoom_overlay_actor,
- CLUTTER_BIN_ALIGNMENT_FILL,
- CLUTTER_BIN_ALIGNMENT_FILL);
+ priv->zoom_overlay_actor = clutter_actor_new ();
+ clutter_actor_add_child (CLUTTER_ACTOR (view), priv->zoom_overlay_actor);
- clutter_actor_set_parent (CLUTTER_ACTOR (priv->view_box), CLUTTER_ACTOR (view));
clutter_actor_queue_relayout (CLUTTER_ACTOR (view));
resize_viewport (view);
@@ -1480,7 +1393,7 @@ timeline_new_frame (G_GNUC_UNUSED ClutterTimeline *timeline,
gdouble lat;
gdouble lon;
- alpha = clutter_alpha_get_alpha (ctx->alpha);
+ alpha = clutter_timeline_get_progress (timeline);
lat = ctx->to_latitude - ctx->from_latitude;
lon = ctx->to_longitude - ctx->from_longitude;
@@ -1524,7 +1437,6 @@ champlain_view_stop_go_to (ChamplainView *view)
clutter_timeline_stop (priv->goto_context->timeline);
g_object_unref (priv->goto_context->timeline);
- g_object_unref (priv->goto_context->alpha);
g_signal_emit_by_name (view, "animation-completed::go-to", NULL);
@@ -1601,7 +1513,7 @@ champlain_view_go_to_with_duration (ChamplainView *view,
* is higher and if the points are far away
*/
ctx->timeline = clutter_timeline_new (duration);
- ctx->alpha = clutter_alpha_new_full (ctx->timeline, CLUTTER_EASE_IN_OUT_CIRC);
+ clutter_timeline_set_progress_mode (ctx->timeline, CLUTTER_EASE_IN_OUT_CIRC);
g_signal_connect (ctx->timeline, "new-frame", G_CALLBACK (timeline_new_frame),
ctx);
@@ -1753,10 +1665,9 @@ champlain_view_add_layer (ChamplainView *view,
g_return_if_fail (CHAMPLAIN_IS_VIEW (view));
g_return_if_fail (CHAMPLAIN_IS_LAYER (layer));
- clutter_container_add_actor (CLUTTER_CONTAINER (view->priv->user_layers),
- CLUTTER_ACTOR (layer));
+ clutter_actor_add_child (view->priv->user_layers, CLUTTER_ACTOR (layer));
champlain_layer_set_view (layer, view);
- clutter_actor_raise_top (CLUTTER_ACTOR (layer));
+ clutter_actor_set_child_above_sibling (view->priv->user_layers, CLUTTER_ACTOR (layer), NULL);
}
@@ -1780,8 +1691,7 @@ champlain_view_remove_layer (ChamplainView *view,
champlain_layer_set_view (layer, NULL);
- clutter_container_remove_actor (CLUTTER_CONTAINER (view->priv->user_layers),
- CLUTTER_ACTOR (layer));
+ clutter_actor_remove_child (view->priv->user_layers, CLUTTER_ACTOR (layer));
}
@@ -1953,7 +1863,7 @@ fill_background_tiles (ChamplainView *view)
x_first = x_coord / size - 1;
y_first = y_coord / size - 1;
- children = clutter_container_get_children (CLUTTER_CONTAINER (priv->background_layer));
+ children = clutter_actor_get_children (priv->background_layer);
children_count = g_list_length (children);
if (children_count < tiles_count)
{
@@ -1964,7 +1874,7 @@ fill_background_tiles (ChamplainView *view)
CoglHandle handle = clutter_texture_get_cogl_texture (priv->background_tile_actor);
clutter_texture_set_cogl_texture (CLUTTER_TEXTURE (clone), handle);
- clutter_container_add_actor (CLUTTER_CONTAINER (priv->background_layer), clone);
+ clutter_actor_add_child (priv->background_layer, clone);
}
}
else if (children_count > tiles_count)
@@ -1972,13 +1882,12 @@ fill_background_tiles (ChamplainView *view)
/* remove extra background tiles */
for (i = tiles_count; i < children_count; ++i)
{
- child = clutter_container_get_children (CLUTTER_CONTAINER (priv->background_layer));
- clutter_container_remove_actor (CLUTTER_CONTAINER (priv->background_layer),
- CLUTTER_ACTOR (child->data));
+ clutter_actor_remove_child (priv->background_layer,
+ clutter_actor_get_first_child (priv->background_layer));
}
}
- children = clutter_container_get_children (CLUTTER_CONTAINER (priv->background_layer));
+ children = clutter_actor_get_children (priv->background_layer);
child = children;
for (x = x_first; x < x_first + x_count; ++x)
{
@@ -2053,7 +1962,7 @@ view_load_visible_tiles (ChamplainView *view)
}
/* Get rid of old tiles first */
- children = clutter_container_get_children (CLUTTER_CONTAINER (priv->map_layer));
+ children = clutter_actor_get_children (priv->map_layer);
for (child = children; child != NULL; child = g_list_next (child))
{
ChamplainTile *tile = CHAMPLAIN_TILE (child->data);
@@ -2068,7 +1977,7 @@ view_load_visible_tiles (ChamplainView *view)
{
/* inform map source to terminate loading the tile */
champlain_tile_set_state (tile, CHAMPLAIN_STATE_DONE);
- clutter_container_remove_actor (CLUTTER_CONTAINER (priv->map_layer), CLUTTER_ACTOR (tile));
+ clutter_actor_remove_child (priv->map_layer, CLUTTER_ACTOR (tile));
}
else
{
@@ -2103,7 +2012,7 @@ view_load_visible_tiles (ChamplainView *view)
champlain_tile_set_size (tile, size);
g_signal_connect (tile, "notify::state", G_CALLBACK (tile_state_notify), view);
- clutter_container_add_actor (CLUTTER_CONTAINER (priv->map_layer), CLUTTER_ACTOR (tile));
+ clutter_actor_add_child (priv->map_layer, CLUTTER_ACTOR (tile));
view_position_tile (view, tile);
/* updates champlain_view state automatically as
@@ -2183,14 +2092,14 @@ remove_all_tiles (ChamplainView *view)
ChamplainViewPrivate *priv = view->priv;
GList *children, *child;
- children = clutter_container_get_children (CLUTTER_CONTAINER (priv->map_layer));
+ children = clutter_actor_get_children (priv->map_layer);
for (child = children; child != NULL; child = g_list_next (child))
{
ChamplainTile *tile = CHAMPLAIN_TILE (child->data);
champlain_tile_set_state (tile, CHAMPLAIN_STATE_DONE);
}
- champlain_group_remove_all (CHAMPLAIN_GROUP (priv->map_layer));
+ clutter_actor_destroy_all_children (priv->map_layer);
g_list_free (children);
}
@@ -2491,7 +2400,7 @@ champlain_view_ensure_layers_visible (ChamplainView *view,
bbox = champlain_bounding_box_new ();
- layers = clutter_container_get_children (CLUTTER_CONTAINER (view->priv->user_layers));
+ layers = clutter_actor_get_children (view->priv->user_layers);
for (elem = layers; elem != NULL; elem = elem->next)
{
@@ -2565,13 +2474,17 @@ position_zoom_actor (ChamplainView *view)
{
ChamplainViewPrivate *priv = view->priv;
gint x, y;
+ ClutterActor *zoom_actor;
x = champlain_map_source_get_x (priv->map_source, priv->zoom_level, priv->zoom_actor_longitude) -
priv->anchor_x;
y = champlain_map_source_get_y (priv->map_source, priv->zoom_level, priv->zoom_actor_latitude) -
priv->anchor_y;
- ClutterActor *zoom_actor = clutter_group_get_nth_child (CLUTTER_GROUP (priv->zoom_overlay_actor), 0);
- clutter_group_remove_all (CLUTTER_GROUP (priv->zoom_layer));
- clutter_actor_reparent (zoom_actor, priv->zoom_layer);
+ clutter_actor_destroy_all_children (priv->zoom_layer);
+ zoom_actor = clutter_actor_get_first_child (priv->zoom_overlay_actor);
+ g_object_ref (zoom_actor);
+ clutter_actor_remove_child(priv->zoom_overlay_actor, zoom_actor);
+ clutter_actor_add_child (priv->zoom_layer, zoom_actor);
+ g_object_unref (zoom_actor);
g_object_set (G_OBJECT (zoom_actor),
"scale-center-x", 0.0,
@@ -2585,13 +2498,16 @@ position_zoom_actor (ChamplainView *view)
static void
-zoom_animation_completed (G_GNUC_UNUSED ClutterAnimation *animation,
+zoom_animation_completed (ClutterActor *actor,
+ const gchar *transition_name,
+ gboolean is_finished,
ChamplainView *view)
{
ChamplainViewPrivate *priv = view->priv;
-
- priv->zoom_animation = NULL;
+ priv->animating_zoom = FALSE;
position_zoom_actor (view);
+
+ g_signal_handlers_disconnect_by_func (actor, zoom_animation_completed, view);
}
@@ -2604,11 +2520,10 @@ show_zoom_actor (ChamplainView *view,
DEBUG_LOG ()
ChamplainViewPrivate *priv = view->priv;
- gboolean animation_running = priv->zoom_animation != NULL;
ClutterActor *zoom_actor = NULL;
gdouble deltazoom;
- if (!animation_running)
+ if (!priv->animating_zoom)
{
GList *children, *child;
gint size;
@@ -2644,11 +2559,11 @@ show_zoom_actor (ChamplainView *view,
priv->zoom_level,
y_first * size);
- clutter_group_remove_all (CLUTTER_GROUP (priv->zoom_overlay_actor));
- zoom_actor = clutter_group_new ();
- clutter_group_add (CLUTTER_GROUP (priv->zoom_overlay_actor), zoom_actor);
+ clutter_actor_destroy_all_children (priv->zoom_overlay_actor);
+ zoom_actor = clutter_actor_new ();
+ clutter_actor_add_child (priv->zoom_overlay_actor, zoom_actor);
- children = clutter_container_get_children (CLUTTER_CONTAINER (priv->map_layer));
+ children = clutter_actor_get_children (priv->map_layer);
for (child = children; child != NULL; child = g_list_next (child))
{
@@ -2657,7 +2572,10 @@ show_zoom_actor (ChamplainView *view,
gint tile_y = champlain_tile_get_y (tile);
champlain_tile_set_state (tile, CHAMPLAIN_STATE_DONE);
- clutter_actor_reparent (CLUTTER_ACTOR (tile), zoom_actor);
+ g_object_ref (CLUTTER_ACTOR (tile));
+ clutter_actor_remove_child(priv->map_layer, CLUTTER_ACTOR (tile));
+ clutter_actor_add_child (zoom_actor, CLUTTER_ACTOR (tile));
+ g_object_unref (CLUTTER_ACTOR (tile));
clutter_actor_set_position (CLUTTER_ACTOR (tile), (tile_x - x_first) * size, (tile_y - y_first) *
size);
}
@@ -2674,31 +2592,32 @@ show_zoom_actor (ChamplainView *view,
NULL);
}
else
- zoom_actor = clutter_group_get_nth_child (CLUTTER_GROUP (priv->zoom_overlay_actor), 0);
+ zoom_actor = clutter_actor_get_first_child (priv->zoom_overlay_actor);
deltazoom = pow (2.0, (gdouble)zoom_level - priv->anim_start_zoom_level);
if (priv->animate_zoom)
{
clutter_actor_set_opacity (priv->map_layer, 0);
-
- clutter_group_remove_all (CLUTTER_GROUP (priv->zoom_layer));
-
- priv->zoom_animation = clutter_actor_animate (CLUTTER_ACTOR (zoom_actor),
- CLUTTER_EASE_IN_OUT_QUAD,
- 350,
- "scale-x", deltazoom,
- "scale-y", deltazoom,
- NULL);
-
- clutter_actor_animate (CLUTTER_ACTOR (priv->map_layer),
- CLUTTER_EASE_IN_EXPO,
- 350,
- "opacity", 255,
- NULL);
-
- if (!animation_running)
- g_signal_connect (priv->zoom_animation, "completed", G_CALLBACK (zoom_animation_completed), view);
+
+ clutter_actor_destroy_all_children (priv->zoom_layer);
+
+ clutter_actor_save_easing_state (zoom_actor);
+ clutter_actor_set_easing_mode (zoom_actor, CLUTTER_EASE_IN_OUT_QUAD);
+ clutter_actor_set_easing_duration (zoom_actor, 350);
+ clutter_actor_set_scale (zoom_actor, deltazoom, deltazoom);
+ clutter_actor_restore_easing_state (zoom_actor);
+
+ clutter_actor_save_easing_state (priv->map_layer);
+ clutter_actor_set_easing_mode (priv->map_layer, CLUTTER_EASE_IN_EXPO);
+ clutter_actor_set_easing_duration (priv->map_layer, 350);
+ clutter_actor_set_opacity (priv->map_layer, 255);
+ clutter_actor_restore_easing_state (priv->map_layer);
+
+ if (!priv->animating_zoom)
+ g_signal_connect (zoom_actor, "transition-stopped::scale-x", G_CALLBACK (zoom_animation_completed),
view);
+
+ priv->animating_zoom = TRUE;
}
else
clutter_actor_set_scale (zoom_actor, deltazoom, deltazoom);
@@ -2963,6 +2882,25 @@ champlain_view_get_animate_zoom (ChamplainView *view)
}
+static ClutterActorAlign
+bin_alignment_to_actor_align (ClutterBinAlignment alignment)
+{
+ switch (alignment)
+ {
+ case CLUTTER_BIN_ALIGNMENT_FILL:
+ return CLUTTER_ACTOR_ALIGN_FILL;
+ case CLUTTER_BIN_ALIGNMENT_START:
+ return CLUTTER_ACTOR_ALIGN_START;
+ case CLUTTER_BIN_ALIGNMENT_END:
+ return CLUTTER_ACTOR_ALIGN_END;
+ case CLUTTER_BIN_ALIGNMENT_CENTER:
+ return CLUTTER_ACTOR_ALIGN_CENTER;
+ default:
+ return CLUTTER_ACTOR_ALIGN_START;
+ }
+}
+
+
/**
* champlain_view_bin_layout_add:
* @view: a #ChamplainView
@@ -2982,16 +2920,15 @@ champlain_view_bin_layout_add (ChamplainView *view,
ClutterBinAlignment x_align,
ClutterBinAlignment y_align)
{
- ChamplainViewPrivate *priv = view->priv;
- ClutterBinLayout *layout_manager;
-
DEBUG_LOG ()
g_return_if_fail (CHAMPLAIN_IS_VIEW (view));
- layout_manager = CLUTTER_BIN_LAYOUT (priv->layout_manager);
- clutter_bin_layout_add (layout_manager, child, x_align, y_align);
- clutter_actor_queue_relayout (CLUTTER_ACTOR (view));
+ clutter_actor_set_x_expand (child, TRUE);
+ clutter_actor_set_y_expand (child, TRUE);
+ clutter_actor_set_x_align (child, bin_alignment_to_actor_align (x_align));
+ clutter_actor_set_y_align (child, bin_alignment_to_actor_align (y_align));
+ clutter_actor_add_child (CLUTTER_ACTOR (view), child);
}
diff --git a/champlain/champlain-viewport.c b/champlain/champlain-viewport.c
index 81eba47..f6e1f1e 100644
--- a/champlain/champlain-viewport.c
+++ b/champlain/champlain-viewport.c
@@ -41,10 +41,6 @@ struct _ChamplainViewportPrivate
ChamplainAdjustment *hadjustment;
ChamplainAdjustment *vadjustment;
-
- gboolean sync_adjustments;
- ClutterActor *child;
- ClutterActor *content_group;
};
enum
@@ -55,7 +51,6 @@ enum
PROP_Y_ORIGIN,
PROP_HADJUST,
PROP_VADJUST,
- PROP_SYNC_ADJUST,
};
static void
@@ -88,10 +83,6 @@ champlain_viewport_get_property (GObject *object,
g_value_set_object (value, adjustment);
break;
- case PROP_SYNC_ADJUST:
- g_value_set_boolean (value, priv->sync_adjustments);
- break;
-
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -134,10 +125,6 @@ champlain_viewport_set_property (GObject *object,
g_value_get_object (value));
break;
- case PROP_SYNC_ADJUST:
- priv->sync_adjustments = g_value_get_boolean (value);
- break;
-
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -174,144 +161,14 @@ champlain_viewport_dispose (GObject *gobject)
priv->vadjustment = NULL;
}
- if (priv->content_group)
- {
- clutter_actor_destroy (priv->content_group);
- priv->content_group = NULL;
- }
-
G_OBJECT_CLASS (champlain_viewport_parent_class)->dispose (gobject);
}
static void
-paint (ClutterActor *self)
-{
- ChamplainViewportPrivate *priv = GET_PRIVATE (self);
-
- clutter_actor_paint (priv->content_group);
-}
-
-
-static void
-pick (ClutterActor *self,
- const ClutterColor *color)
-{
- ChamplainViewportPrivate *priv = GET_PRIVATE (self);
-
- CLUTTER_ACTOR_CLASS (champlain_viewport_parent_class)->pick (self, color);
-
- clutter_actor_paint (CLUTTER_ACTOR (priv->content_group));
-}
-
-
-static void
-get_preferred_width (ClutterActor *self,
- gfloat for_height,
- gfloat *min_width_p,
- gfloat *natural_width_p)
-{
- ChamplainViewportPrivate *priv = GET_PRIVATE (self);
-
- clutter_actor_get_preferred_width (CLUTTER_ACTOR (priv->content_group),
- for_height,
- min_width_p,
- natural_width_p);
-}
-
-
-static void
-get_preferred_height (ClutterActor *self,
- gfloat for_width,
- gfloat *min_height_p,
- gfloat *natural_height_p)
-{
- ChamplainViewportPrivate *priv = GET_PRIVATE (self);
-
- clutter_actor_get_preferred_height (CLUTTER_ACTOR (priv->content_group),
- for_width,
- min_height_p,
- natural_height_p);
-}
-
-
-static void
-map (ClutterActor *self)
-{
- ChamplainViewportPrivate *priv = GET_PRIVATE (self);
-
- CLUTTER_ACTOR_CLASS (champlain_viewport_parent_class)->map (self);
-
- clutter_actor_map (CLUTTER_ACTOR (priv->content_group));
-}
-
-
-static void
-unmap (ClutterActor *self)
-{
- ChamplainViewportPrivate *priv = GET_PRIVATE (self);
-
- CLUTTER_ACTOR_CLASS (champlain_viewport_parent_class)->unmap (self);
-
- clutter_actor_unmap (CLUTTER_ACTOR (priv->content_group));
-}
-
-
-static void
-allocate (ClutterActor *self,
- const ClutterActorBox *box,
- ClutterAllocationFlags flags)
-{
- ClutterActorBox child_box;
- CoglFixed prev_value;
-
- ChamplainViewportPrivate *priv = CHAMPLAIN_VIEWPORT (self)->priv;
-
- /* Chain up */
- CLUTTER_ACTOR_CLASS (champlain_viewport_parent_class)->
- allocate (self, box, flags);
-
- /* Refresh adjustments */
- if (priv->sync_adjustments)
- {
- if (priv->hadjustment)
- {
- g_object_set (G_OBJECT (priv->hadjustment),
- "lower", 0.0,
- "upper", (box->x2 - box->x1),
- NULL);
-
- /* Make sure value is clamped */
- prev_value = champlain_adjustment_get_value (priv->hadjustment);
- champlain_adjustment_set_value (priv->hadjustment, prev_value);
- }
-
- if (priv->vadjustment)
- {
- g_object_set (G_OBJECT (priv->vadjustment),
- "lower", 0.0,
- "upper", (box->y2 - box->y1),
- NULL);
-
- prev_value = champlain_adjustment_get_value (priv->vadjustment);
- champlain_adjustment_set_value (priv->vadjustment, prev_value);
- }
- }
-
- child_box.x1 = 0;
- child_box.x2 = box->x2 - box->x1;
- child_box.y1 = 0;
- child_box.y2 = box->y2 - box->y1;
-
- clutter_actor_allocate (CLUTTER_ACTOR (priv->content_group), &child_box, flags);
-}
-
-
-static void
champlain_viewport_class_init (ChamplainViewportClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
g_type_class_add_private (klass, sizeof (ChamplainViewportPrivate));
@@ -319,14 +176,6 @@ champlain_viewport_class_init (ChamplainViewportClass *klass)
gobject_class->set_property = champlain_viewport_set_property;
gobject_class->dispose = champlain_viewport_dispose;
- actor_class->get_preferred_width = get_preferred_width;
- actor_class->get_preferred_height = get_preferred_height;
- actor_class->allocate = allocate;
- actor_class->paint = paint;
- actor_class->pick = pick;
- actor_class->map = map;
- actor_class->unmap = unmap;
-
g_object_class_install_property (gobject_class,
PROP_X_ORIGIN,
g_param_spec_int ("x-origin",
@@ -346,18 +195,6 @@ champlain_viewport_class_init (ChamplainViewportClass *klass)
G_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
- PROP_SYNC_ADJUST,
- g_param_spec_boolean ("sync-adjustments",
- "Synchronise "
- "adjustments",
- "Whether to "
- "synchronise "
- "adjustments with "
- "viewport size",
- TRUE,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (gobject_class,
PROP_HADJUST,
g_param_spec_object ("hadjustment",
"ChamplainAdjustment",
@@ -527,49 +364,9 @@ champlain_viewport_get_adjustments (ChamplainViewport *viewport,
static void
-clip_notify_cb (ClutterActor *actor,
- GParamSpec *pspec,
- ChamplainViewport *self)
-{
- gfloat width, height;
- ChamplainViewportPrivate *priv = self->priv;
-
- if (!priv->sync_adjustments)
- return;
-
- if (!clutter_actor_has_clip (actor))
- {
- if (priv->hadjustment)
- g_object_set (priv->hadjustment, "page-size", (gdouble) 1.0, NULL);
- if (priv->vadjustment)
- g_object_set (priv->vadjustment, "page-size", (gdouble) 1.0, NULL);
- return;
- }
-
- clutter_actor_get_clip (actor, NULL, NULL, &width, &height);
-
- if (priv->hadjustment)
- g_object_set (priv->hadjustment, "page-size", (gdouble) width, NULL);
-
- if (priv->vadjustment)
- g_object_set (priv->vadjustment, "page-size", (gdouble) height, NULL);
-}
-
-
-static void
champlain_viewport_init (ChamplainViewport *self)
{
self->priv = GET_PRIVATE (self);
-
- self->priv->sync_adjustments = TRUE;
-
- self->priv->child = NULL;
- self->priv->content_group = clutter_group_new ();
- clutter_actor_set_parent (CLUTTER_ACTOR (self->priv->content_group), CLUTTER_ACTOR (self));
- clutter_actor_queue_relayout (CLUTTER_ACTOR (self));
-
- g_signal_connect (self, "notify::clip",
- G_CALLBACK (clip_notify_cb), self);
}
@@ -586,6 +383,7 @@ champlain_viewport_set_origin (ChamplainViewport *viewport,
float y)
{
ChamplainViewportPrivate *priv;
+ ClutterActor *child;
g_return_if_fail (CHAMPLAIN_IS_VIEWPORT (viewport));
@@ -615,10 +413,9 @@ champlain_viewport_set_origin (ChamplainViewport *viewport,
g_object_thaw_notify (G_OBJECT (viewport));
- if (priv->child)
- clutter_actor_set_position (priv->child, -x, -y);
-
- clutter_actor_queue_redraw (CLUTTER_ACTOR (viewport));
+ child = clutter_actor_get_first_child (CLUTTER_ACTOR (viewport));
+ if (child)
+ clutter_actor_set_position (child, -x, -y);
}
@@ -644,11 +441,6 @@ champlain_viewport_get_origin (ChamplainViewport *viewport,
void
champlain_viewport_set_child (ChamplainViewport *viewport, ClutterActor *child)
{
- ChamplainViewportPrivate *priv = viewport->priv;
-
- if (priv->child)
- clutter_container_remove_actor (CLUTTER_CONTAINER (priv->content_group), priv->child);
-
- priv->child = child;
- clutter_container_add_actor (CLUTTER_CONTAINER (priv->content_group), child);
+ clutter_actor_remove_all_children (CLUTTER_ACTOR (viewport));
+ clutter_actor_add_child (CLUTTER_ACTOR (viewport), child);
}
diff --git a/demos/Makefile.am b/demos/Makefile.am
index 8226778..0126324 100644
--- a/demos/Makefile.am
+++ b/demos/Makefile.am
@@ -4,7 +4,7 @@ SUBDIRS = icons
INCLUDES = -I$(top_srcdir)
-AM_CPPFLAGS = $(DEPS_CFLAGS) $(WARN_CFLAGS) -DCLUTTER_DISABLE_DEPRECATION_WARNINGS
+AM_CPPFLAGS = $(DEPS_CFLAGS) $(WARN_CFLAGS)
AM_LDFLAGS = $(DEPS_LIBS)
minimal_SOURCES = minimal.c
diff --git a/docs/reference/Makefile.am b/docs/reference/Makefile.am
index ead0b61..f3c766e 100644
--- a/docs/reference/Makefile.am
+++ b/docs/reference/Makefile.am
@@ -67,7 +67,6 @@ IGNORE_HFILES= $(ignored_headers) \
champlain-marshal.h \
champlain-defines.h \
champlain-features.h \
- champlain-group.h \
champlain-adjustment.h \
champlain-kinetic-scroll-view.h \
champlain-viewport.h
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]