-
Consider this code: import { Button } from "std-widgets.slint";
component Container inherits Rectangle {
background: pink;
Rectangle {
width: 100px; // How to use `@children`'s size?
height: 100px;
background: lime;
@children
}
}
export component Demo {
width: 300px;
height: 300px;
Container {
Button { text: "Foo"; }
}
} How can I bind to |
Beta Was this translation helpful? Give feedback.
Answered by
Enyium
Sep 23, 2024
Replies: 2 comments 1 reply
-
The thing is, do you actually need @children's size to make as large as them ? import { Button } from "std-widgets.slint";
component Container inherits Rectangle {
background: pink;
in-out property inner-width<length> : outerRect.width;
n-out property inner-height<length> : outerRect.height;
outerRect := Rectangle {
width: 100px; // How to use `@children`'s size?
height: 100px;
background: lime;
innerRect := Rectangle{
width: root.inner-width;
height: root.height;
background: parent.background;
@children
}
}
}
export component Demo {
width: 300px;
height: 300px;
Container {
inner-width: bt.width;
inner-height: bt.height;
bt := Button { text: "Foo"; }
}
} or something like that .... |
Beta Was this translation helpful? Give feedback.
0 replies
-
i'd use a layout: Rectangle {
width: l.preferred-width;
height: l.preferred-height;
background: lime;
l := VerticalLayout { @children }
} |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think, looking forward, a
CellLayout
would be the go-to solution for this. See #4800 (comment).