Trying to understand horizontally_stretchable with nested elements
Posted: Wed Apr 12, 2023 3:54 pm
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:
Without setting inner_frame.style.horizontally_stretchable = true, the frames look as I would expect it:

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:

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!
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

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:

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!