Clutter.Canvas

g Clutter.Canvas Clutter.Canvas Clutter.Content Clutter.Content Clutter.Content->Clutter.Canvas GObject.GInterface GObject.GInterface GObject.GInterface->Clutter.Content GObject.Object GObject.Object GObject.Object->Clutter.Canvas

Subclasses:

None

Methods

Inherited:

GObject.Object (37), Clutter.Content (2)

Structs:

GObject.ObjectClass (5)

class

new ()

get_scale_factor ()

set_scale_factor (scale)

set_size (width, height)

Virtual Methods

Inherited:

GObject.Object (7), Clutter.Content (5)

do_draw (cr, width, height)

Properties

Name

Type

Flags

Short Description

height

int

r/w

The height of the canvas

scale-factor

int

r/w

The scaling factor for the surface

scale-factor-set

bool

r

Whether the scale-factor property is set

width

int

r/w

The width of the canvas

Signals

Inherited:

GObject.Object (1), Clutter.Content (2)

Name

Short Description

draw

The Clutter.Canvas ::draw signal is emitted each time a canvas is invalidated.

Fields

Inherited:

GObject.Object (1), Clutter.Content (2)

Name

Type

Access

Description

parent_instance

GObject.Object

r

Class Details

class Clutter.Canvas(**kwargs)
Bases:

GObject.Object, Clutter.Content

Abstract:

No

Structure:

Clutter.CanvasClass

The Clutter.Canvas structure contains private data and should only be accessed using the provided API.

New in version 1.10.

classmethod new()
Returns:

The newly allocated instance of Clutter.Canvas. Use GObject.Object.unref() when done.

Return type:

Clutter.Content

Creates a new instance of Clutter.Canvas.

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.

New in version 1.10.

get_scale_factor()
Returns:

the scaling factor, or -1 if the self uses the default from Clutter.Settings

Return type:

int

Retrieves the scaling factor of self, as set using Clutter.Canvas.set_scale_factor().

New in version 1.18.

set_scale_factor(scale)
Parameters:

scale (int) – the scale factor, or -1 for the default

Sets the scaling factor for the Cairo surface used by self.

This function should rarely be used.

The default scaling factor of a Clutter.Canvas content uses the Clutter.Settings :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 self.

New in version 1.18.

set_size(width, height)
Parameters:
  • width (int) – the width of the canvas, in pixels

  • height (int) – the height of the canvas, in pixels

Returns:

this function returns True if the size change caused a content invalidation, and False otherwise

Return type:

bool

Sets the size of the self, and invalidates the content.

This function will cause the self to be invalidated only if the size of the canvas surface has changed.

If you want to invalidate the contents of the self when setting the size, you can use the return value of the function to conditionally call Clutter.Content.invalidate():

if (!clutter_canvas_set_size (canvas, width, height))
clutter_content_invalidate (CLUTTER_CONTENT (canvas));

New in version 1.10.

do_draw(cr, width, height) virtual
Parameters:
Return type:

bool

Signal Details

Clutter.Canvas.signals.draw(canvas, cr, width, height)
Signal Name:

draw

Flags:

RUN_LAST, NO_RECURSE

Parameters:
  • canvas (Clutter.Canvas) – The object which received the signal

  • cr (cairo.Context) – the Cairo context used to draw

  • width (int) – the width of the canvas

  • height (int) – the height of the canvas

Returns:

True if the signal emission should stop, and False otherwise

Return type:

bool

The Clutter.Canvas ::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.Context.save() and cairo.Context.restore() pairs.

New in version 1.10.

Property Details

Clutter.Canvas.props.height
Name:

height

Type:

int

Default Value:

-1

Flags:

READABLE, WRITABLE

The height of the canvas.

New in version 1.10.

Clutter.Canvas.props.scale_factor
Name:

scale-factor

Type:

int

Default Value:

-1

Flags:

READABLE, WRITABLE

The scaling factor to be applied to the Cairo surface used for drawing.

If Clutter.Canvas :scale-factor is set to a negative value, the value of the Clutter.Settings :window-scaling-factor property is used instead.

Use Clutter.Canvas :scale-factor-set to check if the scale factor is set.

New in version 1.18.

Clutter.Canvas.props.scale_factor_set
Name:

scale-factor-set

Type:

bool

Default Value:

False

Flags:

READABLE

Whether the Clutter.Canvas :scale-factor property is set.

If the Clutter.Canvas :scale-factor-set property is False then Clutter.Canvas will use the Clutter.Settings :window-scaling-factor property.

New in version 1.18.

Clutter.Canvas.props.width
Name:

width

Type:

int

Default Value:

-1

Flags:

READABLE, WRITABLE

The width of the canvas.

New in version 1.10.