hbox: distribute its children to all available xsize

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
User avatar
_ticlock_
Veteran
Posts: 391
Joined: Mon Oct 26, 2020 5:41 pm
Contact:

hbox: distribute its children to all available xsize

#1 Post by _ticlock_ » Wed Jun 15, 2022 1:09 pm

Hi, everyone!

What is the proper way to distribute hbox children to all available x_size.
I would like to have the following:
border element1 spacing element2 spacing element3 border
with spacing calculated automatically.

If I simply use:

Code: Select all

hbox:
    xfill True
it adds additional spacing after the last element:
border element1 spacing element2 spacing element3 spacing border

adding

Code: Select all

xalign 0.5
has no effect since it is already using all available x_size
I can manually specify the spacing and use xalign to achieve the desirable effect:

Code: Select all

hbox:
    xalign 0.5 
    spacing ((x_size-num_of_elements*element_x_size)/(num_of_elements-1)) 
But I would like to avoid doing it explicitly.

I was suggested to add null width at the start to make it visually centered:

Code: Select all

hbox:
    xfill True
    null width 0
    #other elements
border spacing element1 spacing element2 spacing element3 spacing border

However, is it a simle way to achieve the desirable pattern with variable number of elements:
border element1 spacing element2 spacing element3 border

User avatar
PyTom
Ren'Py Creator
Posts: 15893
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: hbox: distribute its children to all available xsize

#2 Post by PyTom » Wed Jun 15, 2022 7:21 pm

I'm treating this as a feature request, and tracking it at https://github.com/renpy/renpy/issues/3666
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

User avatar
_ticlock_
Veteran
Posts: 391
Joined: Mon Oct 26, 2020 5:41 pm
Contact:

Re: hbox: distribute its children to all available xsize

#3 Post by _ticlock_ » Wed Jun 15, 2022 9:20 pm

PyTom wrote:
Wed Jun 15, 2022 7:21 pm
I'm treating this as a feature request, and tracking it at https://github.com/renpy/renpy/issues/3666
PyTom,

Thank you!

I truly appreciate the time and effort you put into doing an excellent job with Ren'Py!

Post Reply

Who is online

Users browsing this forum: No registered users