2019-07-03 08:04 AM
Hi,
I am struggling with text alignment. I hoped that I could center aligning a text in a text area vertically. But it seems har to do.
I have had som fun in TouchGFX Designer aligning some texts.
It is the same text in all fields, and the text areas fills the rectangles. First column is left aligned, center column is center aligned, and the right column is right aligned.
First row in text is rotation 0°, second is 180° and third is in 90°.
I do not understand the algorithm when choosing a different rotation than 0°. But it seems that the text are aligned in two independent domains:
But how do I align the text in the center of a field in both horizontal and vertical direction? It seems only possible if you choose 90° rotation. (and probably also 270°)
If you ask me, there should be independent horizontal and vertical alignment settings.
Here is an example from emWin (GUI builder in last century style):
BR
Kasper
2019-07-09 05:24 AM
Hi,
There's no api function to align a text vertically. You have to do this manually, currently, using getTextHeight() and also measuring the space above the text to the "ceiling" of your textarea. Someone else here just had the same issue, let me try to find the post for you.
/Martin
2019-07-09 05:59 AM
2019-07-10 06:01 AM
Hi Martin
Thanks. I was looking forward for a better solution. This is definitely TouchGFX must do better in the future. Just lik my other post:
https://community.st.com/s/question/0D50X0000B2AQR3SQO/texturemapper-and-orientationportrait
Kasper
2019-07-10 06:11 AM
I will try to confirm the texturemapper-in-portrait-mode tomorrow :) The reason why we haven't done vertical centering, i think, is because its a little odd to do. Application developers are usually told to put things at certain coordinates from their UX people - This is difficult to achieve using centering. Sometmies it makes sense to horizontally, but almost never vertically.
/Martin
2024-08-02 10:14 AM - edited 2024-08-02 10:16 AM
Sorry to necro, but this is a serious deficiency. Basically we have to calculate the position of *every* screen element that's not edge-justified. Even "static" text is variable size when you consider almost every use will have localized variants. Maybe we're supposed to create a different text element for every localized version of a string, show / hide them, and position them statically? I hope not.
Vertical centering is a thing also.