Hello, has anybody encounter this?
I want to implement composite actors that can have any number of
children, so my Widget class is a subclass of Actor and also implements
the Container interface.
According to Clutter docs:
"Container actors, or composite actors with internal children, should
call |clutter_actor_get_preferred_width()|
<http://docs.clutter-project.org/docs/clutter/1.4/ClutterActor.html#clutter-actor-get-preferred-width>
and |clutter_actor_get_preferred_height()|
<http://docs.clutter-project.org/docs/clutter/1.4/ClutterActor.html#clutter-actor-get-preferred-height>
on each visible child inside their implementation of the
|get_preferred_width()| and |get_preferred_height()| virtual functions."
Doing this works fine in my application (actors are allocated the
correct size), however I keep getting allocation cycle warnings that my
actor "is currently inside an allocation cycle; calling
clutter_actor_queue_relayout() is not recommended" . Below is a simple
example in Vala; any ideas on what I am doing wrong?
-----------------------------------------
public class Widget : Actor, Container {
protected LinkedList<Actor> children;
protected LayoutManager layout;
Widget(Widget? parent){
if (parent != null)
parent.add_actor(this);
}
construct {
children = new LinkedList<Actor>();
layout = new FixedLayout();
layout.set_container(this);
}
protected override void get_preferred_width (float for_height, out
float min_width_p, out float natural_width_p){
layout.get_preferred_width(this, for_height, out min_width_p,
out natural_width_p);
}
protected override void get_preferred_height (float for_width, out
float min_height_p, out float natural_height_p){
layout.get_preferred_height (this, for_width, out min_height_p,
out natural_height_p);
}
}
public class Image: Widget {
private Texture mytex;
public Image(Widget parent){
base(parent);
}
construct {
mytex = new *|Texture.from_file|* (|"image.jpg"|) ;
}
protected override void get_preferred_width (float for_height, out
float min_width_p, out float natural_width_p){
base.get_preferred_width(for_height, out min_width_p, out
natural_width_p);
float tmin,tnat;
mytex.get_preferred_width (for_height, out tmin, out tnat); //
<-- this triggers allocation cycle warnings
min_width_p = Math.fmaxf (min_width_p, tmin);
natural_width_p = Math.fmaxf (natural_width_p, tnat);
}
}
-----------------------------------------
thank you,
Dio.-
_______________________________________________
clutter-app-devel-list mailing list
[email protected]
http://lists.clutter-project.org/listinfo/clutter-app-devel-list