Trying to understand horizontally_stretchable with nested elements

Place to get help with not working mods / modding interface.
User avatar
BiterUnion
Inserter
Inserter
Posts: 21
Joined: Fri Aug 19, 2022 7:58 am
Contact:

Trying to understand horizontally_stretchable with nested elements

Post by BiterUnion »

I have two nested frames (outer_frame and inner_frame) and am trying to understand how horizontally_stretchable changes the layout, when setting it on inner_frame:

Code: Select all

local frame = player.gui.screen.add {
    type = 'frame'
}
frame.style.size = 150
frame.force_auto_center()

local outer_frame = frame.add {
    type = 'frame',
    style = 'inside_shallow_frame_with_padding'
}
outer_frame.style.horizontally_stretchable = true
outer_frame.style.vertically_stretchable = true

local inner_frame = outer_frame.add {
    type = 'frame',
    style = 'deep_frame_in_shallow_frame'
}
inner_frame.style.natural_width = 50
inner_frame.style.maximal_width = 70
inner_frame.style.horizontally_stretchable = true  -- this is the line I am talking about
inner_frame.style.vertically_stretchable = true
Without setting inner_frame.style.horizontally_stretchable = true, the frames look as I would expect it:

Image

The inner frame has its natural width and stretches vertically and the outer frame completely fills the window. However, when I set inner_frame.style.horizontally_stretchable = true, it looks like this:

Image

The inner frame behaves as expected (it stretches to its maximal width), but the outer frame no longer stretches to the full width of the window.

Is this behavior intended by the devs? To me it seems like a bug, because setting direction = 'vertical' on the outer frame causes the outer frame to fill the window completely again.

Many thanks in advance!
Post Reply

Return to “Modding help”