[libchamplain] Move background pattern testing from launcher-gtk to launcher demo
- From: Jiří Techet <jiritechet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libchamplain] Move background pattern testing from launcher-gtk to launcher demo
- Date: Thu, 2 May 2013 19:31:33 +0000 (UTC)
commit d6b29ab38d00ee66913e5b408482472380a06e50
Author: Jiří Techet <techet gmail com>
Date: Thu May 2 12:26:43 2013 +0200
Move background pattern testing from launcher-gtk to launcher demo
demos/launcher-gtk.c | 53 --------------------------------------------------
demos/launcher.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 52 insertions(+), 53 deletions(-)
---
diff --git a/demos/launcher-gtk.c b/demos/launcher-gtk.c
index 70e5d4d..6458e93 100644
--- a/demos/launcher-gtk.c
+++ b/demos/launcher-gtk.c
@@ -27,7 +27,6 @@
#define N_COLS 2
#define COL_ID 0
#define COL_NAME 1
-#define TILE_SQUARE_SIZE 64
static ChamplainPathLayer *path_layer;
static ChamplainPathLayer *path;
@@ -212,50 +211,6 @@ append_point (ChamplainPathLayer *layer, gdouble lon, gdouble lat)
}
-static gboolean
-draw_background_tile (ClutterCanvas *canvas,
- cairo_t *cr,
- int width,
- int height)
-{
- cairo_pattern_t *pat;
- gint no_of_squares_x = width / TILE_SQUARE_SIZE;
- gint no_of_squares_y = height / TILE_SQUARE_SIZE;
- gint row, column;
-
- /* Create the background tile */
- pat = cairo_pattern_create_linear (width / 2.0, 0.0, width, height / 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, width, height);
- cairo_fill (cr);
- cairo_pattern_destroy (pat);
-
- /* Filling the tile */
- 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_y; ++row)
- {
- for (column = 0; column < no_of_squares_x; column++)
- {
- /* drawing square alternatively */
- if ((row % 2 == 0 && column % 2 == 0) ||
- (row % 2 != 0 && column % 2 != 0))
- cairo_rectangle (cr,
- column * TILE_SQUARE_SIZE,
- row * TILE_SQUARE_SIZE,
- TILE_SQUARE_SIZE,
- TILE_SQUARE_SIZE);
- }
- cairo_fill (cr);
- }
- cairo_stroke (cr);
-
- return TRUE;
-}
-
-
int
main (int argc,
char *argv[])
@@ -318,14 +273,6 @@ main (int argc,
champlain_view_add_layer (view, CHAMPLAIN_LAYER (path));
champlain_view_add_layer (view, CHAMPLAIN_LAYER (layer));
- ClutterContent *canvas;
- canvas = clutter_canvas_new ();
- clutter_canvas_set_size (CLUTTER_CANVAS (canvas), 512, 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 */
append_point (path_layer, 45.4095, -73.3197);
diff --git a/demos/launcher.c b/demos/launcher.c
index c758d1b..f9a3257 100644
--- a/demos/launcher.c
+++ b/demos/launcher.c
@@ -86,6 +86,51 @@ make_button (char *text)
return button;
}
+#define TILE_SQUARE_SIZE 64
+
+static gboolean
+draw_background_tile (ClutterCanvas *canvas,
+ cairo_t *cr,
+ int width,
+ int height)
+{
+ cairo_pattern_t *pat;
+ gint no_of_squares_x = width / TILE_SQUARE_SIZE;
+ gint no_of_squares_y = height / TILE_SQUARE_SIZE;
+ gint row, column;
+
+ /* Create the background tile */
+ pat = cairo_pattern_create_linear (width / 2.0, 0.0, width, height / 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, width, height);
+ cairo_fill (cr);
+ cairo_pattern_destroy (pat);
+
+ /* Filling the tile */
+ 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_y; ++row)
+ {
+ for (column = 0; column < no_of_squares_x; column++)
+ {
+ /* drawing square alternatively */
+ if ((row % 2 == 0 && column % 2 == 0) ||
+ (row % 2 != 0 && column % 2 != 0))
+ cairo_rectangle (cr,
+ column * TILE_SQUARE_SIZE,
+ row * TILE_SQUARE_SIZE,
+ TILE_SQUARE_SIZE,
+ TILE_SQUARE_SIZE);
+ }
+ cairo_fill (cr);
+ }
+ cairo_stroke (cr);
+
+ return TRUE;
+}
+
int
main (int argc,
@@ -132,6 +177,13 @@ main (int argc,
clutter_actor_add_child (stage, buttons);
+ ClutterContent *canvas;
+ canvas = clutter_canvas_new ();
+ clutter_canvas_set_size (CLUTTER_CANVAS (canvas), 512, 256);
+ g_signal_connect (canvas, "draw", G_CALLBACK (draw_background_tile), NULL);
+ clutter_content_invalidate (canvas);
+ champlain_view_set_background_pattern (CHAMPLAIN_VIEW (actor), canvas);
+
/* Create the markers and marker layer */
layer = create_marker_layer (CHAMPLAIN_VIEW (actor), &path);
champlain_view_add_layer (CHAMPLAIN_VIEW (actor), CHAMPLAIN_LAYER (layer));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]