Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Layout ignore explicit minimum size when smaller than default minimum size #5755

Open
cEvolve05 opened this issue Aug 3, 2024 · 2 comments
Labels
a:layouts Related to the layouting and positioning of the elements (mO,bT) needs info Further information from the reporter is requested

Comments

@cEvolve05
Copy link

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;
            }
        }
    }
}
@ogoffart
Copy link
Member

ogoffart commented Aug 6, 2024

I it work correctly: You can resize the layout to 0.
For the purpose of the default space allocation, it would use preferred-height.

@ogoffart ogoffart added needs info Further information from the reporter is requested a:layouts Related to the layouting and positioning of the elements (mO,bT) labels Aug 6, 2024
@cEvolve05
Copy link
Author

cEvolve05 commented Aug 6, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:layouts Related to the layouting and positioning of the elements (mO,bT) needs info Further information from the reporter is requested
Projects
None yet
Development

No branches or pull requests

2 participants