-
Notifications
You must be signed in to change notification settings - Fork 515
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
HorizontalLayout restricting window size #5391
Comments
Can confirm the windows issue. |
forgot to mention that the exact same issue happens with |
Thanks for filling a bug. This is the expected behavior. Layout have maximum and minimum size and are constrained by their contents by default. So if the inside of the layout is fixed, this fixes the size of the all window. By changing the What is your expectation with this code? |
i at least can understand overwriting preferred width, but i expect |
Hi, I don't see how this would be expected behaviour. I would not expect setting the dimensions of a child object to forcibly turn off resizing of the parent object, I would just expect it make the rectangle 50px by 50px |
update: the next day some of the behavior has changed. |
after more testing, ive narrowed it down to this behavior: min-width: 1280px;
preferred-height: 720px;
min-height: 200px; and a vertical layout. |
The problem is that the layout gives a maximum size to the window, and that maximum size is smaller than the minimum. This is the same as writting export component Test inherits Window {
min-width: 1000px;
max-width: 300px;
} The current behavior with the winit backend is that you can resize the window between 1000 and 300. Admittedly, it's not great.
The layout propagates constrains from the child to the parents. And then it propagates sizes from the parents to the child. |
I also noticed that the window size is violated when using an empty layout. export component MainWindow inherits Window {
preferred-width: 400px;
preferred-height: 200px;
VerticalLayout {
Text { text: "Text"; } // suprisingly working fine without this line
HorizontalLayout {} // <- this line causing a problem
}
} Maybe it's not a big deal in the example code, but, for example, it might be in a custom component where children are not mandatory: component LabeledElement inherits Rectangle {
in property <string> label;
VerticalLayout {
Text { text: root.label; }
HorizontalLayout {
@children
}
}
} |
In my opinion, it is completely unintuitive and ridiculous for the size constraint of a child to effect the window. The child object is a child. it is meant to sit inside its parent. the expected behavior is for the height and width of the child to affect the child, and for the height and width of the parent to effect the parent. If this is intended behavior, then i believe that this framework is incredibly poorly designed and does not attempt to communicate how its constraints work at all.
attempts to work around this restriction has still lead to issues. |
The documentation might needs clarification, but the constraints propagate from the child to the parent. We try to document it in https://releases.slint.dev/1.6.0/docs/slint/src/language/concepts/layouting and we discussed it in https://slint.dev/blog/changes-to-the-slint-language-part-2 If you don't want this behavior, why use a layout at all? I believe then this does what you want (removed the layout) export component AppWindow inherits Window {
title: "My App";
background: @linear-gradient(45deg, #000000 0%, #222222 30%, #222222 70%, #000000 100%);
preferred-width: 1280px;
preferred-height: 720px;
Rectangle {
width: 50px;
height: 50px;
background: blue;
}
} How could we improve the docs? |
this is literally the exact opposite of both what is happening, and what youre insisting is intended behavior. |
No matter what angle you look at this from, something doesnt work. If the child is meant to propagate properties to the parent (ignoring that this is the opposite of how a parent-child relationship works) then why does this only affect this one specific example and only with the width of the window? |
When using
HorizontalLayout
inside a window, thepreferred-width
of the window is ignored and is set to the width of the layout, being unable to be resized. If the layout haswidth: root.width
, the window will be wider, but still smaller than it should be and unable to be resized.min-width
has no effect.im currently using linux with x11, but this also happened on windows.
The text was updated successfully, but these errors were encountered: