Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add vertical alignment option to RichTextLabel #6674

Closed
muno777 opened this issue Apr 10, 2023 · 3 comments · Fixed by godotengine/godot#97963
Closed

Add vertical alignment option to RichTextLabel #6674

muno777 opened this issue Apr 10, 2023 · 3 comments · Fixed by godotengine/godot#97963
Milestone

Comments

@muno777
Copy link

muno777 commented Apr 10, 2023

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
Copy link
Member

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
Copy link
Author

muno777 commented Apr 10, 2023

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
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants