center align in labels
« on: 12 May 2018, 11:06:25 »
Hi Texus.

The center alignment when more than one lines exist, in my case in "buttons" but i can think that the same happening in "labels" also since "buttons" uses "labels", has not
correct align. All lines keep the first line start position. But each line has different count of chars.

It would be great if this would be implement at least in the new version of tgui. This, it would give me an extra motivation to start using 0.8 version sooner ;)

cheers


*

texus

  • *****
  • 1254
    • View Profile
    • Texus's Blog
Re: center align in labels
« Reply #1 on: 12 May 2018, 11:26:00 »
Labels already supports this, if they are given a size (via setSize) then you can use "label->setHorizontalAlignment(Label::HorizontalAlignment::Center)" to center the text. Widgets don't use labels internally anymore for performance reasons, the needed functionality was moved to a Text class (which Label also uses). But this text class if only meant to contain one line, the multi-line text and alignment are implemented directly in Label.

Buttons weren't supposed to have multiple lines of text on them.
At least it is already possible to create an empty button, put a label in front of it and call label->ignoreMouseEvents() to let clicks on the label reach the button.

Re: center align in labels
« Reply #2 on: 12 May 2018, 11:49:33 »
Ok,  i downloaded 0.8 and saw that buttons now using text. Just to clarify, lines in labels in 0.8 version keep center align accordingly to each line chars?

For example is it like this?
       Line 1
     My line 2
 Ok this is line 3

There are a lot of cases when translating a text from one language to another, texts can be much bigger. Setting auto the size can do the trick but the text can be
not-readable. In my case this is happening in button text very often.

« Last Edit: 12 May 2018, 11:53:52 by billarhos »

*

texus

  • *****
  • 1254
    • View Profile
    • Texus's Blog
Re: center align in labels
« Reply #3 on: 12 May 2018, 12:00:52 »
Quote
Just to clarify, lines in labels in 0.8 version keep center align accordingly to each line chars?
Yes, each line will be centered individually.

Re: center align in labels
« Reply #4 on: 12 May 2018, 12:07:16 »
Ok Texus thats great.
Talking about performance, have u made any performance test between 0.7 and 0.8 versions?

*

texus

  • *****
  • 1254
    • View Profile
    • Texus's Blog
Re: center align in labels
« Reply #5 on: 12 May 2018, 12:29:52 »
No, but I wouldn't be surprised if 0.8 was slower than 0.7 in some parts. Performance has never been an important factor so I don't measure it when making changes.
The performance difference I talk about with labels was about some widgets being completely unusable. Like how adding 500 lines to a ListBox required creating 500 labels (and creating widgets is rather slow), making it completely unusable. Most of these cases (like ListBox) where already solved in 0.7 though, but in 0.8 I unified the code in a Text class instead of having duplicate code in all these places where I stopped using labels.