Commit b77d9a6d authored by Emmanuele Bassi's avatar Emmanuele Bassi Committed by Robert Bragg

paint-volume: Add convenience function for using an allocation

Classes overriding ClutterActor::get_paint_volume() that wish to use
their allocation as the paint volume should have an idiomatic way of
doing so.
parent 5640a650
......@@ -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
* <function>get_paint_volume()</function> 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);
}
......@@ -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);
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);
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);
gboolean clutter_paint_volume_set_from_allocation (ClutterPaintVolume *pv,
ClutterActor *actor);
G_END_DECLS
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment