Surrealism-All / SurrealismUI

A third-party UI library using Slint, I think it will give you an extraordinary experience
https://surrealism-all.github.io/SurrealismUI.github.io/
MIT License
197 stars 19 forks source link

SMenu's height cannot be shrinked #44

Closed windoze closed 1 month ago

windoze commented 1 month ago

A minimal example:

import { SMenu  } from "surrealism-ui/index.slint";
export component AppWindow inherits Window {
    HorizontalLayout {
        SMenu { }

        Rectangle {
            min-width: 300px;
        }
    }
}

The AppWindow's height can be extended, but cannot be shrinked back.

syf20020816 commented 1 month ago

you may need to set SMenu height: 100%, and if you need to expand or shrink the window, try fresh the window or reset the menu height. Other wise you can set the height as parent.height

windoze commented 1 month ago

Added height: 100%; in SMenu, nothing changed, kinda weird. I checked the source code and didn't see anything suspicious.

https://github.com/user-attachments/assets/2126f500-890a-431a-b3cd-0ceaa2c743db

windoze commented 1 month ago

Actually I also tried to put the slint UI into a Rust app, the window cannot be vertically shrinked as well, the behavior was identical to the Sline preview. The resizing is back to be working if I replace the SMenu by something else like:

        Rectangle {
            height: 100%;
            width: 40px;
            background: #053320;
        }
syf20020816 commented 1 month ago

SMenu inherits SCard, It may because SCard has bind height, and SMenu has bind height too. you do not set any option props, so SMenu keep the default

syf20020816 commented 1 month ago

You may need to check your version, is that V0.5.0? I test it, it seems no issue

https://github.com/user-attachments/assets/d2bc68b5-769c-4f95-a631-48a08f5ec873

syf20020816 commented 1 month ago

this test is in test package: https://github.com/Surrealism-All/SurrealismUI/blob/main/tests/src/menu.slint you just need to remove the window height and width

windoze commented 1 month ago

Everything back to work when I added:

        x: 0;
        y: 0;

to the container that contains SMenu.

Such a magic...

Not sure if it's a bug or a feature after all.