CtkLayer

CtkLayer — Helper class for implementing layered actors

Synopsis

enum                CtkLayerRepeatMode;
                    CtkLayer;
                    CtkLayerClass;
                    CtkLayerPrivate;
CtkLayer *          ctk_layer_new                       (guint width,
                                                         guint height,
                                                         CtkLayerRepeatMode image_repeat,
                                                         CtkLayerRepeatMode mask_repeat);
guint               ctk_layer_get_width                 (CtkLayer *self);
void                ctk_layer_set_width                 (CtkLayer *self,
                                                         guint width);
guint               ctk_layer_get_height                (CtkLayer *self);
void                ctk_layer_set_height                (CtkLayer *self,
                                                         guint height);
void                ctk_layer_get_color                 (CtkLayer *self,
                                                         ClutterColor *color);
void                ctk_layer_set_color                 (CtkLayer *self,
                                                         ClutterColor *color);
guint8              ctk_layer_get_opacity               (CtkLayer *self);
void                ctk_layer_set_opacity               (CtkLayer *self,
                                                         guint8 opacity);
void                ctk_layer_set_image_pixbuf          (CtkLayer *self,
                                                         GdkPixbuf *pixbuf);
GdkPixbuf *         ctk_layer_get_image_pixbuf          (CtkLayer *self);
void                ctk_layer_set_mask_pixbuf           (CtkLayer *self,
                                                         GdkPixbuf *pixbuf);
GdkPixbuf *         ctk_layer_get_mask_pixbuf           (CtkLayer *self);
void                ctk_layer_set_image_from_file       (CtkLayer *self,
                                                         gchar *filename);
void                ctk_layer_set_image_from_pixbuf     (CtkLayer *self,
                                                         GdkPixbuf *pixbuf);
void                ctk_layer_set_image_from_surface    (CtkLayer *self,
                                                         cairo_surface_t *surface);
void                ctk_layer_set_mask_from_file        (CtkLayer *self,
                                                         gchar *filename);
void                ctk_layer_set_mask_from_pixbuf      (CtkLayer *self,
                                                         GdkPixbuf *pixbuf);
void                ctk_layer_set_mask_from_surface     (CtkLayer *self,
                                                         cairo_surface_t *surface);
void                ctk_layer_set_image_from_id         (CtkLayer *self,
                                                         guint id);
void                ctk_layer_set_mask_from_id          (CtkLayer *self,
                                                         guint id);
guint               ctk_layer_get_image_id              (CtkLayer *self);
guint               ctk_layer_get_mask_id               (CtkLayer *self);
void                ctk_layer_set_image_repeat_mode     (CtkLayer *self,
                                                         CtkLayerRepeatMode repeat);
CtkLayerRepeatMode  ctk_layer_get_image_repeat_mode     (CtkLayer *self);
void                ctk_layer_set_mask_repeat_mode      (CtkLayer *self,
                                                         CtkLayerRepeatMode repeat);
CtkLayerRepeatMode  ctk_layer_get_mask_repeat_mode      (CtkLayer *self);
gboolean            ctk_layer_is_valid                  (CtkLayer *self);
gboolean            ctk_layer_get_enabled               (CtkLayer *self);
void                ctk_layer_set_enabled               (CtkLayer *self,
                                                         gboolean enabled);

Object Hierarchy

  GObject
   +----CtkLayer

Properties

  "color"                    ClutterColor*         : Read / Write
  "enabled"                  gboolean              : Read / Write
  "height"                   guint                 : Read / Write
  "image-id"                 guint                 : Read
  "image-pixbuf"             GdkPixbuf*            : Read / Write
  "image-repeat-mode"        guint                 : Read / Write
  "mask-id"                  guint                 : Read
  "mask-pixbuf"              GdkPixbuf*            : Read / Write
  "mask-repeat-mode"         guint                 : Read / Write
  "opacity"                  guint                 : Read / Write
  "valid"                    gboolean              : Read
  "width"                    guint                 : Read / Write

Description

CtkLayer is a class holding an image or solid color with an associated, but optional, mask. It cannot render itself but is used for painting in class CtkLayerActor.

