slint-ui / slint

Slint is a declarative GUI toolkit to build native user interfaces for Rust, C++, or JavaScript apps.
https://slint.dev
Other
16.94k stars 568 forks source link

dependent dimension properties shrink/grow preview frame #4962

Closed HookedBehemoth closed 5 months ago

HookedBehemoth commented 5 months ago

I found this weird case where when a rectangle inside a VerticalBox defines its dimensions based on the parent dimensions, the preview keeps growing or shrinking when any parameter is changed. I'm uncertain how I'd expect this to behave.

steps to reproduce: copy code, open preview, change anything

https://github.com/slint-ui/slint/assets/22580720/49332cc9-72ec-4a58-8b2b-fe3cf5e81762


export component POC inherits Window {
    VerticalBox {
        Rectangle {
            width: min(parent.width, parent.height) * 110%;
            height: 500px;
        }
    }
}
ogoffart commented 5 months ago

Thanks for the bug report.

This is actually a duplicate of https://github.com/slint-ui/slint/issues/2902 The problem is that there is a loop in the binding computatin as the parent size depends on the layout size. We should actually error out or warn about it but it's hard because there is legimitate use, see https://github.com/slint-ui/slint/pull/3997

(Closing as duplicate, but thanks anyway for reporting)