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.52k stars 600 forks source link

Incorrect size when show/hide title bar #4933

Open hanzuken opened 7 months ago

hanzuken commented 7 months ago

Slint version: v1.5.0 Backend: Winit-skia Sample code: appwindow.slint

export component AppWindow inherits Window {
    no-frame: !self.has-header;
    width: 800px;
    height: 600px;
    in-out property<bool> has-header: false;
    callback show-hide-header();
    VerticalBox {
        Button {
            text: "Show/hide header";
            clicked => {
                root.show-hide-header();
            }
        }
     }
}

main.cpp

#include "appwindow.h"
#include <iostream>

int main(int argc, char **argv)
{
    auto ui = AppWindow::create();

    ui->on_show_hide_header([&]{
        ui->set_has_header(!ui->get_has_header());
        auto size = ui->window().size();
        std::cout << "size: " << size.width << "x" << size.height << std::endl;
    });

    ui->run();
    return 0;
}

Expected: The window size should be kept the same Actual: The window size has been reduced and the entire app cannot be viewed. image

tronical commented 1 month ago

What windowing system / operating system are you using? (I tried reproducing this on macOS, Gnome with Wayland, as well as Windows 10)