Why doesn't setTextSize take a layout as parameter ?

Started by Nafffen, 01 August 2023, 09:44:37


Wouldn't be useful to have setTextSize of Widget take a Layout as parameter ? Now if I want to change text size when parent resize, I have to set a callback on onSizeChange signal.


I'm not convinced that there are many cases where it is useful.

In early TGUI versions text was auto-sizing almost everywhere: if the height of a button increased then so did the text size (which actually still happens if you were to set its text size to 0). This was however one of the main reasons why TGUI looked terribly inconsistent: every widget was using a slightly different text size. The change to a global consistent text size is not something that I would want to revert.

I do realize that it is currently hard to make the gui scalable without manually setting the text size every time, but I haven't found a good solution to this problem yet. I'm not convinced that text size should be scaled PER widget, which is why I don't like the idea of making the value a layout. I feel like there needs to be some way to scale the text size for the entire scene, such as e.g. passing a layout to gui.setTextSize(). That would be more limited, but enough for many cases.

One improvement I made while looking into DPI awareness was a way to scale the entire window as long as the aspect ratio stays the same. Although this information is placed inside the High-DPI tutorial, it is relevant for any case where you want to scale the entire gui (as long as the aspect ratio is kept): https://tgui.eu/tutorials/1.0/dpi-scaling/#scaling-tgui

At least with manually setting the text size in onSizeChange you have full control over what happens. It might be annoying if you have to set the text size widget by widget, but normally you would only need to set it in some parent widget to apply it everywhere (so you don't need much code).