-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
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/
iQEcBAEBAgAGBQJMTit+AAoJEA3CodwzRLMmRDYH/jY6U33uA6P/cziSIWoPEzhg
eRygpG99qTsriRnNzkUIb/BpLZKuItDtuVLxG1yYsHQFdEijamj1yg/xLye+jozp
b+X63BY2yrczk/W/FLIy1kigojnvkECQueCfadiLLVramwNn+TurhWRktbQFSlj0
8rMWuCc/IBsimQaQ+DLlzNbYvxCVONdAbQp+3qkopRZCuvFR4FBFjeZ6BRMjmgOc
ekYplpYjvtfigXpoSqtPriwKnEOkgfn3jgFBQo0mdRcDYHqo9aOvwOFIcu3oJUVI
MoOgrHzi4FQUzs8V0VVQ03K6HyTB2tNp9JxUa0nR71e38eTUSz11b7Iut3jmraE=
=fvyl
-----END PGP SIGNATURE-----
_______________________________________________
clutter-app-devel-list mailing list
[email protected]
http://lists.clutter-project.org/listinfo/clutter-app-devel-list