Details

enum CtkLayerRepeatMode

typedef enum _CtkLayerRepeatMode
{
  CTK_LAYER_REPEAT_NONE = 0,
  CTK_LAYER_REPEAT_X,
  CTK_LAYER_REPEAT_Y,
} CtkLayerRepeatMode;


CtkLayer

typedef struct _CtkLayer CtkLayer;


CtkLayerClass

typedef struct {
  GObjectClass parent_class;
} CtkLayerClass;


CtkLayerPrivate

typedef struct _CtkLayerPrivate CtkLayerPrivate;


ctk_layer_new ()

CtkLayer *          ctk_layer_new                       (guint width,
                                                         guint height,
                                                         CtkLayerRepeatMode image_repeat,
                                                         CtkLayerRepeatMode mask_repeat);

Creates a new CtkLayer with width width and height height. image_repeat and mask_repeat need to be passed in too, but are not taking into account yet. Only CTK_LAYER_REPEAT_NONE is used for both at the moment.

width :

a guint

height :

a guint

image_repeat :

a CtkLayerRepeatMode

mask_repeat :

a CtkLayerRepeatMode

Returns :

a CtkLayer or NULL in an error-case

ctk_layer_get_width ()

guint               ctk_layer_get_width                 (CtkLayer *self);

Get the width of self.

self :

a CtkLayer

Returns :

a guint

ctk_layer_set_width ()

void                ctk_layer_set_width                 (CtkLayer *self,
                                                         guint width);

Set the width of self. If width is set after a previously set image or mask and does not match their respective width, self will be marked as invalid and thus will not be rendered, if added to a CtkLayerActor.

self :

a CtkLayer

width :

a guint

ctk_layer_get_height ()

guint               ctk_layer_get_height                (CtkLayer *self);

Get the height of self.

self :

a CtkLayer

Returns :

a guint

ctk_layer_set_height ()

void                ctk_layer_set_height                (CtkLayer *self,
                                                         guint height);

Set the height of self. If height is set after a previously set image or mask and does not match their respective height, self will be marked as invalid and thus will not be rendered, if added to a CtkLayerActor.

self :

a CtkLayer

height :

a guint

ctk_layer_get_color ()

void                ctk_layer_get_color                 (CtkLayer *self,
                                                         ClutterColor *color);

Copy the color of self to the ClutterColor pointed to by color. If you pass a NULL-pointer for color nothing happens.

If you only need to get the opacity use #ctk_layer_get_opacity() instead.

self :

a CtkLayer

color :

a ClutterColor

ctk_layer_set_color ()

void                ctk_layer_set_color                 (CtkLayer *self,
                                                         ClutterColor *color);

Set the red-, green-, blue- and alpha-component of self. If color or self is a NULL-pointer nothing happens.

color is used if self only consists of a mask but no image.

If you only need to set the opacity use #ctk_layer_set_opacity() instead.

self :

a CtkLayer

color :

a ClutterColor

ctk_layer_get_opacity ()

guint8              ctk_layer_get_opacity               (CtkLayer *self);

Grab the opacity- or alpha-component of self. If you pass in a NULL-pointer for self this will return 0.

self :

a CtkLayer

Returns :

a guint8

ctk_layer_set_opacity ()

void                ctk_layer_set_opacity               (CtkLayer *self,
                                                         guint8 opacity);

Set the alpha- or opacity-component of self. This is mostly used with layers which have an image and mask defined.

If you pass in a NULL-pointer for self this call does nothing.

self :

a CtkLayer

opacity :

a guint8

ctk_layer_set_image_pixbuf ()

void                ctk_layer_set_image_pixbuf          (CtkLayer *self,
                                                         GdkPixbuf *pixbuf);

Set the image's pixbuf of self directly. This will reference pixbuf.

self :

a CtkLayer

pixbuf :

a pointer to a GdkPixbuf

ctk_layer_get_image_pixbuf ()

GdkPixbuf *         ctk_layer_get_image_pixbuf          (CtkLayer *self);

Get the pixbuf of self's image, if one is set.

self :

a CtkLayer

Returns :

