Top |
ClutterContent * | clutter_canvas_new () |
gboolean | clutter_canvas_set_size () |
void | clutter_canvas_set_scale_factor () |
int | clutter_canvas_get_scale_factor () |
gint | height | Read / Write |
gint | scale-factor | Read / Write |
gboolean | scale-factor-set | Read |
gint | width | Read / Write |
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
“height”
property “height” gint
The height of the canvas.
Flags: Read / Write
Allowed values: >= -1
Default value: -1
Since: 1.10
“scale-factor”
property “scale-factor” gint
The scaling factor to be applied to the Cairo surface used for drawing.
If “scale-factor” is set to a negative value, the value of the “window-scaling-factor” property is used instead.
Use “scale-factor-set” to check if the scale factor is set.
Flags: Read / Write
Allowed values: [-1,1000]
Default value: -1
Since: 1.18
“scale-factor-set”
property “scale-factor-set” gboolean
Whether the “scale-factor” property is set.
If the “scale-factor-set” property is FALSE
then ClutterCanvas will use the “window-scaling-factor”
property.
Flags: Read
Default value: FALSE
Since: 1.18
“width”
property “width” gint
The width of the canvas.
Flags: Read / Write
Allowed values: >= -1
Default value: -1
Since: 1.10
“draw”
signalgboolean user_function (ClutterCanvas *canvas, CairoContext *cr, gint width, gint 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