godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.16k stars 97 forks source link

Add vertical alignment option to RichTextLabel #6674

Open muno777 opened 1 year ago

muno777 commented 1 year ago

Describe the project you are working on

A menu system for my game, using RichTextLabels instead of regular Button text for more flexibility.

Describe the problem or limitation you are having in your project

There's currently no way to vertically center or bottom-align the text within a RichTextLabel, which is needed for the style of my menu elements.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Add an option to apply vertical alignment to the entire RichTextLabel's contents, similar to the vertical alignment property on a regular Label.

This is distinct from #4458, since that proposal includes dedicated vertical centering BBCode tags. This proposal instead applies the centering to the entire RichTextLabel - which I suspect would be a little simpler to implement, while still fulfilling most/all use cases.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

The option could be a simple drop-down property:

image

Top:

image

Center:

image

Bottom:

image

(All of these are just screenshots of a regular Label)

If this enhancement will not be used often, can it be worked around with a few lines of script?

This can be worked around by adding a container around the RichTextLabel, but this is less convenient than having it built-in like with a regular Label.

Is there a reason why this should be core and not an add-on in the asset library?

This is basic functionality for the RichTextLabel.

AThousandShips commented 1 year ago

The other suggestion is compatible with the fact that RichTextLabel doesn't align the text horizontally either, it's designed to use the bbcode, it seems strange to just allow vertical alignment

muno777 commented 1 year ago

Yeah it would be a little weird to have just the vertical alignment as a property while the horizontal alignment is done thru bbcode haha.

On the other hand, I think vertical alignment is maybe better suited as a textbox-wide property anyway? It's not clear to me what should happen if, for example, only part of a textbox's contents are vertically centered. Horizontal alignment is a lot easier to imagine mix-and-matching since it just happens on a new line. Plus, horizontal alignment is a common bbcode tag, whereas vertical alignment isn't (possibly for this reason?).

I also think it'd be pretty reasonable to add horizontal alignment as a property to go along with the vertical, but of course it isn't as necessary since you can just use bbcode.

animentork commented 4 months ago

Hardly a solution, but I get around this by putting RichTextLabel in a VBoxLayout with alignment set to ALIGNMENT_CENTER and size_flags_vertical to SIZE_FILL | SIZE_EXPAND.