a pointer to a GdkPixbuf

ctk_layer_set_mask_pixbuf ()

void                ctk_layer_set_mask_pixbuf           (CtkLayer *self,
                                                         GdkPixbuf *pixbuf);

Set the mask's pixbuf of self directly. This will reference pixbuf.

self :

a CtkLayer

pixbuf :

a pointer to a GdkPixbuf

ctk_layer_get_mask_pixbuf ()

GdkPixbuf *         ctk_layer_get_mask_pixbuf           (CtkLayer *self);

Get the pixbuf of self's mask, if one is set.

self :

a CtkLayer

Returns :

a pointer to a GtkPixbuf

ctk_layer_set_image_from_file ()

void                ctk_layer_set_image_from_file       (CtkLayer *self,
                                                         gchar *filename);

Set the image of self by loading the image from filename. Any pre-existing image will be replaced. If something during loading filename goes wrong self will be marked as invalid.

self :

a CtkLayer

filename :

a pointer to a gchar

ctk_layer_set_image_from_pixbuf ()

void                ctk_layer_set_image_from_pixbuf     (CtkLayer *self,
                                                         GdkPixbuf *pixbuf);

Set the image of self by grabbing the pixel-data from pixbuf.

After this call you can free and delete pixbuf. No copy or reference of it is kept.

self :

a CtkLayer

pixbuf :

a GdkPixbuf

ctk_layer_set_image_from_surface ()

void                ctk_layer_set_image_from_surface    (CtkLayer *self,
                                                         cairo_surface_t *surface);

Set the image of self by grabbing the pixel-data from surface. surface needs to be a cairo image-surface. Any pre-existing image will be replaced.

After this call you can free and delete surface. No copy or reference of it is kept.

self :

a CtkLayer

surface :

a cairo_surface_t*

ctk_layer_set_mask_from_file ()

void                ctk_layer_set_mask_from_file        (CtkLayer *self,
                                                         gchar *filename);

Set the mask of self by loading the image from filename. Any pre-existing mask will be replaced. If something during loading filename goes wrong self will be marked as invalid.

self :

a CtkLayer

filename :

a pointer to a gchar

ctk_layer_set_mask_from_pixbuf ()

void                ctk_layer_set_mask_from_pixbuf      (CtkLayer *self,
                                                         GdkPixbuf *pixbuf);

Sets self's mask from a GdkPixbuf pixbuf. Any pre-existing mask will be removed by this call. Remember that the passed in surface needs to be of the same width and height as self. If surface is not an image-surface this call has no effect.

After this call you can free pixbuf. It is not referenced or copied. A texture is created and uploaded to the GPU.

self :

a CtkLayer

pixbuf :

a GdkPixbuf

ctk_layer_set_mask_from_surface ()

void                ctk_layer_set_mask_from_surface     (CtkLayer *self,
                                                         cairo_surface_t *surface);

Sets self's mask from a cairo image-surface surface. Any pre-existing mask will be removed by this call. Remember that the passed in surface needs to be of the same width and height as self. If surface is not an image-surface this call has no effect.

After this call you can free surface. It is not referenced or copied. A texture is created and uploaded to the GPU.

self :

a CtkLayer

surface :

a cairo_surface_t

ctk_layer_set_image_from_id ()

void                ctk_layer_set_image_from_id         (CtkLayer *self,
                                                         guint id);

Sets self's image from an OpenGL-texture ID id. Any pre-existing image will be removed by this call. Remember that the passed in id needs to belong to a texture with the same width and height as self has.

The texture pointed to by id is NOT cloned. Don't delete after this call!

self :

a CtkLayer

id :

a guint

ctk_layer_set_mask_from_id ()

void                ctk_layer_set_mask_from_id          (CtkLayer *self,
                                                         guint id);

Sets self's mask from an OpenGL-texture ID id. Any pre-existing mask will be removed by this call. Remember that the passed in id needs to belong to a texture with the same width and height as self has.

The texture pointed to by id is NOT cloned. Don't delete after this call!

self :

a CtkLayer

id :

a guint

ctk_layer_get_image_id ()

guint               ctk_layer_get_image_id              (CtkLayer *self);

Gets the OpenGL-texture ID of self's image.

self :

a CtkLayer

Returns :

a guint

ctk_layer_get_mask_id ()

guint               ctk_layer_get_mask_id               (CtkLayer *self);

Gets the OpenGL-texture ID of self's mask.

self :

a CtkLayer

Returns :

a guint

ctk_layer_set_image_repeat_mode ()

void                ctk_layer_set_image_repeat_mode     (CtkLayer *self,
                                                         CtkLayerRepeatMode repeat);

Set the repeat-mode of self's image. This can be set, but is not taken into account yet. Sofar only CTK_LAYER_REPEAT_NONE is always applied no matter what you set here.

self :

a CtkLayer

repeat :

a CtkLayerRepeatMode

ctk_layer_get_image_repeat_mode ()

CtkLayerRepeatMode  ctk_layer_get_image_repeat_mode     (CtkLayer *self);

Get the of repeat-mode of self's image.

self :

a CtkLayer

Returns :

a CtkLayerRepeatMode

ctk_layer_set_mask_repeat_mode ()

void                ctk_layer_set_mask_repeat_mode      (CtkLayer *self,
                                                         CtkLayerRepeatMode repeat);

Set the repeat-mode of self's mask. This can be set, but is not taken into account yet. Sofar only CTK_LAYER_REPEAT_NONE is always applied no matter what you set here.

self :

a CtkLayer

repeat :

a CtkLayerRepeatMode

ctk_layer_get_mask_repeat_mode ()

CtkLayerRepeatMode  ctk_layer_get_mask_repeat_mode      (CtkLayer *self);

Get the of repeat-mode of self's mask.

self :

a CtkLayer

Returns :

a CtkLayerRepeatMode

ctk_layer_is_valid ()

gboolean            ctk_layer_is_valid                  (CtkLayer *self);

Get the validity-state of self. A CtkLayer may be invalid if image and mask provided for it are not of the same size.

self :

a CtkLayer

Returns :

a gboolean, TRUE if valid or FALSE if not or an error occured

ctk_layer_get_enabled ()

gboolean            ctk_layer_get_enabled               (CtkLayer *self);

Get the enabled-state of self.

self :

a CtkLayer

Returns :

a gboolean, TRUE if enabled or FALSE if not or an error occured

ctk_layer_set_enabled ()

void                ctk_layer_set_enabled               (CtkLayer *self,
                                                         gboolean enabled);

self :

enabled :

Property Details

The "color" property

  "color"                    ClutterColor*         : Read / Write

Solid RGBA-color of layer.


The "enabled" property

  "enabled"                  gboolean              : Read / Write

Indicator-flag telling if layer is enabled.

Default value: TRUE


The "height" property

  "height"                   guint                 : Read / Write

Height of layer in pixels.

Default value: 0


The "image-id" property

  "image-id"                 guint                 : Read

OpenGL ID of layer-image.

Default value: 0


The "image-pixbuf" property

  "image-pixbuf"             GdkPixbuf*            : Read / Write

GdkPixbuf of layer-image.


The "image-repeat-mode" property

  "image-repeat-mode"        guint                 : Read / Write

Repeat-mode of layer-image.

Allowed values: <= 3

Default value: 0


The "mask-id" property

  "mask-id"                  guint                 : Read

OpenGL ID of layer-mask.

Default value: 0


The "mask-pixbuf" property

  "mask-pixbuf"              GdkPixbuf*            : Read / Write

GdkPixbuf of layer-mask.


The "mask-repeat-mode" property

  "mask-repeat-mode"         guint                 : Read / Write

Repeat-mode of layer-mask.

Allowed values: <= 3

Default value: 0


The "opacity" property

  "opacity"                  guint                 : Read / Write

Opacity of layer (A-component of color).

Default value: 0


The "valid" property

  "valid"                    gboolean              : Read

State-indicator.

Default value: FALSE


The "width" property

  "width"                    guint                 : Read / Write

Width of layer in pixels.

Default value: 0

See Also

CtkLayerActorinclude ctk-layer.h