Issue with the button-based pie menus is that when the text grows, the alignment goes all wobbly like so:

So I tried to fix it. The following is me trying to get that to work (and failing, kinda)
I wanted to avoid manually repositioning them so I tried setting the button grow direction:
for btn in buttons:
btn.rect_position = Vector2(button_radius, 0).rotated(angle)
if angle == PI*1.5 or angle == PI*0.5 or angle == PI*-0.5:
btn.grow_horizontal = Control.GROW_DIRECTION_BOTH
elif angle >= PI*0.5 and angle < PI*1.5:
btn.grow_horizontal = Control.GROW_DIRECTION_BEGIN
else:
btn.grow_horizontal = Control.GROW_DIRECTION_END
angle += angle_offset

As you can see, this works... with a caveat. For some reason, the next time you call it the .grow_horizontal
property always acts as if it's back to GROW_DIRECTION_END
, so you're back to how it was before. I'm not sure if this is a bug with buttons or not... In my code, I was calling queue_free()
the buttons and making new ones as children. Yet, the buttons would somehow keep some sort of state between this...
I inspected the buttons of pie menu before and after: the difference was that margin
changed. I don't know enough about how margin gets set yet to figure this out! Does anyone have any insight?
Here's what actually does work... on the second time it's called:
for btn in buttons:
btn.grow_horizontal = Control.GROW_DIRECTION_END
btn.rect_position = Vector2(button_radius, 0).rotated(angle)
if angle == PI*1.5 or angle == PI*0.5 or angle == PI*-0.5:
btn.rect_position.x -= btn.rect_size.x / 2
elif angle > PI*0.5 and angle < PI*1.5:
btn.rect_position.x -= btn.rect_size.x
angle += angle_offset