I have been playing around with clutter and have become a bit confused about how to work with Actors and child actors. Let's start with a simple example which has caused me some confusion. I create two Clutter::Rectangles (im using the Cluttermm bindings) and make the second the child of the first:
Glib::RefPtr<Clutter::Rectangle> rect = Clutter::Rectangle::create();
rect->set_color(Clutter::Color(255, 0, 0, 255));
rect->set_size(100, 100);
rect->set_position(500,500);
rect->show();
stage->add_actor(rect);
Glib::RefPtr<Clutter::Rectangle> rect2 = Clutter::Rectangle::create();
rect2->set_color(Clutter::Color(0, 255, 0, 255));
rect2->set_size(100, 100);
rect2->set_position(0,0);
rect2->set_parent(rect);
rect2->show();
From what I understand, this should make two rectangles visible, however rectangle2 is not. Despite making it the parent of the first rectangle, it is no where to be found. Why is this? What is the true meaning of set_parent()?
This confusion runs a bit deeper. Earlier today, I attempted to write a more complicated composite actor, which consists of a number of actors (e.g. rectangles, etc). While visually, this task was successful, I encountered serious difficulties when trying to affix event callbacks to these children actors -- in fact, as far as I could tell the events would NEVER reach the children of the parent actor.
This leaves me very confused. How would one, for example, create a button box using clutter? Would you have to create out your own actor detection/event management system, or is the only way to connect an event callback to a child actor by adding the child to the stage instead of the actual parent?
This had left me very confused and considering the current lack of literature, any help would be greatly appreciated!
a Rectangle is not a container: you cannot add children to one; or, at least, you can set the parent of an actor to be a non-container actor, but that actor won't be painted - which is most likely not what you want.
you should use a container actor and add rectangles to that container.
this is valid for Clutter ≤ 1.8, though; in the current stable version of Clutter (1.10) there have been various changes:
the API reference for ClutterActor should shed some light on the issue:
http://developer.gnome.org/clutter/stable/ClutterActor.html