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.67k stars 611 forks source link

`@radial-gradient` does not error when used on a `property <color>` #6819

Open bryce-happel-walton opened 1 week ago

bryce-happel-walton commented 1 week ago

Language: Rust Platform: Arm64

While messing around with brushes I noticed I wasn't getting the expected results from a gradient. Eventually I figured out that I was passing the macro to a property <color> and passing the property <color> to a property <brush>.

Using gradient macros on property <color> should at least produce a warning. It will truncate the result to the first color provided to the macro, I do not believe this to be an intuitive outcome.

ogoffart commented 1 week ago

Indeed, it would be worth displaying a warning when the user literally use @...-gradiant macro that is immediately converted to a colour.

The condition can be detected there https://github.com/slint-ui/slint/blob/74e23881b50544069adc69dbc590c33f04e4cab5/internal/compiler/expression_tree.rs#L1102