Layout ignore explicit minimum size when smaller than default minimum size
cEvolve05 opened this issue · comments
C++/Slint 1.7.1
When a explicit minimum size is smaller than default minimum size, Layout(alignment: stretch
) will ignore the explicit minimum size: Layout won't use the explicit minimum, it use default minimum instead. Attached code may convey my issue more clearly.
The expected behavior: Layout use explicit minimum size to allocate the layout space.
Setting minimum size to 0 is intended to allocate the layout space to elements only through vertical-stretch
(horizontal-stretch
), rather than allocating the spare space.
component Example {
HorizontalLayout {
VerticalLayout {
horizontal-stretch: 1;
Rectangle {
min-height: 0px;
vertical-stretch: 2;
background: green;
}
Rectangle {
min-height: 0px;
vertical-stretch: 1;
background: red;
}
}
VerticalLayout {
horizontal-stretch: 1;
Rectangle {
min-height: 0px;
vertical-stretch: 2;
background: green;
Text {
min-height: 0px;
text: "test\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest";
}
}
Rectangle {
min-height: 0px;
vertical-stretch: 1;
background: red;
}
}
}
}
I it work correctly: You can resize the layout to 0.
For the purpose of the default space allocation, it would use preferred-height.
Thanks for your reply, I know the problem.
In the document Stretch algorithm, it describes that algorithm will size elements to their minimum size and allocate spare space to elements. I previously think minimum size refer to min-height
/min-width
. After your reply, I made some tests and know it actually refer to the bigger one between min-*
and preferred-*
I hope I understand correctly. If I'm correct, the document may need an update to clarify what property it actually used. And if possible, it may be helpful for some user to add a link to corresponding source code as "advanced insight" part or something similar.