summaryrefslogtreecommitdiff
path: root/demos/launcher-gtk.c
diff options
context:
space:
mode:
authorJiří Techet <techet@gmail.com>2013-04-11 18:01:31 +0200
committerJiří Techet <techet@gmail.com>2013-04-11 18:01:31 +0200
commit5df37f9bd3aa2b2e64139be9e903f8f5b211452f (patch)
tree3e350a73454fd5da03e1b43ea8f483cedf6d7a5c /demos/launcher-gtk.c
parent56cfc6deb1e21abb43dd16203f2dea7a06b43247 (diff)
downloadlibchamplain-5df37f9bd3aa2b2e64139be9e903f8f5b211452f.tar.gz
Modify the background pattern interface to use ClutterContent
Diffstat (limited to 'demos/launcher-gtk.c')
-rw-r--r--demos/launcher-gtk.c35
1 files changed, 19 insertions, 16 deletions
diff --git a/demos/launcher-gtk.c b/demos/launcher-gtk.c
index 828ab0b..e71ada8 100644
--- a/demos/launcher-gtk.c
+++ b/demos/launcher-gtk.c
@@ -27,7 +27,7 @@
#define N_COLS 2
#define COL_ID 0
#define COL_NAME 1
-#define TILE_SQUARE_SIZE 8
+#define TILE_SQUARE_SIZE 32
static ChamplainPathLayer *path_layer;
static ChamplainPathLayer *path;
@@ -213,28 +213,26 @@ append_point (ChamplainPathLayer *layer, gdouble lon, gdouble lat)
}
-static ClutterTexture *
-fill_background_tile (gint size)
+static gboolean
+draw_background_tile (ClutterCanvas *canvas,
+ cairo_t *cr,
+ int width,
+ int height)
{
- ClutterActor *actor = NULL;
- cairo_t *cr;
cairo_pattern_t *pat;
- gint no_of_squares = size / TILE_SQUARE_SIZE;
+ gint no_of_squares = width / TILE_SQUARE_SIZE;
gint row, column;
- actor = clutter_cairo_texture_new (size, size);
-
/* Create the background tile */
- cr = clutter_cairo_texture_create (CLUTTER_CAIRO_TEXTURE (actor));
- pat = cairo_pattern_create_linear (size / 2.0, 0.0, size, size / 2.0);
+ pat = cairo_pattern_create_linear (width / 2.0, 0.0, width, width / 2.0);
cairo_pattern_add_color_stop_rgb (pat, 0, 0.662, 0.662, 0.662);
cairo_set_source (cr, pat);
- cairo_rectangle (cr, 0, 0, size, size);
+ cairo_rectangle (cr, 0, 0, width, width);
cairo_fill (cr);
cairo_pattern_destroy (pat);
/* Filling the tile */
- cairo_set_source_rgb (cr, 0.411, 0.411, 0.411);
+ cairo_set_source_rgb (cr, 0.811, 0.811, 0.811);
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
for (row = 0; row < no_of_squares; ++row)
@@ -253,9 +251,8 @@ fill_background_tile (gint size)
cairo_fill (cr);
}
cairo_stroke (cr);
- cairo_destroy (cr);
-
- return CLUTTER_TEXTURE(actor);
+
+ return TRUE;
}
@@ -321,7 +318,13 @@ main (int argc,
champlain_view_add_layer (view, CHAMPLAIN_LAYER (path));
champlain_view_add_layer (view, CHAMPLAIN_LAYER (layer));
- champlain_view_set_background_tile (view, fill_background_tile (256));
+ ClutterContent *canvas;
+ canvas = clutter_canvas_new ();
+ clutter_canvas_set_size (CLUTTER_CANVAS (canvas), 256, 256);
+ g_signal_connect (canvas, "draw", G_CALLBACK (draw_background_tile), NULL);
+ clutter_content_invalidate (canvas);
+
+ champlain_view_set_background_pattern (view, canvas);
path_layer = champlain_path_layer_new ();
/* Cheap approx of Highway 10 */