Rotated label in a container
Asked Answered
L

17

0

Let's say I have a VBoxContainer with a button and 4 labels in it. I want labels to be rotated so they are vertical, with their text going from bottom to top. Also, VBox height should follow the length of the longest label. How this can be done? (I'm using Godot 3.4.3)

Lisandra answered 2/4, 2022 at 12:14 Comment(0)
L
0

Is it possible at all?

Lisandra answered 4/4, 2022 at 9:17 Comment(0)
O
0

do you want break some necks?

do you tried in the VBox container Rect/Rotation set it to -90, and labels Align to Right?

Obey answered 4/4, 2022 at 9:43 Comment(0)
L
0

@Zelta said: do you want break some necks?

do you tried in the VBox container Rect/Rotation set it to -90, and labels Align to Right?

This way doesn't work because I don't want the button to be rotated, only the labels.

Lisandra answered 4/4, 2022 at 10:13 Comment(0)
O
0

but you can rotate the button too xD

Obey answered 4/4, 2022 at 10:29 Comment(0)
L
0

@Zelta the button also has text which should be horizontal. Also, all this VBox is a part of bigger layout.

Lisandra answered 4/4, 2022 at 10:47 Comment(0)
O
0

some like this? sorry if i dont understand what are you trying to do

Obey answered 4/4, 2022 at 11:35 Comment(0)
L
0

@Zelta Yeah, exactly what I want! How did you make it? I see there is some symbol on VBoxContainer...

Lisandra answered 4/4, 2022 at 12:41 Comment(0)
O
0

i used a 'Panel' node for layout but you can use any other Labels aligned to right VBox container Alignement set to 'End', rotation -90

the symbol is because the option 'children not selectable'

Obey answered 4/4, 2022 at 14:58 Comment(0)
L
0

@Zelta, unfortunately this doesn't work because I need both Button and VBoxContainer with labels to be inside another container. And this outer container resets rotation of its children.

Lisandra answered 4/4, 2022 at 15:9 Comment(0)
O
0

this way?

Obey answered 4/4, 2022 at 15:49 Comment(0)
A
0

It really is as simple as @Zelta is showing, you likely just aren't yet familiar enough with godots UI/control nodes kit. I'd recommend you keep experimenting - it's actually a very capable system for UIs.

Announce answered 4/4, 2022 at 18:33 Comment(0)
L
0

@Megalomaniak I'm not sure yet)

@Zelta Can you please elaborate on your last screenshot? How are button and labels laid out inside of Panel? It looks like what I need but I'm not sure that layout will work how I need.

Lisandra answered 5/4, 2022 at 7:56 Comment(0)
L
0

Here is what I'm starting with:

Now I need labels to be vertical/rotated AND still participate in layout (i.e. height of the whole container should be equal to the length of the longest label):

But rotation of the labels are controlled by their containers and always reset to 0.

Lisandra answered 5/4, 2022 at 8:4 Comment(0)
A
0

make sure your control nodes horizontal&vertical size flags are also set appropriately.

Announce answered 5/4, 2022 at 14:49 Comment(0)
O
0

i used a panel, check the image. download the scene for ref

Obey answered 5/4, 2022 at 18:35 Comment(0)
L
0

@Zelta Thanks for the scene. Unfortunately it doesn't work the way I need – container with labels is not a part of any other container so it doesn't affect layout/size of other elements (button, panel). Looks like it's simply impossible in Godot to include a rotated element inside of any container.

Lisandra answered 6/4, 2022 at 10:51 Comment(0)
D
0

Hi, did you solve this? I am with a similar issue and I am working around it by using a Node2D as the parent of the label to be able to rotate it, then a Container as the parent of the Node2D. The Container will adapt to its parent, and with a Script I control de position of the childrens. This works but it is a bit tedious. So I'm looking for a solution to simplify it.

Dolph answered 8/11, 2023 at 20:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.