diff --git a/clutter/clutter-paint-volume.c b/clutter/clutter-paint-volume.c index c770691dd..c60baf0ca 100644 --- a/clutter/clutter-paint-volume.c +++ b/clutter/clutter-paint-volume.c @@ -859,3 +859,40 @@ _clutter_actor_set_default_paint_volume (ClutterActor *self, return TRUE; } + +/** + * clutter_paint_volume_set_from_allocation: + * @pv: a #ClutterPaintVolume + * @actor: a #ClutterActor + * + * Sets the #ClutterPaintVolume from the allocation of @actor. + * + * This function should be used when overriding the + * get_paint_volume() by #ClutterActor sub-classes that do + * not paint outside their allocation. + * + * A typical example is: + * + * |[ + * static gboolean + * my_actor_get_paint_volume (ClutterActor *self, + * ClutterPaintVolume *volume) + * { + * return clutter_paint_volume_set_from_allocation (volume, self); + * } + * ]| + * + * Return value: %TRUE if the paint volume was successfully set, and %FALSE + * otherwise + * + * Since: 1.4 + */ +gboolean +clutter_paint_volume_set_from_allocation (ClutterPaintVolume *pv, + ClutterActor *actor) +{ + g_return_val_if_fail (pv != NULL, FALSE); + g_return_val_if_fail (CLUTTER_IS_ACTOR (actor), FALSE); + + return _clutter_actor_set_default_paint_volume (actor, G_TYPE_INVALID, pv); +} diff --git a/clutter/clutter-types.h b/clutter/clutter-types.h index 32420dbee..17cfbcfd2 100644 --- a/clutter/clutter-types.h +++ b/clutter/clutter-types.h @@ -456,24 +456,27 @@ typedef enum { GType clutter_paint_volume_get_type (void) G_GNUC_CONST; -ClutterPaintVolume *clutter_paint_volume_copy (const ClutterPaintVolume *pv); -void clutter_paint_volume_free (ClutterPaintVolume *pv); +ClutterPaintVolume *clutter_paint_volume_copy (const ClutterPaintVolume *pv); +void clutter_paint_volume_free (ClutterPaintVolume *pv); -void clutter_paint_volume_set_origin (ClutterPaintVolume *pv, - const ClutterVertex *origin); -void clutter_paint_volume_get_origin (const ClutterPaintVolume *pv, - ClutterVertex *vertex); -void clutter_paint_volume_set_width (ClutterPaintVolume *pv, - gfloat width); -gfloat clutter_paint_volume_get_width (const ClutterPaintVolume *pv); -void clutter_paint_volume_set_height (ClutterPaintVolume *pv, - gfloat height); -gfloat clutter_paint_volume_get_height (const ClutterPaintVolume *pv); -void clutter_paint_volume_set_depth (ClutterPaintVolume *pv, - gfloat depth); -gfloat clutter_paint_volume_get_depth (const ClutterPaintVolume *pv); -void clutter_paint_volume_union (ClutterPaintVolume *pv, - const ClutterPaintVolume *another_pv); +void clutter_paint_volume_set_origin (ClutterPaintVolume *pv, + const ClutterVertex *origin); +void clutter_paint_volume_get_origin (const ClutterPaintVolume *pv, + ClutterVertex *vertex); +void clutter_paint_volume_set_width (ClutterPaintVolume *pv, + gfloat width); +gfloat clutter_paint_volume_get_width (const ClutterPaintVolume *pv); +void clutter_paint_volume_set_height (ClutterPaintVolume *pv, + gfloat height); +gfloat clutter_paint_volume_get_height (const ClutterPaintVolume *pv); +void clutter_paint_volume_set_depth (ClutterPaintVolume *pv, + gfloat depth); +gfloat clutter_paint_volume_get_depth (const ClutterPaintVolume *pv); +void clutter_paint_volume_union (ClutterPaintVolume *pv, + const ClutterPaintVolume *another_pv); + +gboolean clutter_paint_volume_set_from_allocation (ClutterPaintVolume *pv, + ClutterActor *actor); G_END_DECLS