canvas: Add canvas size to the ::draw signal

Instead of requiring a call to clutter_content_get_preferred_size(), we
can simply pass the canvas size to the Canvas::draw signal.
This commit is contained in:
Emmanuele Bassi
2012-03-08 15:47:16 +00:00
parent 07bb35bbe3
commit 0eeb61f3a8
5 changed files with 27 additions and 17 deletions

View File

@@ -5,9 +5,10 @@
static gboolean
draw_clock (ClutterCanvas *canvas,
cairo_t *cr)
cairo_t *cr,
int width,
int height)
{
float width, height;
GDateTime *now;
float hours, minutes, seconds;
ClutterColor color;
@@ -31,9 +32,6 @@ draw_clock (ClutterCanvas *canvas,
cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
/* scale the modelview to the size of the surface */
clutter_content_get_preferred_size (CLUTTER_CONTENT (canvas),
&width,
&height);
cairo_scale (cr, width, height);
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
@@ -108,6 +106,9 @@ test_canvas_main (int argc, char *argv[])
clutter_actor_set_content (actor, canvas);
clutter_actor_add_child (stage, actor);
/* the actor now owns the canvas */
g_object_unref (canvas);
/* bind the size of the actor to that of the stage */
clutter_actor_add_constraint (actor, clutter_bind_constraint_new (stage, CLUTTER_BIND_SIZE, 0));