GUI - Automatically measuring TextBlock size
GUI - Automatically measuring TextBlock size

The goal is to have TextBlocks automatically set their own width and height according to their measured text size, instead of having to manually set it for each case - which seems tedious and redundant to me.

It can be optional, but working quite a lot with GUI lately I can say this will make TextBlocks much easier and dynamic.

It's very rough as you can see, but the idea is calculating the width and height of a TextBlock every time it's rendered, and setting it to the control.

Issues:

1) Setting width and height at the moment sets the control as dirty which results in infinitely re-rendering it.
2) Doesn't seem to scale properly with idealWidth.
3) Need to calculate the height, probably something like this?

https://stackoverflow.com/questions/1134586/how-can-you-find-the-height-of-text-on-an-html-canvas

A different way to make it optional is to provide a measureText() function in TextBlock which returns accurately measured width and height, then the user can choose if/how to use this information.

I'm using this code to test the TextBlock's borders:
http://www.babylonjs-playground.com/#JR21MP#2

abow/Babylon.js,Temechon/Babylon.js,Temechon/Babylon.js,jbousquie/Babylon.js,RaananW/Babylon.js,sebavan/Babylon.js,Kesshi/Babylon.js,RaananW/Babylon.js,Hersir88/Babylon.js,Kesshi/Babylon.js,RaananW/Babylon.js,BabylonJS/Babylon.js,BabylonJS/Babylon.js,BabylonJS/Babylon.js,NicolasBuecher/Babylon.js,Kesshi/Babylon.js,abow/Babylon.js,abow/Babylon.js,Hersir88/Babylon.js,NicolasBuecher/Babylon.js,sebavan/Babylon.js,Hersir88/Babylon.js,NicolasBuecher/Babylon.js,jbousquie/Babylon.js,Temechon/Babylon.js,sebavan/Babylon.js,jbousquie/Babylon.js