[libchamplain] Allow the background pattern to be arbitrary rectangle
- From: Jiří Techet <jiritechet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libchamplain] Allow the background pattern to be arbitrary rectangle
- Date: Tue, 16 Apr 2013 21:33:55 +0000 (UTC)
commit 482f1e8567bb7dd7291a564ddec236c9c1ff4b5e
Author: Jiří Techet <techet gmail com>
Date: Sat Apr 13 15:14:49 2013 +0200
Allow the background pattern to be arbitrary rectangle
champlain/champlain-view.c | 20 ++++++++++----------
demos/launcher-gtk.c | 15 ++++++++-------
2 files changed, 18 insertions(+), 17 deletions(-)
---
diff --git a/champlain/champlain-view.c b/champlain/champlain-view.c
index 159a897..64b3d34 100644
--- a/champlain/champlain-view.c
+++ b/champlain/champlain-view.c
@@ -1823,22 +1823,22 @@ fill_background_tiles (ChamplainView *view)
gint x_count, y_count, x_first, y_first;
gdouble x_coord, y_coord;
gint x, y;
- gfloat size;
+ gfloat width, height;
+ gboolean have_children = TRUE;
- clutter_content_get_preferred_size (priv->background_content, &size, &size);
+ clutter_content_get_preferred_size (priv->background_content, &width, &height);
x_coord = priv->viewport_x + priv->anchor_x;
y_coord = priv->viewport_y + priv->anchor_y;
- x_count = ceil ((float) priv->viewport_width / size) + 2;
- y_count = ceil ((float) priv->viewport_height / size) + 2;
+ x_count = ceil ((float) priv->viewport_width / width) + 2;
+ y_count = ceil ((float) priv->viewport_height / height) + 2;
- x_first = x_coord / size - 1;
- y_first = y_coord / size - 1;
+ x_first = x_coord / width - 1;
+ y_first = y_coord / height - 1;
clutter_actor_iter_init (&iter, priv->background_layer);
- gboolean have_children = TRUE;
for (x = x_first; x < x_first + x_count; ++x)
{
for (y = y_first; y < y_first + y_count; ++y)
@@ -1847,13 +1847,13 @@ fill_background_tiles (ChamplainView *view)
{
have_children = FALSE;
child = clutter_actor_new ();
- clutter_actor_set_size (child, size, size);
+ clutter_actor_set_size (child, width, height);
clutter_actor_set_content (child, priv->background_content);
clutter_actor_add_child (priv->background_layer, child);
}
clutter_actor_set_position (child,
- (x * size) - priv->anchor_x,
- (y * size) - priv->anchor_y);
+ (x * width) - priv->anchor_x,
+ (y * height) - priv->anchor_y);
child = clutter_actor_get_next_sibling (child);
}
}
diff --git a/demos/launcher-gtk.c b/demos/launcher-gtk.c
index d1d2125..dd560da 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 32
+#define TILE_SQUARE_SIZE 64
static ChamplainPathLayer *path_layer;
static ChamplainPathLayer *path;
@@ -219,14 +219,15 @@ draw_background_tile (ClutterCanvas *canvas,
int height)
{
cairo_pattern_t *pat;
- gint no_of_squares = width / TILE_SQUARE_SIZE;
+ 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, width / 2.0);
+ 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, width);
+ cairo_rectangle (cr, 0, 0, width, height);
cairo_fill (cr);
cairo_pattern_destroy (pat);
@@ -234,9 +235,9 @@ draw_background_tile (ClutterCanvas *canvas,
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)
+ for (row = 0; row < no_of_squares_y; ++row)
{
- for (column = 0; column < no_of_squares; column++)
+ for (column = 0; column < no_of_squares_x; column++)
{
/* drawing square alternatively */
if ((row % 2 == 0 && column % 2 == 0) ||
@@ -317,7 +318,7 @@ main (int argc,
ClutterContent *canvas;
canvas = clutter_canvas_new ();
- clutter_canvas_set_size (CLUTTER_CANVAS (canvas), 256, 256);
+ clutter_canvas_set_size (CLUTTER_CANVAS (canvas), 512, 256);
g_signal_connect (canvas, "draw", G_CALLBACK (draw_background_tile), NULL);
clutter_content_invalidate (canvas);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]