mirror of
https://github.com/brl/mutter.git
synced 2025-08-02 06:34:40 +00:00
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:
@@ -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));
|
||||
|
||||
|
Reference in New Issue
Block a user