Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for rem values in min()/max() #6697

Open
Enyium opened this issue Nov 1, 2024 · 1 comment
Open

Support for rem values in min()/max() #6697

Enyium opened this issue Nov 1, 2024 · 1 comment
Labels
a:language-slint Compiler for the .slint language (mO,bF) bug Something isn't working good first issue Good for newcomers

Comments

@Enyium
Copy link
Contributor

Enyium commented Nov 1, 2024

min()/max() already support some type heterogeneity: You can use px with phx. However, to specify one of the values as a rem value, you have to multiply with root.default-font-size:

export component AppWindow inherits Window {
    property <length> size: 50px;

    Rectangle {
        min-width: max(20 /*rem*/ * root.default-font-size, root.size);
        background: skyblue;
    }
}

Is there a chance that rem values can be mixed with px/phx in min()/max() (and maybe others like clamp() and mod())? It would look like this:

export component AppWindow inherits Window {
    property <length> size: 50px;

    Rectangle {
        min-width: max(20rem, root.size);
        background: skyblue;
    }
}
@ogoffart
Copy link
Member

ogoffart commented Nov 1, 2024

Indeed, the Type::Rem is not handled in

let ty = match base.ty() {

I think actually min/max should ideally work with any number type (there is no easy way to check for that, one way is ty.as_unit_product().is_some()

@ogoffart ogoffart added bug Something isn't working good first issue Good for newcomers a:language-slint Compiler for the .slint language (mO,bF) labels Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:language-slint Compiler for the .slint language (mO,bF) bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants