-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
(apologies if the message is duplicated. I sent it from the wrong email
address before)
Hello,
I am implementing a composite actor which will have a Text inside. I am
trying to resize the text font within the allocate method, but I keep
getting allocation cycle warnings. What am I doing wrong?
This is my code in Vala:
=================================================================
using Clutter;
class Key : Actor {
private Text _label;
construct {
}
public Key(string label, string font = "Arial Bold 50px") {
this.name = label;
_label = new Text.full(font,label,Color.from_string("white"));
_label.set_parent(this);
}
protected override void allocate(ActorBox box,
AllocationFlags flags){
base.allocate(box, flags);
float width = box.get_width()*0.9f;
_label.font_name = "Arial Bold " + width.to_string() + "px";
_label.allocate(box,flags);
}
public override void get_preferred_width (float for_height, out float
min_width_p, out float natural_width_p){
_label.get_preferred_width (for_height, out min_width_p,
out natural_width_p);
}
public override void get_preferred_height (float for_width, out float
min_height_p, out float natural_height_p){
_label.get_preferred_height (for_width, out min_height_p,
out natural_height_p);
}
protected override void paint() {
_label.paint();
}
protected override void pick(Clutter.Color c){
if (should_pick_paint()) {
_label.paint();
}
}
protected override void map() {
base.map();
_label.map();
}
protected override void unmap() {
_label.unmap();
base.unmap();
}
}
//test function
public Box construct_keyboard() {
BoxLayout layout = new BoxLayout();
layout.spacing = 5;
layout.vertical = false;
Box keyboard = new Box(layout);
string[] alphabet = {"A", "B", "C", "D"};
foreach (string letter in alphabet) {
Key k = new Key(letter);
keyboard.pack(k);
}
return keyboard;
}
//in my main:
{
var s = construct_keyboard();
stage.add_actor(s);
}
=================================================================
Setting _label.font_name within the allocate() method
is triggering the allocation cycle warning for every actor:
Clutter-WARNING **: The actor 'A' is currently inside an allocation
cycle; calling clutter_actor_queue_relayout() is not recommended
Thank you,
Dio.-
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/
iQEcBAEBAgAGBQJMTi8EAAoJEA3CodwzRLMmZL4H/1IMJ4bAvBLCLOHJtxvCdJzS
KFHZB4h+LLwQY9dG1yN7GcuYBCt6nC2N8c1g5DeTT3gVGT8xaQDhWn+Z9TmnaaWW
1j8bxgdW+ym6dLWRwmrkwK9qSiHaCH5sC8G7NxhItBReuru3Fq8KO+d73IkGr4NB
S3ciyCeqjVyOekUg8YAyTIKxZczYFApjI9sJzn6lYsETvzFvGvt9EFE9fEwt/HIe
fpu/CGYBGm9o1CDi1NMS9TRq/W2EGDO1mZDgWMi9dt+F6zFEYI0oITYfTPrLNeGf
8PKMIesLeA05OnDazrduHY3X+PDgRQgIAAjggcZ2qHxJRq+8j8XjYpEX4CHqwcM=
=x7Gm
-----END PGP SIGNATURE-----
_______________________________________________
clutter-app-devel-list mailing list
[email protected]
http://lists.clutter-project.org/listinfo/clutter-app-devel-list