Top | ![]() |
![]() |
![]() |
![]() |
ClutterContent * | clutter_canvas_new () |
gboolean | clutter_canvas_set_size () |
void | clutter_canvas_set_scale_factor () |
int | clutter_canvas_get_scale_factor () |
The ClutterCanvas class is a ClutterContent implementation that allows drawing using the Cairo API on a 2D surface.
In order to draw on a ClutterCanvas, you should connect a handler to the
“draw” signal; the signal will receive a cairo_t context
that can be used to draw. ClutterCanvas will emit the “draw”
signal when invalidated using clutter_content_invalidate()
.
See canvas.c for an example of how to use ClutterCanvas.
ClutterCanvas is available since Clutter 1.10.
ClutterContent *
clutter_canvas_new (void
);
Creates a new instance of ClutterCanvas.
You should call clutter_canvas_set_size()
to set the size of the canvas.
You should call clutter_content_invalidate()
every time you wish to
draw the contents of the canvas.
The newly allocated instance of
ClutterCanvas. Use g_object_unref()
when done.
[transfer full]
Since: 1.10
gboolean clutter_canvas_set_size (ClutterCanvas *canvas
,int width
,int height
);
Sets the size of the canvas
, and invalidates the content.
This function will cause the canvas
to be invalidated only
if the size of the canvas surface has changed.
If you want to invalidate the contents of the canvas
when setting
the size, you can use the return value of the function to conditionally
call clutter_content_invalidate()
:
1 2 |
if (!clutter_canvas_set_size (canvas, width, height)) clutter_content_invalidate (CLUTTER_CONTENT (canvas)); |
canvas |
||
width |
the width of the canvas, in pixels |
|
height |
the height of the canvas, in pixels |
this function returns TRUE
if the size change
caused a content invalidation, and FALSE
otherwise
Since: 1.10
void clutter_canvas_set_scale_factor (ClutterCanvas *canvas
,int scale
);
struct ClutterCanvas;
The ClutterCanvas structure contains private data and should only be accessed using the provided API.
Since: 1.10
struct ClutterCanvasClass { gboolean (* draw) (ClutterCanvas *canvas, cairo_t *cr, int width, int height); };
The ClutterCanvasClass structure contains private data.
Since: 1.10
“height”
property “height” int
The height of the canvas.
Owner: ClutterCanvas
Flags: Read / Write
Allowed values: >= -1
Default value: -1
Since: 1.10
“width”
property “width” int
The width of the canvas.
Owner: ClutterCanvas
Flags: Read / Write
Allowed values: >= -1
Default value: -1
Since: 1.10
“draw”
signalgboolean user_function (ClutterCanvas *canvas, CairoContext *cr, int width, int height, gpointer user_data)
The “draw” signal is emitted each time a canvas is invalidated.
It is safe to connect multiple handlers to this signal: each
handler invocation will be automatically protected by cairo_save()
and cairo_restore()
pairs.
canvas |
the ClutterCanvas that emitted the signal |
|
cr |
the Cairo context used to draw |
|
width |
the width of the |
|
height |
the height of the |
|
user_data |
user data set when the signal handler was connected. |
Flags: No Recursion
Since: 1.10