slint-ui / slint

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

Preview widens when replacing `100%` by `parent.width` #6321

Closed Enyium closed 1 month ago

Enyium commented 1 month ago

Consider this SlintPad demo (see comments):

import { HorizontalBox } from "std-widgets.slint";

export component Demo {
    HorizontalBox {
        alignment: center;
        //padding: 0; // Bug doesn't happen with this.

        Rectangle {
            // Every cutting of `100%;//` makes preview widen.
            width: 100%;//parent.width;

            height: 20px;
            background: fuchsia;
        }
    }
}

Happens in SlintPad and VS Code preview window.

ogoffart commented 1 month ago

Duplicate of https://github.com/slint-ui/slint/issues/2902

(percentages size are considered differently by the layout than a literal parent.width. There is, in fact, a binding loop there but we don't detect it, see #2902)