Hi

(sorry if I've sent this twice, I'm having a bit of trouble with my mail
client)

On Tue, 23 Mar 2010 14:00:50 -0500, Uday Verma <uday.ka...@gmail.com> wrote:
> I am trying to animate a sub-actor inside a ClutterActor but I can't
> seem to be able to do so.
> 
> I have an actor A which contains several Bs, A is not a container but
> a regular actor.  I have a add method which adds B to A, and in the
> process does B.set_parent (A).
> 
> 1.  When I do so, right after the parenting operation I set the
> position and dimensions of B.  The position and dimension requests are
> not being regarded and according to --clutter-flags=paint, the
> allocation of actor B is {0,0,0,0}.  I wonder why that is when I am
> explicitly setting the size and position.  The only way I could get
> the actor B to appear was by explicitly setting the allocation of
> actor B to the desired location.

Setting the size of an actor just replaces the preferred and minimum
sizes that would be returned by get_preferred_with/height. The actor
still needs to be allocated to get an actual size. Any actor that has
children must implement the allocate method to call allocate on its
children. Your allocate method should be something like this (note I
don't know Vala so I'm just guessing):

public override void allocate (Clutter.Actor actor,
                               Clutter.ActorBox box,
                               Clutter.AllocationFlags flags)
{
  /* Chain up so we still get an allocation (I don't know Vala's syntax
     for this so I'll use C++) */
  actor.ClutterActor::allocate (actor, box, flags);

  /* Allocate all of the children at their natural size and position */
  foreach (var a in children.values)
    a.allocate_preferred_size ();
}

You also need to implement paint, pick, map and unmap in a similar
way. You can get away without pick if the children don't need to handle
events and it will work without map and unmap if you always add actors
after the container is mapped (but it's cleaner just to implement them).

- Neil
-- 
To unsubscribe send a mail to clutter+unsubscr...@o-hand.com

Reply via email to