Problem with Bind and setAutoSize

Started by crdl_pls, 12 June 2017, 05:27:21


I'm trying to create a label that will automatically centre itself. I'm attempting to do this:
label->setPosition(screenSize.x / 2.f - bindWidth(label)/2.f, YVALUE);

So no matter what I set the text to, in theory, the width should adjust accordingly, and then the position should change based on the width.
However, it seems that bindWidth(label) isn't updating when the length changes, and label has no text value until I change it, bindWidth(label) is always 0.

In the image "Get Ready!!!" is the label.

Any ideas? The width is changing correctly but that doesn't seem to affect the binding.


This was a bug in TGUI, changing the text did not sent a SizeChanged event to which bindWidth subscribes.
I have fixed this in the latest version. You can download the latest version (which will eventually be released as v0.7.5) and build that TGUI version yourself with cmake.