set_allocation


Description:

[ Version ( since = "1.10" ) ]
public void set_allocation (ActorBox box, AllocationFlags flags)

Stores the allocation of this as defined by box.

This function can only be called from within the implementation of the allocate virtual function.

The allocation should have been adjusted to take into account constraints, alignment, and margin properties. If you are implementing a Actor subclass that provides its own layout management policy for its children instead of using a LayoutManager delegate, you should not call this function on the children of this; instead, you should call allocate, which will adjust the allocation box for you.

This function should only be used by subclasses of Actor that wish to store their allocation but cannot chain up to the parent's implementation; the default implementation of the allocate virtual function will call this function.

It is important to note that, while chaining up was the recommended behaviour for Actor subclasses prior to the introduction of this function, it is recommended to call set_allocation instead.

If the Actor is using a LayoutManager delegate object to handle the allocation of its children, this function will call the allocate function only if the DELEGATE_LAYOUT flag is set on flags, otherwise it is expected that the subclass will call allocate by itself. For instance, the following code:

static void
my_actor_allocate (ClutterActor *actor,
const ClutterActorBox *allocation,
ClutterAllocationFlags flags)
{
ClutterActorBox new_alloc;
ClutterAllocationFlags new_flags;

adjust_allocation (allocation, &new_alloc);

new_flags = flags | CLUTTER_DELEGATE_LAYOUT;

// this will use the layout manager set on the actor
clutter_actor_set_allocation (actor, &new_alloc, new_flags);
}

is equivalent to this:

static void
my_actor_allocate (ClutterActor *actor,
const ClutterActorBox *allocation,
ClutterAllocationFlags flags)
{
ClutterLayoutManager *layout;
ClutterActorBox new_alloc;

adjust_allocation (allocation, &new_alloc);

clutter_actor_set_allocation (actor, &new_alloc, flags);

layout = clutter_actor_get_layout_manager (actor);
clutter_layout_manager_allocate (layout,
CLUTTER_CONTAINER (actor),
&new_alloc,
flags);
}

Parameters:

this

a Actor

box

a ActorBox

flags

allocation flags




2022 vala-language.org