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
);
Sets the scaling factor for the Cairo surface used by canvas
.
This function should rarely be used.
The default scaling factor of a ClutterCanvas content uses the “window-scaling-factor” property, which is set by the windowing system. By using this function it is possible to override that setting.
Changing the scale factor will invalidate the canvas
.
Since: 1.18
int
clutter_canvas_get_scale_factor (ClutterCanvas *canvas
);
Retrieves the scaling factor of canvas
, as set using
clutter_canvas_set_scale_factor()
.
Since: 1.18
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