Commit 392efa10 authored by Jiří Techet's avatar Jiří Techet

Update most of libchamplain to Clutter API 1.12

parent 0a25d2e7
......@@ -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);
}
......
......@@ -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)
......
......@@ -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")]
......
......@@ -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",
......
......@@ -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)
{
......@@ -141,109 +135,10 @@ 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));
}
......
......@@ -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);
}
......
This diff is collapsed.
/*
* Clutter.
*
* An OpenGL based 'interactive canvas' library.
*
* Authored By Matthew Allum <mallum@openedhand.com>
*
* Copyright (C) 2006 OpenedHand
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __CHAMPLAIN_GROUP_H__
#define __CHAMPLAIN_GROUP_H__
#include <glib-object.h>
#include <clutter/clutter.h>
G_BEGIN_DECLS
#define CHAMPLAIN_TYPE_GROUP champlain_group_get_type ()
#define CHAMPLAIN_GROUP(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), CHAMPLAIN_TYPE_GROUP, ChamplainGroup))
#define CHAMPLAIN_GROUP_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST ((klass), CHAMPLAIN_TYPE_GROUP, ChamplainGroupClass))
#define CHAMPLAIN_IS_GROUP(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), CHAMPLAIN_TYPE_GROUP))
#define CHAMPLAIN_IS_GROUP_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), CHAMPLAIN_TYPE_GROUP))
#define CHAMPLAIN_GROUP_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), CHAMPLAIN_TYPE_GROUP, ChamplainGroupClass))
typedef struct _ChamplainGroup ChamplainGroup;
typedef struct _ChamplainGroupClass ChamplainGroupClass;
typedef struct _ChamplainGroupPrivate ChamplainGroupPrivate;
/**
* ChamplainGroup:
*
* The #ChamplainGroup structure contains only private data
* and should be accessed using the provided API
*
* Since: 0.1
*/
struct _ChamplainGroup
{
/*< private >*/
ClutterActor parent_instance;
ChamplainGroupPrivate *priv;
};
/**
* ChamplainGroupClass:
*
* The #ChamplainGroupClass structure contains only private data
*
* Since: 0.1
*/
struct _ChamplainGroupClass
{
/*< private >*/
ClutterActorClass parent_class;
/* padding for future expansion */
void (*_clutter_reserved1)(void);
void (*_clutter_reserved2)(void);
void (*_clutter_reserved3)(void);
void (*_clutter_reserved4)(void);
void (*_clutter_reserved5)(void);
void (*_clutter_reserved6)(void);
};
GType champlain_group_get_type (void) G_GNUC_CONST;
ClutterActor *champlain_group_new (void);
ClutterActor *champlain_group_get_nth_child (ChamplainGroup *self,
gint index_);
gint champlain_group_get_n_children (ChamplainGroup *self);
void champlain_group_remove_all (ChamplainGroup *group);
/* for Mr. Mallum */
#define champlain_group_add(group, actor) G_STMT_START { \
ClutterActor *_actor = (ClutterActor *) (actor); \
if (CHAMPLAIN_IS_GROUP ((group)) && CLUTTER_IS_ACTOR ((_actor))) \
{ \
ClutterContainer *_container = (ClutterContainer *) (group); \
clutter_container_add_actor (_container, _actor); \
} } G_STMT_END
G_END_DECLS
#endif /* __CHAMPLAIN_GROUP_H__ */
......@@ -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)