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.95k stars 568 forks source link

The size of root Window will not update when its layout constraints resize in Slint 1.3.0 #3911

Closed Horbin-Magician closed 8 months ago

Horbin-Magician commented 10 months ago

(Win11, Rust, winit-femtovg) This is my simple demo:

import { Button, VerticalBox } from "std-widgets.slint";
export component AppWindow inherits Window {
    VerticalBox {
        Button {
            width: 100px;
            clicked => {
                self.width += 100px;
            }
        }
    }
}

I hope that when the button is clicked, the size of the button and the window change together. It works well in Slint1.2.2, but doesn't work in Slint1.3.0.

I think the feature of the window changing with the size of its content is very important, so this might be a Bug in the new version (1.3.0).

ogoffart commented 10 months ago

I couldn't reproduce the problem on X11.

Horbin-Magician commented 10 months ago

I couldn't reproduce the problem on X11.

But this phenomenon does occur on two of my windows devices (one win10, the other win11). Can I get details somewhere about how to read and contribute to the source code? Maybe I can try to fix this myself.

ogoffart commented 10 months ago

I haven't tried with Windows yet. In slint, the code that sets the window constraints is supposed to be there: https://github.com/slint-ui/slint/blob/84202f6af3ae56f0ae51fd61268d360487f9980d/internal/backends/winit/winitwindowadapter.rs#L553

What i'd do to debug is check (by adding eprintln) if this is called with the expected value of the size. If it is called, then it might be a problem in winit.

Horbin-Magician commented 10 months ago

I haven't tried with Windows yet. In slint, the code that sets the window constraints is supposed to be there:

https://github.com/slint-ui/slint/blob/84202f6af3ae56f0ae51fd61268d360487f9980d/internal/backends/winit/winitwindowadapter.rs#L553

What i'd do to debug is check (by adding eprintln) if this is called with the expected value of the size. If it is called, then it might be a problem in winit.

https://github.com/slint-ui/slint/assets/46142827/b9e40a07-f828-468d-ac29-34da8c591beb

So, this is a problem in winit?

ogoffart commented 10 months ago

Yes, this seems to be a bug in winit

ogoffart commented 8 months ago

I assume this was fixed by #4032